1
0
Fork 1
mirror of https://example.com synced 2024-11-22 14:46:38 +09:00

WIP (wasm-bindgen)

This commit is contained in:
naskya 2024-02-03 22:15:40 +09:00
parent 18aeeaabd2
commit a27edd668a
Signed by: naskya
GPG key ID: 712D413B3A9FED5C
161 changed files with 1550 additions and 532 deletions

2
.gitignore vendored
View file

@ -34,7 +34,7 @@ coverage
.eslintcache
# misskey
built
/built
db
elasticsearch
redis

67
Cargo.lock generated
View file

@ -230,6 +230,7 @@ dependencies = [
"rand",
"regex",
"schemars",
"sdk",
"sea-orm",
"serde",
"serde_json",
@ -1118,9 +1119,9 @@ dependencies = [
[[package]]
name = "indexmap"
version = "2.2.1"
version = "2.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "433de089bd45971eecf4668ee0ee8f4cec17db4f8bd8f7bc3197a6ce37aa7d9b"
checksum = "824b2ae422412366ba479e8111fd301f7b5faece8149317bb81925979a53f520"
dependencies = [
"equivalent",
"hashbrown 0.14.3",
@ -1235,9 +1236,9 @@ dependencies = [
[[package]]
name = "libc"
version = "0.2.152"
version = "0.2.153"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7"
checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
[[package]]
name = "libloading"
@ -1338,9 +1339,9 @@ dependencies = [
[[package]]
name = "napi"
version = "2.15.0"
version = "2.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efbf98e1bcb85cc441bbf7cdfb11070d2537a100e2697d75397b2584c32492d1"
checksum = "43792514b0c95c5beec42996da0c1b39265b02b75c97baa82d163d3ef55cbfa7"
dependencies = [
"bitflags 2.4.2",
"chrono",
@ -1475,6 +1476,12 @@ dependencies = [
"num-traits",
]
[[package]]
name = "num-conv"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
[[package]]
name = "num-integer"
version = "0.1.45"
@ -1880,9 +1887,9 @@ dependencies = [
[[package]]
name = "reqwest"
version = "0.11.23"
version = "0.11.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37b1ae8d9ac08420c66222fb9096fc5de435c3c48542bc5336c51892cffafb41"
checksum = "c6920094eb85afde5e4a138be3f2de8bbdf28000f0029e72c45025a56b042251"
dependencies = [
"base64",
"bytes",
@ -1903,6 +1910,7 @@ dependencies = [
"serde",
"serde_json",
"serde_urlencoded",
"sync_wrapper",
"system-configuration",
"tokio",
"tower-service",
@ -1978,9 +1986,9 @@ dependencies = [
[[package]]
name = "rust_decimal"
version = "1.33.1"
version = "1.34.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06676aec5ccb8fc1da723cc8c0f9a46549f21ebb8753d3915c6c41db1e7f1dc4"
checksum = "755392e1a2f77afd95580d3f0d0e94ac83eeeb7167552c9b5bca549e61a94d83"
dependencies = [
"arrayvec",
"borsh",
@ -2000,9 +2008,9 @@ checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
[[package]]
name = "rustix"
version = "0.38.30"
version = "0.38.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca"
checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949"
dependencies = [
"bitflags 2.4.2",
"errno",
@ -2088,6 +2096,13 @@ dependencies = [
"untrusted",
]
[[package]]
name = "sdk"
version = "0.0.0"
dependencies = [
"wasm-bindgen",
]
[[package]]
name = "sea-bae"
version = "0.2.0"
@ -2684,6 +2699,12 @@ dependencies = [
"syn 2.0.48",
]
[[package]]
name = "sync_wrapper"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160"
[[package]]
name = "system-configuration"
version = "0.5.1"
@ -2746,12 +2767,13 @@ dependencies = [
[[package]]
name = "time"
version = "0.3.31"
version = "0.3.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e"
checksum = "fe80ced77cbfb4cb91a94bf72b378b4b6791a0d9b7f09d0be747d1bdff4e68bd"
dependencies = [
"deranged",
"itoa",
"num-conv",
"powerfmt",
"serde",
"time-core",
@ -2766,10 +2788,11 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3"
[[package]]
name = "time-macros"
version = "0.2.16"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26197e33420244aeb70c3e8c78376ca46571bc4e701e4791c2cd9f57dcb3a43f"
checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774"
dependencies = [
"num-conv",
"time-core",
]
@ -2790,9 +2813,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "tokio"
version = "1.35.1"
version = "1.36.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104"
checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931"
dependencies = [
"backtrace",
"bytes",
@ -2851,9 +2874,9 @@ checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1"
[[package]]
name = "toml_edit"
version = "0.21.0"
version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03"
checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1"
dependencies = [
"indexmap",
"toml_datetime",
@ -3245,9 +3268,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"
[[package]]
name = "winnow"
version = "0.5.35"
version = "0.5.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1931d78a9c73861da0134f453bb1f790ce49b2e30eba8410b4b79bac72b46a2d"
checksum = "818ce546a11a9986bc24f93d0cdf38a8a1a400f1473ea8c82e59f6e0ffab9249"
dependencies = [
"memchr",
]

View file

@ -1,5 +1,5 @@
[workspace]
members = ["packages/backend-rs"]
members = ["packages/backend-rs", "packages/sdk"]
resolver = "2"
[workspace.dependencies]
@ -7,6 +7,8 @@ napi = { version = "2.15.0", default-features = false }
napi-build = "2.1.0"
napi-derive = "2.15.0"
wasm-bindgen = "0.2.90"
argon2 = "0.5.3"
async-trait = "0.1.77"
basen = "0.1.0"

View file

@ -9,15 +9,22 @@ PACKAGE_JSONS += packages/client/package.json
PACKAGE_JSONS += packages/firefish-js/package.json
PACKAGE_JSONS += packages/megalodon/package.json
PACKAGE_JSONS += packages/sw/package.json
PACKAGE_JSONS += packages/sdk/package.json
CARGO_TOMLS := Cargo.toml
CARGO_TOMLS += packages/backend-rs/Cargo.toml
CARGO_TOMLS += packages/sdk/Cargo.toml
RUST_BE_DIR := packages/backend-rs
RUST_BE_SRC := Cargo.toml
RUST_BE_SRC += $(RUST_BE_DIR)/Cargo.toml
RUST_BE_SRC += $(call recursive_wildcard, $(RUST_BE_DIR)/src, *)
SDK_DIR := packages/sdk
SDK_SRC := Cargo.toml
SDK_SRC += $(SDK_DIR)/Cargo.toml
SDK_SRC += $(call recursive_wildcard, $(SDK_DIR)/src, *)
MIGRATIONS := $(foreach dir, packages/backend/migration, $(wildcard $(dir)/*))
MIGRATIONS += $(foreach dir, packages/backend/migration-neko, $(wildcard $(dir)/*))
@ -85,12 +92,16 @@ format:
.PHONY: rust-lint
rust-lint: $(T)/rust-be-lint
rust-lint: $(T)/rust-be-lint $(T)/sdk-lint
$(T)/rust-be-lint: $(RUST_BE_SRC)
pnpm --filter='backend-rs' run lint
touch $@
$(T)/sdk-lint: $(SDK_SRC)
pnpm --filter='sdk' run lint
touch $@
.PHONY: regenerate-entities
regenerate-entities: $(T)/regenerate-entities

View file

@ -1,7 +1,5 @@
/* tslint:disable */
// prettier-ignore
/* eslint-disable */
/* prettier-ignore */
/* auto-generated by NAPI-RS */
const { existsSync, readFileSync } = require('fs')
@ -13,18 +11,52 @@ let nativeBinding = null
let localFileExisted = false
let loadError = null
function isMusl() {
// For Node 10
if (!process.report || typeof process.report.getReport !== 'function') {
try {
const lddPath = require('child_process').execSync('which ldd').toString().trim()
return readFileSync(lddPath, 'utf8').includes('musl')
} catch (e) {
const isMusl = () => {
let musl = false
if (process.platform === 'linux') {
musl = isMuslFromFilesystem()
if (musl === null) {
musl = isMuslFromReport()
}
if (musl === null) {
musl = isMuslFromChildProcess()
}
}
return musl
}
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
const isMuslFromFilesystem = () => {
try {
return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
} catch {
return null
}
}
const isMuslFromReport = () => {
const report = typeof process.report.getReport === 'function' ? process.report.getReport() : null
if (!report) {
return null
}
if (report.header && report.header.glibcVersionRuntime) {
return false
}
if (Array.isArray(report.sharedObjects)) {
if (report.sharedObjects.some(isFileMusl)) {
return true
}
} else {
const { glibcVersionRuntime } = process.report.getReport().header
return !glibcVersionRuntime
}
return false
}
const isMuslFromChildProcess = () => {
try {
return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
} catch (e) {
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
return false
}
}
@ -288,6 +320,21 @@ switch (platform) {
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
}
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
try {
nativeBinding = require('./backend-rs.wasi.cjs')
} catch {
// ignore
}
if (!nativeBinding) {
try {
nativeBinding = require('backend-rs-wasm32-wasi')
} catch (err) {
console.error(err)
}
}
}
if (!nativeBinding) {
if (loadError) {
throw loadError
@ -295,45 +342,41 @@ if (!nativeBinding) {
throw new Error(`Failed to load native binding`)
}
const { EnvConfig, readEnvironmentConfig, readServerConfig, JsDbConn, connectToDatabase, AntennaSrcEnum, MutedNoteReasonEnum, NoteVisibilityEnum, NotificationTypeEnum, PageVisibilityEnum, PollNotevisibilityEnum, RelayStatusEnum, UserEmojimodpermEnum, UserProfileFfvisibilityEnum, UserProfileMutingnotificationtypesEnum, stringToAcct, acctToString, checkWordMute, getFullApAccount, isSelfHost, extractHost, toPuny, toPunyOptional, convertToHiddenPost, sqlLikeEscape, safeForSql, formatMilliseconds, nativeInitIdGenerator, nativeCreateId, nativeGetTimestamp, fetchMeta, metaToPugArgs, hasOtherRenoteOfThisNote, nyaify, hashPassword, verifyPassword, isOldPasswordAlgorithm, genString, IdConvertType, convertId } = nativeBinding
module.exports.EnvConfig = EnvConfig
module.exports.readEnvironmentConfig = readEnvironmentConfig
module.exports.readServerConfig = readServerConfig
module.exports.JsDbConn = JsDbConn
module.exports.connectToDatabase = connectToDatabase
module.exports.AntennaSrcEnum = AntennaSrcEnum
module.exports.MutedNoteReasonEnum = MutedNoteReasonEnum
module.exports.NoteVisibilityEnum = NoteVisibilityEnum
module.exports.NotificationTypeEnum = NotificationTypeEnum
module.exports.PageVisibilityEnum = PageVisibilityEnum
module.exports.PollNotevisibilityEnum = PollNotevisibilityEnum
module.exports.RelayStatusEnum = RelayStatusEnum
module.exports.UserEmojimodpermEnum = UserEmojimodpermEnum
module.exports.UserProfileFfvisibilityEnum = UserProfileFfvisibilityEnum
module.exports.UserProfileMutingnotificationtypesEnum = UserProfileMutingnotificationtypesEnum
module.exports.stringToAcct = stringToAcct
module.exports.acctToString = acctToString
module.exports.checkWordMute = checkWordMute
module.exports.getFullApAccount = getFullApAccount
module.exports.isSelfHost = isSelfHost
module.exports.extractHost = extractHost
module.exports.toPuny = toPuny
module.exports.toPunyOptional = toPunyOptional
module.exports.convertToHiddenPost = convertToHiddenPost
module.exports.sqlLikeEscape = sqlLikeEscape
module.exports.safeForSql = safeForSql
module.exports.formatMilliseconds = formatMilliseconds
module.exports.nativeInitIdGenerator = nativeInitIdGenerator
module.exports.nativeCreateId = nativeCreateId
module.exports.nativeGetTimestamp = nativeGetTimestamp
module.exports.fetchMeta = fetchMeta
module.exports.metaToPugArgs = metaToPugArgs
module.exports.hasOtherRenoteOfThisNote = hasOtherRenoteOfThisNote
module.exports.nyaify = nyaify
module.exports.hashPassword = hashPassword
module.exports.verifyPassword = verifyPassword
module.exports.isOldPasswordAlgorithm = isOldPasswordAlgorithm
module.exports.genString = genString
module.exports.IdConvertType = IdConvertType
module.exports.convertId = convertId
module.exports.EnvConfig = nativeBinding.EnvConfig
module.exports.JsDbConn = nativeBinding.JsDbConn
module.exports.AntennaSrcEnum = nativeBinding.AntennaSrcEnum
module.exports.checkWordMute = nativeBinding.checkWordMute
module.exports.connectToDatabase = nativeBinding.connectToDatabase
module.exports.convertId = nativeBinding.convertId
module.exports.convertToHiddenPost = nativeBinding.convertToHiddenPost
module.exports.extractHost = nativeBinding.extractHost
module.exports.fetchMeta = nativeBinding.fetchMeta
module.exports.formatMilliseconds = nativeBinding.formatMilliseconds
module.exports.genString = nativeBinding.genString
module.exports.getFullApAccount = nativeBinding.getFullApAccount
module.exports.hashPassword = nativeBinding.hashPassword
module.exports.hasOtherRenoteOfThisNote = nativeBinding.hasOtherRenoteOfThisNote
module.exports.IdConvertType = nativeBinding.IdConvertType
module.exports.isOldPasswordAlgorithm = nativeBinding.isOldPasswordAlgorithm
module.exports.isSelfHost = nativeBinding.isSelfHost
module.exports.metaToPugArgs = nativeBinding.metaToPugArgs
module.exports.MutedNoteReasonEnum = nativeBinding.MutedNoteReasonEnum
module.exports.nativeCreateId = nativeBinding.nativeCreateId
module.exports.nativeGetTimestamp = nativeBinding.nativeGetTimestamp
module.exports.nativeInitIdGenerator = nativeBinding.nativeInitIdGenerator
module.exports.NoteVisibilityEnum = nativeBinding.NoteVisibilityEnum
module.exports.NotificationTypeEnum = nativeBinding.NotificationTypeEnum
module.exports.nyaify = nativeBinding.nyaify
module.exports.PageVisibilityEnum = nativeBinding.PageVisibilityEnum
module.exports.PollNotevisibilityEnum = nativeBinding.PollNotevisibilityEnum
module.exports.readEnvironmentConfig = nativeBinding.readEnvironmentConfig
module.exports.readServerConfig = nativeBinding.readServerConfig
module.exports.RelayStatusEnum = nativeBinding.RelayStatusEnum
module.exports.safeForSql = nativeBinding.safeForSql
module.exports.sqlLikeEscape = nativeBinding.sqlLikeEscape
module.exports.toPuny = nativeBinding.toPuny
module.exports.toPunyOptional = nativeBinding.toPunyOptional
module.exports.UserEmojimodpermEnum = nativeBinding.UserEmojimodpermEnum
module.exports.UserProfileFfvisibilityEnum = nativeBinding.UserProfileFfvisibilityEnum
module.exports.UserProfileMutingnotificationtypesEnum = nativeBinding.UserProfileMutingnotificationtypesEnum
module.exports.verifyPassword = nativeBinding.verifyPassword

View file

@ -42,6 +42,7 @@ br
say 'Start building Firefish.'
say 'It takes some time! Why not brew a cup of cofe?'
run 'rustup target add wasm32-wasi-preview1-threads'
run 'NODE_OPTIONS="--max_old_space_size=3072" NODE_ENV="production" pnpm run rebuild'
say "Done! We're almost there."

View file

@ -13,7 +13,7 @@
"private": true,
"scripts": {
"rebuild": "pnpm run clean && pnpm run build",
"build": "pnpm --filter backend-rs run build && pnpm --filter firefish-js run build && pnpm --filter !firefish-js --filter !backend-rs -r --parallel run build && pnpm run gulp",
"build": "pnpm --filter sdk run build && pnpm --filter backend-rs run build && pnpm --filter firefish-js run build && pnpm --filter !sdk --filter !firefish-js --filter !backend-rs -r --parallel run build && pnpm run gulp",
"start": "pnpm --filter backend run start",
"start:container": "pnpm run gulp && pnpm run migrate && pnpm run start",
"init": "pnpm run migrate",
@ -25,7 +25,7 @@
"dev:staging": "NODE_OPTIONS=--max_old_space_size=3072 NODE_ENV=development pnpm run build && pnpm run start",
"lint": "pnpm -r --parallel run lint",
"debug": "pnpm run build:debug && pnpm run start",
"build:debug": "pnpm clean && pnpm --filter backend-rs run build:debug && pnpm --filter firefish-js run build:debug && pnpm --filter firefish-js run build:types && pnpm --filter !firefish-js --filter !backend-rs -r --parallel run build:debug && pnpm run gulp",
"build:debug": "pnpm clean && pnpm --filter sdk run build:debug && pnpm --filter backend-rs run build:debug && pnpm --filter firefish-js run build:debug && pnpm --filter firefish-js run build:types && pnpm --filter !sdk --filter !firefish-js --filter !backend-rs -r --parallel run build:debug && pnpm run gulp",
"format": "pnpm -r --parallel run format",
"clean": "pnpm node ./scripts/clean-built.mjs",
"clean-cargo": "cargo clean",
@ -36,7 +36,6 @@
"dependencies": {
"@bull-board/api": "5.14.0",
"@bull-board/ui": "5.14.0",
"@napi-rs/cli": "2.18.0",
"gulp": "4.0.2",
"gulp-cssnano": "2.1.3",
"gulp-replace": "1.1.4",

View file

@ -8,3 +8,4 @@ This directory contains all of the packages Firefish uses.
- `sw`: Web [Service Worker](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API) written in TypeScript
- `firefish-js`: TypeScript SDK for both backend and client, also published on [NPM](https://www.npmjs.com/package/firefish-js) for public use
- `megalodon`: TypeScript library used for partial Mastodon API compatibility
- `sdk`: SDK for both backend and client, written in Rust, bound to WebAssembly by [NAPI-RS](https://napi.rs/)

View file

@ -10,6 +10,8 @@ crate-type = ["cdylib", "lib"]
napi = { workspace = true, default-features = false, features = ["napi9", "tokio_rt", "chrono_date", "serde-json"] }
napi-derive = { workspace = true }
sdk = { path = "../sdk" }
argon2 = { workspace = true }
async-trait = { workspace = true }
basen = { workspace = true }

View file

@ -4,26 +4,11 @@
"main": "built/index.js",
"types": "built/index.d.ts",
"napi": {
"name": "backend-rs",
"triples": {
"additional": [
"aarch64-apple-darwin",
"aarch64-linux-android",
"aarch64-unknown-linux-gnu",
"aarch64-unknown-linux-musl",
"aarch64-pc-windows-msvc",
"armv7-unknown-linux-gnueabihf",
"x86_64-unknown-linux-musl",
"x86_64-unknown-freebsd",
"i686-pc-windows-msvc",
"armv7-linux-androideabi",
"universal-apple-darwin"
]
}
"binaryName": "backend-rs"
},
"license": "MIT",
"devDependencies": {
"@napi-rs/cli": "2.18.0",
"@napi-rs/cli": "3.0.0-alpha.36",
"ava": "6.1.1"
},
"ava": {
@ -31,8 +16,8 @@
},
"scripts": {
"artifacts": "napi artifacts",
"build": "napi build --platform --release ./built/",
"build:debug": "napi build --platform ./built/",
"build": "napi build --platform --release --output-dir ./built/",
"build:debug": "napi build --platform --output-dir ./built/",
"prepublishOnly": "napi prepublish -t npm",
"universal": "napi universal",
"version": "napi version",

View file

@ -1,3 +1,5 @@
pub use sdk;
pub mod config;
pub mod database;
pub mod macros;

View file

@ -1,4 +1,3 @@
pub mod acct;
pub mod check_word_mute;
pub mod convert_host;
pub mod convert_to_hidden_post;

1
packages/backend/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
built

View file

@ -3,7 +3,7 @@ import type Bull from "bull";
import { queueLogger } from "../../logger.js";
import { resolveUser } from "@/remote/resolve-user.js";
import { downloadTextFile } from "@/misc/download-text-file.js";
import { isSelfHost, stringToAcct, toPuny } from "backend-rs";
import { isSelfHost, toPuny, stringToAcct } from "backend-rs";
import { Users, DriveFiles } from "@/models/index.js";
import type { DbUserImportJobData } from "@/queue/types.js";
import block from "@/services/blocking/create.js";

View file

@ -3,7 +3,7 @@ import follow from "@/services/following/create.js";
import { resolveUser } from "@/remote/resolve-user.js";
import { downloadTextFile } from "@/misc/download-text-file.js";
import { isSelfHost, stringToAcct, toPuny } from "backend-rs";
import { isSelfHost, toPuny, stringToAcct } from "backend-rs";
import { Users, DriveFiles } from "@/models/index.js";
import type { DbUserImportJobData } from "@/queue/types.js";
import { queueLogger } from "../../logger.js";

View file

@ -3,7 +3,7 @@ import type Bull from "bull";
import { queueLogger } from "../../logger.js";
import { resolveUser } from "@/remote/resolve-user.js";
import { downloadTextFile } from "@/misc/download-text-file.js";
import { isSelfHost, stringToAcct, toPuny } from "backend-rs";
import { isSelfHost, toPuny, stringToAcct } from "backend-rs";
import { Users, DriveFiles, Mutings } from "@/models/index.js";
import type { DbUserImportJobData } from "@/queue/types.js";
import type { User } from "@/models/entities/user.js";

View file

@ -4,7 +4,7 @@ import { queueLogger } from "../../logger.js";
import { resolveUser } from "@/remote/resolve-user.js";
import { pushUserToUserList } from "@/services/user-list/push.js";
import { downloadTextFile } from "@/misc/download-text-file.js";
import { isSelfHost, stringToAcct, toPuny } from "backend-rs";
import { isSelfHost, toPuny, stringToAcct } from "backend-rs";
import {
DriveFiles,
Users,

View file

@ -16,11 +16,10 @@ import { IsNull } from "typeorm";
import config from "@/config/index.js";
import Logger from "@/services/logger.js";
import { Users } from "@/models/index.js";
import { fetchMeta } from "@/misc/backend-rs.js";
import { genIdenticon } from "@/misc/gen-identicon.js";
import { createTemp } from "@/misc/create-temp.js";
import { stringToAcct } from "backend-rs";
import { envConfig } from "@/misc/backend-rs.js";
import { envConfig, fetchMeta } from "@/misc/backend-rs.js";
import megalodon, { MegalodonInterface } from "megalodon";
import activityPub from "./activitypub.js";
import nodeinfo from "./nodeinfo.js";

View file

@ -17,7 +17,7 @@ import { KoaAdapter } from "@bull-board/koa";
import { In, IsNull } from "typeorm";
import { fetchMeta } from "@/misc/backend-rs.js";
import { metaToPugArgs } from "backend-rs";
import { metaToPugArgs, stringToAcct } from "backend-rs";
import config from "@/config/index.js";
import {
Users,
@ -29,7 +29,6 @@ import {
Emojis,
GalleryPosts,
} from "@/models/index.js";
import { stringToAcct } from "backend-rs";
import { getNoteSummary } from "@/misc/get-note-summary.js";
import { queues } from "@/queue/queues.js";
import { genOpenapiSpec } from "../api/openapi/gen-spec.js";

View file

@ -1,8 +1,7 @@
import Router from "@koa/router";
import config from "@/config/index.js";
import { stringToAcct } from "backend-rs";
import type { Acct } from "backend-rs";
import { stringToAcct, type Acct } from "backend-rs";
import { links } from "./nodeinfo.js";
import { escapeAttribute, escapeValue } from "@/prelude/xml.js";
import { Users } from "@/models/index.js";

1
packages/client/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
built

View file

@ -71,6 +71,7 @@
"rollup": "4.9.6",
"s-age": "1.1.2",
"sass": "1.70.0",
"sdk": "workspace:*",
"seedrandom": "3.0.5",
"stringz": "2.1.0",
"swiper": "11.0.5",
@ -85,6 +86,8 @@
"uuid": "9.0.1",
"vite": "5.0.12",
"vite-plugin-compression": "0.5.1",
"vite-plugin-top-level-await": "^1.4.1",
"vite-plugin-wasm": "^3.3.0",
"vue": "3.4.15",
"vue-draggable-plus": "^0.3.5",
"vue-plyr": "^7.0.0",

View file

@ -1,4 +1,4 @@
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import { defineAsyncComponent } from "vue";
import { i18n } from "./i18n";
import { apiUrl } from "@/config";
@ -10,7 +10,7 @@ import { reloadChannel, unisonReload } from "@/scripts/unison-reload";
// TODO: 他のタブと永続化されたstateを同期
export type Account = firefish.entities.MeDetailed;
export type Account = entities.MeDetailed;
export async function signout() {
waiting();
@ -149,8 +149,8 @@ export async function openAccountMenu(
opts: {
includeCurrentAccount?: boolean;
withExtraOperation: boolean;
active?: firefish.entities.UserDetailed["id"];
onChoose?: (account: firefish.entities.UserDetailed) => void;
active?: entities.UserDetailed["id"];
onChoose?: (account: entities.UserDetailed) => void;
},
ev: MouseEvent,
isMobile?: boolean,
@ -183,7 +183,7 @@ export async function openAccountMenu(
);
}
async function switchAccount(account: firefish.entities.UserDetailed) {
async function switchAccount(account: entities.UserDetailed) {
const storedAccounts = await getAccounts();
const token = storedAccounts.find((x) => x.id === account.id).token;
switchAccountWithToken(token);
@ -200,7 +200,7 @@ export async function openAccountMenu(
userIds: storedAccounts.map((x) => x.id),
});
function createItem(account: firefish.entities.UserDetailed) {
function createItem(account: entities.UserDetailed) {
return {
type: "user",
user: account,

View file

@ -41,7 +41,7 @@
<script setup lang="ts">
import { ref } from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import XWindow from "@/components/MkWindow.vue";
import MkTextarea from "@/components/form/textarea.vue";
import MkButton from "@/components/MkButton.vue";
@ -50,7 +50,7 @@ import { i18n } from "@/i18n";
import icon from "@/scripts/icon";
const props = defineProps<{
user: firefish.entities.User;
user: entities.User;
initialComment?: string;
}>();

View file

@ -17,7 +17,7 @@
<span class="name">
<MkUserName :key="user.id" :user="user" />
</span>
<span class="username">@{{ acct(user) }}</span>
<span class="username">@{{ acctToString(user) }}</span>
</li>
<li
tabindex="-1"
@ -95,7 +95,7 @@ import {
import contains from "@/scripts/contains";
import { char2filePath } from "@/scripts/twemoji-base";
import { getStaticImageUrl } from "@/scripts/get-static-image-url";
import { acct } from "@/filters/user";
import { acctToString } from "sdk";
import * as os from "@/os";
import { MFM_TAGS } from "@/scripts/mfm-tags";
import { defaultStore } from "@/store";

View file

@ -10,7 +10,7 @@
:to="
message.groupId
? `/my/messaging/group/${message.groupId}`
: `/my/messaging/${getAcct(
: `/my/messaging/${acctToString(
isMe(message) ? message.recipient : message.user,
)}`
"
@ -41,7 +41,9 @@
/></span>
<span class="username"
>@{{
acct(isMe(message) ? message.recipient : message.user)
acctToString(
isMe(message) ? message.recipient : message.user,
)
}}</span
>
<MkTime :time="message.createdAt" class="time" />
@ -63,14 +65,11 @@
</template>
<script lang="ts" setup>
import * as firefishJs from "firefish-js";
import { i18n } from "@/i18n";
import { acct } from "@/filters/user";
import { acctToString } from "sdk";
import { $i } from "@/reactiveAccount";
const getAcct = firefishJs.acct.toString;
const props = defineProps<{
defineProps<{
message: Record<string, any>;
}>();

View file

@ -37,7 +37,7 @@
<script lang="ts" setup>
import { onMounted, ref } from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import Cropper from "cropperjs";
import tinycolor from "tinycolor2";
import XModalWindow from "@/components/MkModalWindow.vue";
@ -49,13 +49,13 @@ import { query } from "@/scripts/url";
import { i18n } from "@/i18n";
const emit = defineEmits<{
(ev: "ok", cropped: firefish.entities.DriveFile): void;
(ev: "ok", cropped: entities.DriveFile): void;
(ev: "cancel"): void;
(ev: "closed"): void;
}>();
const props = defineProps<{
file: firefish.entities.DriveFile;
file: entities.DriveFile;
aspectRatio: number;
}>();
@ -68,7 +68,7 @@ let cropper: Cropper | null = null,
loading = ref(true);
const ok = async () => {
const promise = new Promise<firefish.entities.DriveFile>(async (res) => {
const promise = new Promise<entities.DriveFile>(async (res) => {
const croppedCanvas = await cropper?.getCropperSelection()?.$toCanvas();
croppedCanvas.toBlob((blob) => {
const formData = new FormData();

View file

@ -15,13 +15,13 @@
<script lang="ts" setup>
import { computed, ref } from "vue";
import { length } from "stringz";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import { concat } from "@/scripts/array";
import { i18n } from "@/i18n";
const props = defineProps<{
modelValue: boolean;
note: firefish.entities.Note;
note: entities.Note;
}>();
const emit = defineEmits<{

View file

@ -205,7 +205,7 @@
<script lang="ts" setup>
import { computed, onBeforeUnmount, onMounted, ref, shallowRef } from "vue";
// import { acct } from "firefish-js";
// import { acctToString } from "sdk";
import MkModal from "@/components/MkModal.vue";
import MkButton from "@/components/MkButton.vue";
import MkInput from "@/components/form/input.vue";
@ -388,7 +388,7 @@ function onInputKeydown(evt: KeyboardEvent) {
// action: () => {
// os.selectUser().then((user) => {
// inputValue.value = appendFilter(
// "from:@" + acct.toString(user),
// "from:@" + acctToString(user),
// );
// });
// },

View file

@ -39,7 +39,7 @@
<script lang="ts" setup>
import { computed, defineAsyncComponent, ref } from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import copyToClipboard from "@/scripts/copy-to-clipboard";
import MkDriveFileThumbnail from "@/components/MkDriveFileThumbnail.vue";
import bytes from "@/filters/bytes";
@ -50,7 +50,7 @@ import icon from "@/scripts/icon";
const props = withDefaults(
defineProps<{
file: firefish.entities.DriveFile;
file: entities.DriveFile;
isSelected?: boolean;
selectMode?: boolean;
}>(),
@ -61,7 +61,7 @@ const props = withDefaults(
);
const emit = defineEmits<{
(ev: "chosen", r: firefish.entities.DriveFile): void;
(ev: "chosen", r: entities.DriveFile): void;
(ev: "dragstart"): void;
(ev: "dragend"): void;
}>();

View file

@ -38,7 +38,7 @@
<script lang="ts" setup>
import { computed, defineAsyncComponent, ref } from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import * as os from "@/os";
import { i18n } from "@/i18n";
import { defaultStore } from "@/store";
@ -46,7 +46,7 @@ import icon from "@/scripts/icon";
const props = withDefaults(
defineProps<{
folder: firefish.entities.DriveFolder;
folder: entities.DriveFolder;
isSelected?: boolean;
selectMode?: boolean;
}>(),
@ -57,11 +57,11 @@ const props = withDefaults(
);
const emit = defineEmits<{
(ev: "chosen", v: firefish.entities.DriveFolder): void;
(ev: "move", v: firefish.entities.DriveFolder): void;
(ev: "upload", file: File, folder: firefish.entities.DriveFolder);
(ev: "removeFile", v: firefish.entities.DriveFile["id"]): void;
(ev: "removeFolder", v: firefish.entities.DriveFolder["id"]): void;
(ev: "chosen", v: entities.DriveFolder): void;
(ev: "move", v: entities.DriveFolder): void;
(ev: "upload", file: File, folder: entities.DriveFolder);
(ev: "removeFile", v: entities.DriveFile["id"]): void;
(ev: "removeFolder", v: entities.DriveFolder["id"]): void;
(ev: "dragstart"): void;
(ev: "dragend"): void;
}>();

View file

@ -15,28 +15,23 @@
<script lang="ts" setup>
import { ref } from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import * as os from "@/os";
import { i18n } from "@/i18n";
import icon from "@/scripts/icon";
const props = defineProps<{
folder?: firefish.entities.DriveFolder;
parentFolder: firefish.entities.DriveFolder | null;
folder?: entities.DriveFolder;
parentFolder: entities.DriveFolder | null;
}>();
const emit = defineEmits<{
(ev: "move", v?: firefish.entities.DriveFolder): void;
(
ev: "upload",
file: File,
folder?: firefish.entities.DriveFolder | null,
): void;
(ev: "removeFile", v: firefish.entities.DriveFile["id"]): void;
(ev: "removeFolder", v: firefish.entities.DriveFolder["id"]): void;
(ev: "move", v?: entities.DriveFolder): void;
(ev: "upload", file: File, folder?: entities.DriveFolder | null): void;
(ev: "removeFile", v: entities.DriveFile["id"]): void;
(ev: "removeFolder", v: entities.DriveFolder["id"]): void;
}>();
const hover = ref(false);
const draghover = ref(false);
function onClick() {

View file

@ -145,7 +145,7 @@ import {
ref,
watch,
} from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import MkButton from "./MkButton.vue";
import XNavFolder from "@/components/MkDrive.navFolder.vue";
import XFolder from "@/components/MkDrive.folder.vue";
@ -159,7 +159,7 @@ import icon from "@/scripts/icon";
const props = withDefaults(
defineProps<{
initialFolder?: firefish.entities.DriveFolder;
initialFolder?: entities.DriveFolder;
type?: string;
multiple?: boolean;
select?: "file" | "folder" | null;
@ -173,17 +173,14 @@ const props = withDefaults(
);
const emit = defineEmits<{
(
ev: "selected",
v: firefish.entities.DriveFile | firefish.entities.DriveFolder,
): void;
(ev: "selected", v: entities.DriveFile | entities.DriveFolder): void;
(
ev: "change-selection",
v: firefish.entities.DriveFile[] | firefish.entities.DriveFolder[],
v: entities.DriveFile[] | entities.DriveFolder[],
): void;
(ev: "move-root"): void;
(ev: "cd", v: firefish.entities.DriveFolder | null): void;
(ev: "open-folder", v: firefish.entities.DriveFolder): void;
(ev: "cd", v: entities.DriveFolder | null): void;
(ev: "open-folder", v: entities.DriveFolder): void;
}>();
const stream = useStream();
@ -191,14 +188,14 @@ const stream = useStream();
const loadMoreFiles = ref<InstanceType<typeof MkButton>>();
const fileInput = ref<HTMLInputElement>();
const folder = ref<firefish.entities.DriveFolder | null>(null);
const files = ref<firefish.entities.DriveFile[]>([]);
const folders = ref<firefish.entities.DriveFolder[]>([]);
const folder = ref<entities.DriveFolder | null>(null);
const files = ref<entities.DriveFile[]>([]);
const folders = ref<entities.DriveFolder[]>([]);
const moreFiles = ref(false);
const moreFolders = ref(false);
const hierarchyFolders = ref<firefish.entities.DriveFolder[]>([]);
const selectedFiles = ref<firefish.entities.DriveFile[]>([]);
const selectedFolders = ref<firefish.entities.DriveFolder[]>([]);
const hierarchyFolders = ref<entities.DriveFolder[]>([]);
const selectedFiles = ref<entities.DriveFile[]>([]);
const selectedFolders = ref<entities.DriveFolder[]>([]);
const uploadings = uploads;
const connection = stream.useChannel("drive");
const keepOriginal = ref<boolean>(defaultStore.state.keepOriginalUploading); // $ref使
@ -222,11 +219,11 @@ const ilFilesObserver = new IntersectionObserver(
watch(folder, () => emit("cd", folder.value));
function onStreamDriveFileCreated(file: firefish.entities.DriveFile) {
function onStreamDriveFileCreated(file: entities.DriveFile) {
addFile(file, true);
}
function onStreamDriveFileUpdated(file: firefish.entities.DriveFile) {
function onStreamDriveFileUpdated(file: entities.DriveFile) {
const current = folder.value ? folder.value.id : null;
if (current !== file.folderId) {
removeFile(file);
@ -239,15 +236,11 @@ function onStreamDriveFileDeleted(fileId: string) {
removeFile(fileId);
}
function onStreamDriveFolderCreated(
createdFolder: firefish.entities.DriveFolder,
) {
function onStreamDriveFolderCreated(createdFolder: entities.DriveFolder) {
addFolder(createdFolder, true);
}
function onStreamDriveFolderUpdated(
updatedFolder: firefish.entities.DriveFolder,
) {
function onStreamDriveFolderUpdated(updatedFolder: entities.DriveFolder) {
const current = folder.value ? folder.value.id : null;
if (current !== updatedFolder.parentId) {
removeFolder(updatedFolder);
@ -391,7 +384,7 @@ function createFolder() {
});
}
function renameFolder(folderToRename: firefish.entities.DriveFolder) {
function renameFolder(folderToRename: entities.DriveFolder) {
os.inputText({
title: i18n.ts.renameFolder,
placeholder: i18n.ts.inputNewFolderName,
@ -408,7 +401,7 @@ function renameFolder(folderToRename: firefish.entities.DriveFolder) {
});
}
function deleteFolder(folderToDelete: firefish.entities.DriveFolder) {
function deleteFolder(folderToDelete: entities.DriveFolder) {
os.api("drive/folders/delete", {
folderId: folderToDelete.id,
})
@ -441,10 +434,7 @@ function onChangeFileInput() {
}
}
function upload(
file: File,
folderToUpload?: firefish.entities.DriveFolder | null,
) {
function upload(file: File, folderToUpload?: entities.DriveFolder | null) {
uploadFile(
file,
folderToUpload && typeof folderToUpload === "object"
@ -457,7 +447,7 @@ function upload(
});
}
function chooseFile(file: firefish.entities.DriveFile) {
function chooseFile(file: entities.DriveFile) {
const isAlreadySelected = selectedFiles.value.some((f) => f.id === file.id);
if (props.multiple) {
if (isAlreadySelected) {
@ -478,7 +468,7 @@ function chooseFile(file: firefish.entities.DriveFile) {
}
}
function chooseFolder(folderToChoose: firefish.entities.DriveFolder) {
function chooseFolder(folderToChoose: entities.DriveFolder) {
const isAlreadySelected = selectedFolders.value.some(
(f) => f.id === folderToChoose.id,
);
@ -501,7 +491,7 @@ function chooseFolder(folderToChoose: firefish.entities.DriveFolder) {
}
}
function move(target?: firefish.entities.DriveFolder) {
function move(target?: entities.DriveFolder) {
if (!target) {
goRoot();
return;
@ -529,10 +519,7 @@ function move(target?: firefish.entities.DriveFolder) {
});
}
function addFolder(
folderToAdd: firefish.entities.DriveFolder,
unshift = false,
) {
function addFolder(folderToAdd: entities.DriveFolder, unshift = false) {
const current = folder.value ? folder.value.id : null;
if (current !== folderToAdd.parentId) return;
@ -549,7 +536,7 @@ function addFolder(
}
}
function addFile(fileToAdd: firefish.entities.DriveFile, unshift = false) {
function addFile(fileToAdd: entities.DriveFile, unshift = false) {
const current = folder.value ? folder.value.id : null;
if (current !== fileToAdd.folderId) return;
@ -566,30 +553,30 @@ function addFile(fileToAdd: firefish.entities.DriveFile, unshift = false) {
}
}
function removeFolder(folderToRemove: firefish.entities.DriveFolder | string) {
function removeFolder(folderToRemove: entities.DriveFolder | string) {
const folderIdToRemove =
typeof folderToRemove === "object" ? folderToRemove.id : folderToRemove;
folders.value = folders.value.filter((f) => f.id !== folderIdToRemove);
}
function removeFile(file: firefish.entities.DriveFile | string) {
function removeFile(file: entities.DriveFile | string) {
const fileId = typeof file === "object" ? file.id : file;
files.value = files.value.filter((f) => f.id !== fileId);
}
function appendFile(file: firefish.entities.DriveFile) {
function appendFile(file: entities.DriveFile) {
addFile(file);
}
function appendFolder(folderToAppend: firefish.entities.DriveFolder) {
function appendFolder(folderToAppend: entities.DriveFolder) {
addFolder(folderToAppend);
}
/*
function prependFile(file: firefish.entities.DriveFile) {
function prependFile(file: entities.DriveFile) {
addFile(file, true);
}
function prependFolder(folderToPrepend: firefish.entities.DriveFolder) {
function prependFolder(folderToPrepend: entities.DriveFolder) {
addFolder(folderToPrepend, true);
}
*/
@ -719,9 +706,7 @@ function getMenu() {
text: i18n.ts.deleteFolder,
icon: `${icon("ph-trash")}`,
action: () => {
deleteFolder(
folder.value as firefish.entities.DriveFolder,
);
deleteFolder(folder.value as entities.DriveFolder);
},
}
: undefined,

View file

@ -29,12 +29,12 @@
<script lang="ts" setup>
import { computed } from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import ImgWithBlurhash from "@/components/MkImgWithBlurhash.vue";
import icon from "@/scripts/icon";
const props = defineProps<{
file: firefish.entities.DriveFile;
file: entities.DriveFile;
fit: string;
}>();

View file

@ -37,7 +37,7 @@
<script lang="ts" setup>
import { ref } from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import XDrive from "@/components/MkDrive.vue";
import XModalWindow from "@/components/MkModalWindow.vue";
import number from "@/filters/number";
@ -54,13 +54,13 @@ withDefaults(
);
const emit = defineEmits<{
(ev: "done", r?: firefish.entities.DriveFile[]): void;
(ev: "done", r?: entities.DriveFile[]): void;
(ev: "closed"): void;
}>();
const dialog = ref<InstanceType<typeof XModalWindow>>();
const selected = ref<firefish.entities.DriveFile[]>([]);
const selected = ref<entities.DriveFile[]>([]);
function ok() {
emit("done", selected.value);
@ -72,7 +72,7 @@ function cancel() {
dialog.value?.close();
}
function onChangeSelection(files: firefish.entities.DriveFile[]) {
function onChangeSelection(files: entities.DriveFile[]) {
selected.value = files;
}
</script>

View file

@ -14,14 +14,13 @@
</template>
<script lang="ts" setup>
import {} from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import XDrive from "@/components/MkDrive.vue";
import XWindow from "@/components/MkWindow.vue";
import { i18n } from "@/i18n";
defineProps<{
initialFolder?: firefish.entities.DriveFolder;
initialFolder?: entities.DriveFolder;
}>();
const emit = defineEmits<{

View file

@ -165,7 +165,7 @@
<script lang="ts" setup>
import { computed, onMounted, ref, watch } from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import { FocusTrap } from "focus-trap-vue";
import XSection from "@/components/MkEmojiPicker.section.vue";
import type { UnicodeEmojiDef } from "@/scripts/emojilist";
@ -242,7 +242,7 @@ const height = computed(() =>
const customEmojiCategories = emojiCategories;
const customEmojis = instance.emojis;
const q = ref<string | null>(null);
const searchResultCustom = ref<firefish.entities.CustomEmoji[]>([]);
const searchResultCustom = ref<entities.CustomEmoji[]>([]);
const searchResultUnicode = ref<UnicodeEmojiDef[]>([]);
const tab = ref<"index" | "custom" | "unicode" | "tags">("index");
@ -260,7 +260,7 @@ watch(q, () => {
const searchCustom = () => {
const max = 100;
const emojis = customEmojis;
const matches = new Set<firefish.entities.CustomEmoji>();
const matches = new Set<entities.CustomEmoji>();
const exactMatch = emojis.find((emoji) => emoji.name === newQ);
if (exactMatch) matches.add(exactMatch);
@ -421,7 +421,7 @@ function reset() {
}
function getKey(
emoji: string | firefish.entities.CustomEmoji | UnicodeEmojiDef,
emoji: string | entities.CustomEmoji | UnicodeEmojiDef,
): string {
return typeof emoji === "string" ? emoji : emoji.emoji ?? `:${emoji.name}:`;
}

View file

@ -8,10 +8,10 @@
<script lang="ts" setup>
import { ref } from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import * as os from "@/os";
const meta = ref<firefish.entities.DetailedInstanceMetadata>();
const meta = ref<entities.DetailedInstanceMetadata>();
os.api("meta", { detail: true }).then((gotMeta) => {
meta.value = gotMeta;

View file

@ -13,7 +13,7 @@
`${file.type}\n${bytes(file.size)}\n${new Date(
file.createdAt,
).toLocaleString()}\nby ${
file.user ? '@' + acct.toString(file.user) : 'system'
file.user ? '@' + acctToString(file.user) : 'system'
}`
"
:to="`/admin/file/${file.id}`"
@ -54,13 +54,13 @@
</template>
<script lang="ts" setup>
import { acct } from "firefish-js";
import { acctToString } from "sdk";
import MkPagination from "@/components/MkPagination.vue";
import MkDriveFileThumbnail from "@/components/MkDriveFileThumbnail.vue";
import bytes from "@/filters/bytes";
import { i18n } from "@/i18n";
const props = defineProps<{
defineProps<{
pagination: any;
viewMode: "grid" | "list";
}>();

View file

@ -62,7 +62,7 @@
<script lang="ts" setup>
import { computed, onBeforeUnmount, onMounted, ref } from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import * as os from "@/os";
import { useStream } from "@/stream";
import { i18n } from "@/i18n";
@ -78,7 +78,7 @@ const stream = useStream();
const emit = defineEmits(["refresh"]);
const props = withDefaults(
defineProps<{
user: firefish.entities.UserDetailed;
user: entities.UserDetailed;
full?: boolean;
large?: boolean;
hideMenu?: boolean;
@ -109,7 +109,7 @@ if (props.user.isFollowing == null) {
}).then(onFollowChange);
}
function onFollowChange(user: firefish.entities.UserDetailed) {
function onFollowChange(user: entities.UserDetailed) {
if (user.id === props.user.id) {
isFollowing.value = user.isFollowing;
hasPendingFollowRequestFromYou.value =

View file

@ -28,14 +28,14 @@
<script lang="ts" setup>
import { ref } from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import bytes from "@/filters/bytes";
import number from "@/filters/number";
import MkModal from "@/components/MkModal.vue";
const props = withDefaults(
withDefaults(
defineProps<{
image: firefish.entities.DriveFile;
image: entities.DriveFile;
}>(),
{},
);

View file

@ -23,14 +23,11 @@
</template>
<script lang="ts" setup>
import { ref } from "vue";
import type * as firefish from "firefish-js";
import * as os from "@/os";
import type { entities } from "firefish-js";
import { getProxiedImageUrlNullable } from "@/scripts/media-proxy";
const props = defineProps<{
instance: firefish.entities.Instance;
defineProps<{
instance: entities.Instance;
}>();
function getInstanceIcon(instance): string {

View file

@ -58,7 +58,7 @@
<script lang="ts" setup>
import { ref } from "vue";
import { entities } from "firefish-js";
import type { entities } from "firefish-js";
import MkInput from "@/components/form/input.vue";
import XModalWindow from "@/components/MkModalWindow.vue";
import * as os from "@/os";

View file

@ -92,7 +92,7 @@
import { computed, ref, watch } from "vue";
import VuePlyr from "vue-plyr";
import "vue-plyr/dist/vue-plyr.css";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import { getStaticImageUrl } from "@/scripts/get-static-image-url";
import ImgWithBlurhash from "@/components/MkImgWithBlurhash.vue";
import { defaultStore } from "@/store";
@ -101,7 +101,7 @@ import * as os from "@/os";
import icon from "@/scripts/icon";
const props = defineProps<{
media: firefish.entities.DriveFile;
media: entities.DriveFile;
raw?: boolean;
}>();

View file

@ -58,15 +58,15 @@
<script lang="ts" setup>
import { onMounted, ref } from "vue";
import VuePlyr from "vue-plyr";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import { ColdDeviceStorage } from "@/store";
import "vue-plyr/dist/vue-plyr.css";
import { i18n } from "@/i18n";
import icon from "@/scripts/icon";
const props = withDefaults(
withDefaults(
defineProps<{
media: firefish.entities.DriveFile;
media: entities.DriveFile;
}>(),
{},
);

View file

@ -41,7 +41,7 @@
<script lang="ts" setup>
import { onMounted, ref } from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import PhotoSwipeLightbox from "photoswipe/lightbox";
import PhotoSwipe from "photoswipe";
import "photoswipe/style.css";
@ -56,13 +56,12 @@ import {
} from "@/const";
const props = defineProps<{
mediaList: firefish.entities.DriveFile[];
mediaList: entities.DriveFile[];
raw?: boolean;
inDm?: boolean;
}>();
const gallery = ref(null);
const pswpZIndex = os.claimZIndex("middle");
onMounted(() => {
const lightbox = new PhotoSwipeLightbox({
@ -184,7 +183,7 @@ onMounted(() => {
}
});
const previewable = (file: firefish.entities.DriveFile): boolean => {
const previewable = (file: entities.DriveFile): boolean => {
if (file.type === "image/svg+xml") return true; // svgwebpublic/thumbnailpngtrue
// FILE_TYPE_BROWSERSAFE
if (isModule(file)) return true;
@ -194,7 +193,7 @@ const previewable = (file: firefish.entities.DriveFile): boolean => {
);
};
const isModule = (file: firefish.entities.DriveFile): boolean => {
const isModule = (file: entities.DriveFile): boolean => {
return (
FILE_TYPE_TRACKER_MODULES.includes(file.type) ||
FILE_EXT_TRACKER_MODULES.some((ext) => {

View file

@ -107,7 +107,7 @@
<script lang="ts" setup>
import { nextTick, onDeactivated, onMounted, ref, shallowRef } from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import FormRange from "./form/range.vue";
import { i18n } from "@/i18n";
import * as os from "@/os";
@ -116,7 +116,7 @@ import { ChiptuneJsConfig, ChiptuneJsPlayer } from "@/scripts/chiptune2";
import icon from "@/scripts/icon";
const props = defineProps<{
module: firefish.entities.DriveFile;
module: entities.DriveFile;
}>();
interface ModRow {

View file

@ -273,7 +273,7 @@
<script lang="ts" setup>
import { computed, inject, onMounted, ref } from "vue";
import type { Ref } from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import MkSubNoteContent from "./MkSubNoteContent.vue";
import MkNoteSub from "@/components/MkNoteSub.vue";
import XNoteHeader from "@/components/MkNoteHeader.vue";
@ -306,7 +306,7 @@ import icon from "@/scripts/icon";
const router = useRouter();
const props = defineProps<{
note: firefish.entities.Note;
note: entities.Note;
pinned?: boolean;
detailedView?: boolean;
collapsedReply?: boolean;
@ -351,7 +351,7 @@ const renoteButton = ref<InstanceType<typeof XRenoteButton>>();
const renoteTime = ref<HTMLElement>();
const reactButton = ref<HTMLElement>();
const appearNote = computed(() =>
isRenote ? (note.value.renote as firefish.entities.Note) : note.value,
isRenote ? (note.value.renote as entities.Note) : note.value,
);
const isMyRenote = isSignedIn && $i.id === note.value.userId;
const showContent = ref(false);
@ -466,7 +466,7 @@ function undoReact(note): void {
});
}
const currentClipPage = inject<Ref<firefish.entities.Clip> | null>(
const currentClipPage = inject<Ref<entities.Clip> | null>(
"currentClipPage",
null,
);

View file

@ -167,8 +167,7 @@
<script lang="ts" setup>
import { onMounted, onUnmounted, onUpdated, ref } from "vue";
import type * as firefish from "firefish-js";
import { StreamTypes } from "firefish-js";
import type { entities, StreamTypes } from "firefish-js";
import MkTab from "@/components/MkTab.vue";
import MkNote from "@/components/MkNote.vue";
import MkNoteSub from "@/components/MkNoteSub.vue";
@ -190,7 +189,7 @@ import { useStream } from "@/stream";
// import icon from "@/scripts/icon";
const props = defineProps<{
note: firefish.entities.Note;
note: entities.Note;
pinned?: boolean;
}>();
@ -243,10 +242,10 @@ const muted = ref(
);
const translation = ref(null);
const translating = ref(false);
const conversation = ref<null | firefish.entities.Note[]>([]);
const replies = ref<firefish.entities.Note[]>([]);
const directReplies = ref<null | firefish.entities.Note[]>([]);
const directQuotes = ref<null | firefish.entities.Note[]>([]);
const conversation = ref<null | entities.Note[]>([]);
const replies = ref<entities.Note[]>([]);
const directReplies = ref<null | entities.Note[]>([]);
const directQuotes = ref<null | entities.Note[]>([]);
const clips = ref();
const renotes = ref();
let isScrolling;

View file

@ -50,7 +50,7 @@
<script lang="ts" setup>
import { ref } from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import { defaultStore } from "@/store";
import MkVisibility from "@/components/MkVisibility.vue";
import MkInstanceTicker from "@/components/MkInstanceTicker.vue";
@ -61,7 +61,7 @@ import { pageWindow } from "@/os";
import icon from "@/scripts/icon";
const props = defineProps<{
note: firefish.entities.Note;
note: entities.Note;
pinned?: boolean;
canOpenServerInfo?: boolean;
}>();

View file

@ -11,12 +11,12 @@
</template>
<script lang="ts" setup>
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import XNoteHeader from "@/components/MkNoteHeader.vue";
import MkSubNoteContent from "@/components/MkSubNoteContent.vue";
defineProps<{
note: firefish.entities.Note;
note: entities.Note;
pinned?: boolean;
}>();
</script>

View file

@ -191,7 +191,7 @@
<script lang="ts" setup>
import { computed, inject, ref } from "vue";
import type { Ref } from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import XNoteHeader from "@/components/MkNoteHeader.vue";
import MkSubNoteContent from "@/components/MkSubNoteContent.vue";
import XReactionsViewer from "@/components/MkReactionsViewer.vue";
@ -221,8 +221,8 @@ const router = useRouter();
const props = withDefaults(
defineProps<{
note: firefish.entities.Note;
conversation?: firefish.entities.Note[];
note: entities.Note;
conversation?: entities.Note[];
parentId?;
detailedView?;
@ -262,7 +262,7 @@ const starButton = ref<InstanceType<typeof XStarButton>>();
const renoteButton = ref<InstanceType<typeof XRenoteButton>>();
const reactButton = ref<HTMLElement>();
const appearNote = computed(() =>
isRenote ? (note.value.renote as firefish.entities.Note) : note.value,
isRenote ? (note.value.renote as entities.Note) : note.value,
);
const isDeleted = ref(false);
const muted = ref(
@ -275,7 +275,7 @@ const muted = ref(
);
const translation = ref(null);
const translating = ref(false);
const replies: firefish.entities.Note[] =
const replies: entities.Note[] =
props.conversation
?.filter(
(item) =>
@ -369,7 +369,7 @@ function undoReact(note): void {
});
}
const currentClipPage = inject<Ref<firefish.entities.Clip> | null>(
const currentClipPage = inject<Ref<entities.Clip> | null>(
"currentClipPage",
null,
);

View file

@ -263,7 +263,7 @@
<script lang="ts" setup>
import { onMounted, onUnmounted, ref, watch } from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import XReactionIcon from "@/components/MkReactionIcon.vue";
import MkFollowButton from "@/components/MkFollowButton.vue";
import XReactionTooltip from "@/components/MkReactionTooltip.vue";
@ -280,7 +280,7 @@ import icon from "@/scripts/icon";
const props = withDefaults(
defineProps<{
notification: firefish.entities.Notification;
notification: entities.Notification;
withTime?: boolean;
full?: boolean;
}>(),

View file

@ -69,7 +69,7 @@
<script lang="ts" setup>
import type { ComputedRef } from "vue";
import { computed, isRef, onActivated, onDeactivated, ref, watch } from "vue";
import type * as firefish from "firefish-js";
import type { Endpoints } from "firefish-js";
import * as os from "@/os";
import {
getScrollContainer,
@ -81,14 +81,10 @@ import MkButton from "@/components/MkButton.vue";
import { i18n } from "@/i18n";
import { defaultStore } from "@/store";
export interface Paging<
E extends keyof firefish.Endpoints = keyof firefish.Endpoints,
> {
export interface Paging<E extends keyof Endpoints = keyof Endpoints> {
endpoint: E;
limit: number;
params?:
| firefish.Endpoints[E]["req"]
| ComputedRef<firefish.Endpoints[E]["req"]>;
params?: Endpoints[E]["req"] | ComputedRef<Endpoints[E]["req"]>;
/**
* 検索APIのようなページング不可なエンドポイントを利用する場合

View file

@ -53,7 +53,7 @@
<script lang="ts" setup>
import { computed, ref } from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import { sum } from "@/scripts/array";
import { pleaseLogin } from "@/scripts/please-login";
import * as os from "@/os";
@ -62,7 +62,7 @@ import { useInterval } from "@/scripts/use-interval";
import icon from "@/scripts/icon";
const props = defineProps<{
note: firefish.entities.Note;
note: entities.Note;
readOnly?: boolean;
}>();

View file

@ -279,12 +279,12 @@ import {
watch,
} from "vue";
import * as mfm from "mfm-js";
import type * as firefish from "firefish-js";
import autosize from "autosize";
import insertTextAtCursor from "insert-text-at-cursor";
import { length } from "stringz";
import { toASCII } from "punycode/";
import { acct } from "firefish-js";
import type { entities, noteVisibilities, languages } from "firefish-js";
import { acctToString } from "sdk";
import { throttle } from "throttle-debounce";
import XNoteSimple from "@/components/MkNoteSimple.vue";
import XNotePreview from "@/components/MkNotePreview.vue";
@ -317,22 +317,22 @@ const modal = inject("modal");
const props = withDefaults(
defineProps<{
reply?: firefish.entities.Note;
renote?: firefish.entities.Note;
reply?: entities.Note;
renote?: entities.Note;
channel?: any; // TODO
mention?: firefish.entities.User;
specified?: firefish.entities.User;
mention?: entities.User;
specified?: entities.User;
initialText?: string;
initialVisibility?: typeof firefish.noteVisibilities;
initialLanguage?: typeof firefish.languages;
initialFiles?: firefish.entities.DriveFile[];
initialVisibility?: typeof noteVisibilities;
initialLanguage?: typeof languages;
initialFiles?: entities.DriveFile[];
initialLocalOnly?: boolean;
initialVisibleUsers?: firefish.entities.User[];
initialNote?: firefish.entities.Note;
initialVisibleUsers?: entities.User[];
initialNote?: entities.Note;
instant?: boolean;
fixed?: boolean;
autofocus?: boolean;
editId?: firefish.entities.Note["id"];
editId?: entities.Note["id"];
}>(),
{
initialVisibleUsers: () => [],
@ -378,7 +378,7 @@ const visibility = ref(
((defaultStore.state.rememberNoteVisibility
? defaultStore.state.visibility
: defaultStore.state
.defaultNoteVisibility) as (typeof firefish.noteVisibilities)[number]),
.defaultNoteVisibility) as (typeof noteVisibilities)[number]),
);
const visibleUsers = ref([]);
@ -1116,7 +1116,7 @@ function cancel() {
function insertMention() {
os.selectUser().then((user) => {
insertTextAtCursor(textareaEl.value, "@" + acct.toString(user) + " ");
insertTextAtCursor(textareaEl.value, "@" + acctToString(user) + " ");
});
}
@ -1145,7 +1145,7 @@ function showActions(ev) {
);
}
const postAccount = ref<firefish.entities.UserDetailed | null>(null);
const postAccount = ref<entities.UserDetailed | null>(null);
function openAccountMenu(ev: MouseEvent) {
openAccountMenu_(

View file

@ -21,27 +21,27 @@
<script lang="ts" setup>
import { shallowRef } from "vue";
import type * as firefish from "firefish-js";
import type { entities, noteVisibilities, languages } from "firefish-js";
import MkModal from "@/components/MkModal.vue";
import MkPostForm from "@/components/MkPostForm.vue";
const props = defineProps<{
reply?: firefish.entities.Note;
renote?: firefish.entities.Note;
reply?: entities.Note;
renote?: entities.Note;
channel?: any; // TODO
mention?: firefish.entities.User;
specified?: firefish.entities.User;
mention?: entities.User;
specified?: entities.User;
initialText?: string;
initialVisibility?: typeof firefish.noteVisibilities;
initialLanguage?: typeof firefish.languages;
initialFiles?: firefish.entities.DriveFile[];
initialVisibility?: typeof noteVisibilities;
initialLanguage?: typeof languages;
initialFiles?: entities.DriveFile[];
initialLocalOnly?: boolean;
initialVisibleUsers?: firefish.entities.User[];
initialNote?: firefish.entities.Note;
initialVisibleUsers?: entities.User[];
initialNote?: entities.Note;
instant?: boolean;
fixed?: boolean;
autofocus?: boolean;
editId?: firefish.entities.Note["id"];
editId?: entities.Note["id"];
}>();
const emit = defineEmits<{

View file

@ -11,7 +11,7 @@
<script lang="ts" setup>
import { computed } from "vue";
import { entities } from "firefish-js";
import type { entities } from "firefish-js";
import { pleaseLogin } from "@/scripts/please-login";
import * as os from "@/os";
import { $i } from "@/reactiveAccount";

View file

@ -32,16 +32,16 @@
<script lang="ts" setup>
import { onMounted, ref, watch } from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import MkReactionIcon from "@/components/MkReactionIcon.vue";
import MkUserCardMini from "@/components/MkUserCardMini.vue";
import * as os from "@/os";
const props = defineProps<{
noteId: firefish.entities.Note["id"];
noteId: entities.Note["id"];
}>();
const note = ref<firefish.entities.Note>();
const note = ref<entities.Note>();
const tab = ref<string | null>(null);
const reactions = ref<string[]>();
const users = ref();

View file

@ -23,7 +23,7 @@
<script lang="ts" setup>
import { computed, ref } from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import XDetails from "@/components/MkReactionsViewer.details.vue";
import XReactionIcon from "@/components/MkReactionIcon.vue";
import * as os from "@/os";
@ -34,7 +34,7 @@ const props = defineProps<{
reaction: string;
count: number;
isInitial: boolean;
note: firefish.entities.Note;
note: entities.Note;
}>();
const emit = defineEmits<{

View file

@ -18,12 +18,12 @@
<script lang="ts" setup>
import { computed, ref } from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import { $i, isSignedIn } from "@/reactiveAccount";
import XReaction from "@/components/MkReactionsViewer.reaction.vue";
const props = defineProps<{
note: firefish.entities.Note;
note: entities.Note;
}>();
const reactionsEl = ref<HTMLElement>();

View file

@ -22,7 +22,7 @@
<script lang="ts" setup>
import { computed, ref } from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import Ripple from "@/components/MkRipple.vue";
import XDetails from "@/components/MkUsersTooltip.vue";
import { pleaseLogin } from "@/scripts/please-login";
@ -36,7 +36,7 @@ import { vibrate } from "@/scripts/vibrate";
import icon from "@/scripts/icon";
const props = defineProps<{
note: firefish.entities.Note;
note: entities.Note;
count: number;
detailedView?;
}>();

View file

@ -42,7 +42,7 @@
</template>
<script lang="ts" setup>
import { entities } from "firefish-js";
import type { entities } from "firefish-js";
import Ripple from "@/components/MkRipple.vue";
import { pleaseLogin } from "@/scripts/please-login";
import * as os from "@/os";

View file

@ -39,7 +39,7 @@
<script lang="ts" setup>
import { ref } from "vue";
import { entities } from "firefish-js";
import type { entities } from "firefish-js";
import Ripple from "@/components/MkRipple.vue";
import XDetails from "@/components/MkUsersTooltip.vue";
import { pleaseLogin } from "@/scripts/please-login";

View file

@ -179,7 +179,7 @@
<script lang="ts" setup>
import { ref } from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import * as mfm from "mfm-js";
import * as os from "@/os";
import XNoteSimple from "@/components/MkNoteSimple.vue";
@ -197,7 +197,7 @@ import { defaultStore } from "@/store";
import icon from "@/scripts/icon";
const props = defineProps<{
note: firefish.entities.Note;
note: entities.Note;
parentId?;
conversation?;
detailed?: boolean;

View file

@ -16,21 +16,22 @@
<div class="body">
<span class="name"><MkUserName class="name" :user="user" /></span>
<span class="sub"
><span class="acct _monospace">@{{ acct(user) }}</span></span
><span class="acct _monospace"
>@{{ acctToString(user) }}</span
></span
>
</div>
</MkA>
</template>
<script lang="ts" setup>
import { ref } from "vue";
import type * as firefish from "firefish-js";
import { acct, userPage } from "@/filters/user";
import type { entities } from "firefish-js";
import { userPage } from "@/filters/user";
import { acctToString } from "sdk";
const props = withDefaults(
defineProps<{
user: firefish.entities.User;
user: entities.User;
showAboutPage?: boolean;
}>(),
{

View file

@ -92,7 +92,7 @@
<script lang="ts" setup>
import { ref } from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import MkFollowButton from "@/components/MkFollowButton.vue";
import XShowMoreButton from "@/components/MkShowMoreButton.vue";
import MkNumber from "@/components/MkNumber.vue";
@ -102,7 +102,7 @@ import { defaultStore } from "@/store";
import { $i, isSignedIn } from "@/reactiveAccount";
const props = defineProps<{
user: firefish.entities.UserDetailed;
user: entities.UserDetailed;
detailed?: boolean;
}>();

View file

@ -10,11 +10,11 @@
<script lang="ts" setup>
import { computed } from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import { i18n } from "@/i18n";
const props = defineProps<{
user: firefish.entities.User;
user: entities.User;
}>();
const text = computed(() => {

View file

@ -29,8 +29,8 @@
<script lang="ts" setup>
import { onMounted, ref } from "vue";
import { acct } from "firefish-js";
import type * as firefish from "firefish-js";
import { stringToAcct } from "sdk";
import type { entities } from "firefish-js";
import MkUserInfo from "@/components/MkUserInfo.vue";
import * as os from "@/os";
import { defaultStore } from "@/store";
@ -48,7 +48,7 @@ const emit = defineEmits<{
}>();
const zIndex = os.claimZIndex("middle");
const user = ref<firefish.entities.UserDetailed | null>(null);
const user = ref<entities.UserDetailed | null>(null);
const top = ref(0);
const left = ref(0);
@ -57,7 +57,7 @@ onMounted(() => {
user.value = props.q;
} else {
const query = props.q.startsWith("@")
? acct.parse(props.q.slice(1))
? stringToAcct(props.q.slice(1))
: { userId: props.q };
os.api("users/show", query).then((res) => {

View file

@ -89,7 +89,7 @@
<script lang="ts" setup>
import { onMounted, ref } from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import MkInput from "@/components/form/input.vue";
import FormSplit from "@/components/form/split.vue";
import XModalWindow from "@/components/MkModalWindow.vue";
@ -98,16 +98,16 @@ import { defaultStore } from "@/store";
import { i18n } from "@/i18n";
const emit = defineEmits<{
(ev: "ok", selected: firefish.entities.UserDetailed): void;
(ev: "ok", selected: entities.UserDetailed): void;
(ev: "cancel"): void;
(ev: "closed"): void;
}>();
const username = ref("");
const host = ref("");
const users: firefish.entities.UserDetailed[] = ref([]);
const recentUsers: firefish.entities.UserDetailed[] = ref([]);
const selected: firefish.entities.UserDetailed | null = ref(null);
const users: entities.UserDetailed[] = ref([]);
const recentUsers: entities.UserDetailed[] = ref([]);
const selected: entities.UserDetailed | null = ref(null);
const dialogEl = ref();
const search = () => {

View file

@ -85,7 +85,7 @@
<script lang="ts" setup>
import { onMounted, ref } from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import MkInput from "@/components/form/input.vue";
import FormSplit from "@/components/form/split.vue";
import XModalWindow from "@/components/MkModalWindow.vue";
@ -94,15 +94,15 @@ import { defaultStore } from "@/store";
import { i18n } from "@/i18n";
const emit = defineEmits<{
(ev: "ok", selected: firefish.entities.UserDetailed): void;
(ev: "ok", selected: entities.UserDetailed): void;
(ev: "cancel"): void;
(ev: "closed"): void;
}>();
const username = ref("");
const users: firefish.entities.UserDetailed[] = ref([]);
const recentUsers: firefish.entities.UserDetailed[] = ref([]);
const selected: firefish.entities.UserDetailed | null = ref(null);
const users: entities.UserDetailed[] = ref([]);
const recentUsers: entities.UserDetailed[] = ref([]);
const selected: entities.UserDetailed | null = ref(null);
const dialogEl = ref();
const search = () => {

View file

@ -144,7 +144,7 @@
<script lang="ts" setup>
import { nextTick, ref, shallowRef, watch } from "vue";
import type * as firefish from "firefish-js";
import type { noteVisibilities } from "firefish-js";
import MkModal from "@/components/MkModal.vue";
import { i18n } from "@/i18n";
import icon from "@/scripts/icon";
@ -153,7 +153,7 @@ const modal = shallowRef<InstanceType<typeof MkModal>>();
const props = withDefaults(
defineProps<{
currentVisibility: (typeof firefish.noteVisibilities)[number];
currentVisibility: (typeof noteVisibilities)[number];
currentLocalOnly: boolean;
src?: HTMLElement;
}>(),
@ -161,10 +161,7 @@ const props = withDefaults(
);
const emit = defineEmits<{
(
ev: "changeVisibility",
v: (typeof firefish.noteVisibilities)[number],
): void;
(ev: "changeVisibility", v: (typeof noteVisibilities)[number]): void;
(ev: "changeLocalOnly", v: boolean): void;
(ev: "closed"): void;
}>();
@ -177,7 +174,7 @@ watch(localOnly, () => {
});
function choose(
visibility: (typeof firefish.noteVisibilities)[number] | "private",
visibility: (typeof noteVisibilities)[number] | "private",
): void {
v.value = visibility;
emit("changeVisibility", visibility);

View file

@ -10,14 +10,14 @@
</template>
<script lang="ts" setup>
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import { toUnicode } from "punycode/";
import { host as hostRaw } from "@/config";
import { defaultStore } from "@/store";
import { $i } from "@/reactiveAccount";
const props = defineProps<{
user: firefish.entities.UserDetailed;
user: entities.UserDetailed;
detail?: boolean;
}>();

View file

@ -8,7 +8,7 @@
square: user.isCat ? false : defaultStore.state.squareAvatars,
}"
:style="{ color }"
:title="acct(user)"
:title="acctToString(user)"
@click="onClick"
>
<img v-if="show" class="inner" :src="url" decoding="async" />
@ -28,7 +28,7 @@
square: user.isCat ? false : defaultStore.state.squareAvatars,
}"
:style="{ color }"
:title="acct(user)"
:title="acctToString(user)"
@click.stop
>
<img class="inner avatar" :src="url" decoding="async" />
@ -48,7 +48,7 @@
}"
:style="{ color }"
:to="userPage(user)"
:title="acct(user)"
:title="acctToString(user)"
:target="target"
@click.stop
>
@ -63,12 +63,13 @@
<script lang="ts" setup>
import { computed, onMounted, ref, watch } from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import PhotoSwipeLightbox from "photoswipe/lightbox";
import PhotoSwipe from "photoswipe";
import { getStaticImageUrl } from "@/scripts/get-static-image-url";
import { extractAvgColorFromBlurhash } from "@/scripts/extract-avg-color-from-blurhash";
import { acct, userPage } from "@/filters/user";
import { userPage } from "@/filters/user";
import { acctToString } from "sdk";
import MkUserOnlineIndicator from "@/components/MkUserOnlineIndicator.vue";
import { defaultStore } from "@/store";
import { $i } from "@/reactiveAccount";
@ -76,7 +77,7 @@ import "photoswipe/style.css";
const props = withDefaults(
defineProps<{
user: firefish.entities.User;
user: entities.User;
target?: string | null;
disableLink?: boolean;
showLightBox?: boolean;

View file

@ -22,7 +22,7 @@
<script lang="ts" setup>
import { computed } from "vue";
import { entities } from "firefish-js";
import type { entities } from "firefish-js";
import { getStaticImageUrl } from "@/scripts/get-static-image-url";
import { char2filePath } from "@/scripts/twemoji-base";
import { defaultStore } from "@/store";

View file

@ -10,13 +10,13 @@
</template>
<script lang="ts" setup>
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import { defaultStore } from "@/store";
import { $i } from "@/reactiveAccount";
const props = withDefaults(
defineProps<{
user: firefish.entities.User;
user: entities.User;
nowrap?: boolean;
}>(),
{

View file

@ -1,14 +1,13 @@
import * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import { acctToString, type Acct } from "sdk";
import { url } from "@/config";
export const acct = (user: firefish.Acct) => {
return firefish.acct.toString(user);
};
export const userName = (user: firefish.entities.User) => {
export const userName = (user: entities.User) => {
return user.name ?? user.username;
};
export const userPage = (user: firefish.Acct, path?, absolute = false) => {
return `${absolute ? url : ""}/@${acct(user)}${path ? `/${path}` : ""}`;
export const userPage = (user: Acct, path?, absolute = false) => {
return `${absolute ? url : ""}/@${acctToString(user)}${
path ? `/${path}` : ""
}`;
};

View file

@ -1,6 +1,8 @@
/**
* Client entry point
*/
import * as sdk from "sdk";
Object.assign(window, {sdk});
// https://vitejs.dev/config/build-options.html#build-modulepreload
import "vite/modulepreload-polyfill";

View file

@ -1,4 +1,4 @@
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import { computed, reactive } from "vue";
import { api } from "./os";
@ -7,7 +7,7 @@ import { api } from "./os";
const instanceData = localStorage.getItem("instance");
// TODO: instanceをリアクティブにするかは再考の余地あり
export const instance: firefish.entities.DetailedInstanceMetadata = reactive(
export const instance: entities.DetailedInstanceMetadata = reactive(
instanceData
? JSON.parse(instanceData)
: {

View file

@ -1,7 +1,7 @@
// TODO: なんでもかんでもos.tsに突っ込むのやめたいのでよしなに分割する
import { EventEmitter } from "eventemitter3";
import * as firefish from "firefish-js";
import { api as firefishApi, type entities } from "firefish-js";
import insertTextAtCursor from "insert-text-at-cursor";
import type { Component, Ref } from "vue";
import { defineAsyncComponent, markRaw, ref } from "vue";
@ -16,7 +16,7 @@ import type { MenuItem } from "@/types/menu";
export const pendingApiRequestsCount = ref(0);
const apiClient = new firefish.api.APIClient({
const apiClient = new firefishApi.APIClient({
origin: url,
});
@ -655,7 +655,7 @@ export async function selectLocalUser() {
});
}
export async function selectInstance(): Promise<firefish.entities.Instance> {
export async function selectInstance(): Promise<entities.Instance> {
return new Promise((resolve, reject) => {
popup(
defineAsyncComponent({
@ -745,11 +745,11 @@ export async function pickEmoji(src: HTMLElement | null, opts) {
}
export async function cropImage(
image: firefish.entities.DriveFile,
image: entities.DriveFile,
options: {
aspectRatio: number;
},
): Promise<firefish.entities.DriveFile> {
): Promise<entities.DriveFile> {
return new Promise((resolve, reject) => {
popup(
defineAsyncComponent({

View file

@ -37,7 +37,7 @@
<script lang="ts" setup>
import { ref } from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import MkButton from "@/components/MkButton.vue";
import { version } from "@/config";
import * as os from "@/os";
@ -56,7 +56,7 @@ withDefaults(
const loaded = ref(false);
const serverIsDead = ref(false);
const meta = ref<firefish.entities.LiteInstanceMetadata | null>(null);
const meta = ref<entities.LiteInstanceMetadata | null>(null);
os.api("meta", {
detail: false,

View file

@ -9,21 +9,20 @@
<div class="body">
<span class="name"><MkUserName class="name" :user="user" /></span>
<span class="sub"
><span class="acct _monospace">@{{ acct(user) }}</span></span
><span class="acct _monospace"
>@{{ acctToString(user) }}</span
></span
>
</div>
</MkA>
</template>
<script lang="ts" setup>
import { ref } from "vue";
import type { entities } from "firefish-js";
import { acctToString } from "sdk";
import type * as firefish from "firefish-js";
import * as os from "@/os";
import { acct } from "@/filters/user";
const props = defineProps<{
user: firefish.entities.User;
defineProps<{
user: entities.User;
}>();
</script>

View file

@ -29,7 +29,7 @@
<script lang="ts" setup>
import { computed, provide, ref, watch } from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import XNotes from "@/components/MkNotes.vue";
import { $i, isSignedIn } from "@/reactiveAccount";
import { i18n } from "@/i18n";
@ -41,7 +41,7 @@ const props = defineProps<{
clipId: string;
}>();
const clip = ref<firefish.entities.Clip>();
const clip = ref<entities.Clip>();
const pagination = {
endpoint: "clips/notes" as const,
limit: 10,

View file

@ -38,7 +38,7 @@
><MkUserName :user="req.follower"
/></MkA>
<p class="acct">
@{{ acct(req.follower) }}
@{{ acctToString(req.follower) }}
</p>
</div>
<div
@ -84,7 +84,8 @@
<script lang="ts" setup>
import { computed, ref } from "vue";
import MkPagination from "@/components/MkPagination.vue";
import { acct, userPage } from "@/filters/user";
import { userPage } from "@/filters/user";
import { acctToString } from "sdk";
import * as os from "@/os";
import { i18n } from "@/i18n";
import { definePageMetadata } from "@/scripts/page-metadata";

View file

@ -3,7 +3,7 @@
</template>
<script lang="ts" setup>
import * as firefishJs from "firefish-js";
import { stringToAcct } from "sdk";
import * as os from "@/os";
import { mainRouter } from "@/router";
import { i18n } from "@/i18n";
@ -50,7 +50,7 @@ if (acct.startsWith("https://")) {
}
});
} else {
promise = os.api("users/show", firefishJs.acct.parse(acct));
promise = os.api("users/show", stringToAcct(acct));
promise.then((user) => {
follow(user);
});

View file

@ -265,7 +265,7 @@
import { computed, ref, watch } from "vue";
import { Virtual } from "swiper/modules";
import { Swiper, SwiperSlide } from "swiper/vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import MkObjectView from "@/components/MkObjectView.vue";
import FormLink from "@/components/form/link.vue";
import MkLink from "@/components/MkLink.vue";
@ -287,11 +287,11 @@ import icon from "@/scripts/icon";
import "swiper/scss";
import "swiper/scss/virtual";
type AugmentedInstanceMetadata = firefish.entities.DetailedInstanceMetadata & {
type AugmentedInstanceMetadata = entities.DetailedInstanceMetadata & {
blockedHosts: string[];
silencedHosts: string[];
};
type AugmentedInstance = firefish.entities.Instance & {
type AugmentedInstance = entities.Instance & {
isBlocked: boolean;
isSilenced: boolean;
};

View file

@ -89,7 +89,7 @@
<script lang="ts" setup>
import { computed, markRaw, onMounted, onUnmounted, ref, watch } from "vue";
import { acct } from "firefish-js";
import { acctToString } from "sdk";
import { Virtual } from "swiper/modules";
import { Swiper, SwiperSlide } from "swiper/vue";
import MkButton from "@/components/MkButton.vue";
@ -207,7 +207,7 @@ function onRead(ids): void {
async function startUser(): void {
os.selectUser().then((user) => {
router.push(`/my/messaging/${acct.toString(user)}`);
router.push(`/my/messaging/${acctToString(user)}`);
});
}

View file

@ -52,7 +52,7 @@
<script lang="ts" setup>
import { computed, onMounted, ref, watch } from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import autosize from "autosize";
// import insertTextAtCursor from 'insert-text-at-cursor';
import { throttle } from "throttle-debounce";
@ -67,8 +67,8 @@ import { uploadFile } from "@/scripts/upload";
import icon from "@/scripts/icon";
const props = defineProps<{
user?: firefish.entities.UserDetailed | null;
group?: firefish.entities.UserGroup | null;
user?: entities.UserDetailed | null;
group?: entities.UserGroup | null;
}>();
const stream = useStream();
@ -77,7 +77,7 @@ const textEl = ref<HTMLTextAreaElement>();
const fileEl = ref<HTMLInputElement>();
const text = ref<string>("");
const file = ref<firefish.entities.DriveFile | null>(null);
const file = ref<entities.DriveFile | null>(null);
const sending = ref(false);
const typing = throttle(3000, () => {
stream.send(

View file

@ -85,7 +85,7 @@
import { computed } from "vue";
import * as mfm from "mfm-js";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import XMediaList from "@/components/MkMediaList.vue";
import { extractUrlFromMfm } from "@/scripts/extract-url-from-mfm";
import MkUrlPreview from "@/components/MkUrlPreview.vue";
@ -95,7 +95,7 @@ import { i18n } from "@/i18n";
import icon from "@/scripts/icon";
const props = defineProps<{
message: firefish.entities.MessagingMessage;
message: entities.MessagingMessage;
isGroup?: boolean;
}>();

View file

@ -105,7 +105,8 @@ import {
ref,
watch,
} from "vue";
import * as firefishJs from "firefish-js";
import type { entities } from "firefish-js";
import { stringToAcct } from "sdk";
import XMessage from "./messaging-room.message.vue";
import XForm from "./messaging-room.form.vue";
import XList from "@/components/MkDateSeparatedList.vue";
@ -138,12 +139,11 @@ const formEl = ref<InstanceType<typeof XForm>>();
const pagingComponent = ref<InstanceType<typeof MkPagination>>();
const fetching = ref(true);
const user = ref<firefishJs.entities.UserDetailed | null>(null);
const group = ref<firefishJs.entities.UserGroup | null>(null);
const typers = ref<firefishJs.entities.User[]>([]);
const connection: firefishJs.ChannelConnection<
firefishJs.StreamTypes.Channels["messaging"]
> | null = ref(null);
const user = ref<entities.UserDetailed | null>(null);
const group = ref<entities.UserGroup | null>(null);
const typers = ref<entities.User[]>([]);
const connection: ChannelConnection<StreamTypes.Channels["messaging"]> | null =
ref(null);
const showIndicator = ref(false);
const { animation } = defaultStore.reactiveState;
@ -158,7 +158,7 @@ async function fetch() {
fetching.value = true;
if (props.userAcct) {
const acct = firefishJs.acct.parse(props.userAcct);
const acct = stringToAcct(props.userAcct);
user.value = await os.api("users/show", {
username: acct.username,
host: acct.host ?? undefined,

View file

@ -115,7 +115,7 @@
<script lang="ts" setup>
import { ref, watch } from "vue";
import { acct } from "firefish-js";
import { acctToString } from "sdk";
import MkButton from "@/components/MkButton.vue";
import MkInput from "@/components/form/input.vue";
import MkTextarea from "@/components/form/textarea.vue";
@ -226,7 +226,7 @@ async function deleteAntenna() {
function addUser() {
os.selectUser().then((user) => {
users.value = users.value.trim();
users.value += `\n@${acct.toString(user as any)}`;
users.value += `\n@${acctToString(user as any)}`;
users.value = users.value.trim();
});
}

View file

@ -70,7 +70,7 @@
<script lang="ts" setup>
import { computed, ref, watch } from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import XNoteDetailed from "@/components/MkNoteDetailed.vue";
import XNotes from "@/components/MkNotes.vue";
import MkRemoteCaution from "@/components/MkRemoteCaution.vue";
@ -86,14 +86,14 @@ const props = defineProps<{
noteId: string;
}>();
const note = ref<null | firefish.entities.Note>();
const note = ref<null | entities.Note>();
const hasPrev = ref(false);
const hasNext = ref(false);
const showPrev = ref(false);
const showNext = ref(false);
const error = ref();
const isRenote = ref(false);
const appearNote = ref<null | firefish.entities.Note>();
const appearNote = ref<null | entities.Note>();
const prevPagination = {
endpoint: "users/notes" as const,
@ -139,7 +139,7 @@ function fetchNote() {
note.value.fileIds.length === 0 &&
note.value.poll == null;
appearNote.value = isRenote.value
? (note.value.renote as firefish.entities.Note)
? (note.value.renote as entities.Note)
: note.value;
Promise.all([

View file

@ -33,9 +33,8 @@
import { computed, ref } from "vue";
// SPECIFICATION: https://misskey-hub.net/docs/features/share-form.html
import { noteVisibilities } from "firefish-js";
import { acct } from "firefish-js";
import type * as firefish from "firefish-js";
import { noteVisibilities, type entities } from "firefish-js";
import { stringToAcct } from "sdk";
import MkButton from "@/components/MkButton.vue";
import XPostForm from "@/components/MkPostForm.vue";
import * as os from "@/os";
@ -53,16 +52,16 @@ const title = ref(urlParams.get("title"));
const text = urlParams.get("text");
const url = urlParams.get("url");
const initialText = ref(null as string | null);
const reply = ref(null as firefish.entities.Note | null);
const renote = ref(null as firefish.entities.Note | null);
const reply = ref(null as entities.Note | null);
const renote = ref(null as entities.Note | null);
const visibility = ref(
noteVisibilities.includes(visibilityQuery) ? visibilityQuery : null,
);
const localOnly = ref(
localOnlyQuery === "0" ? false : localOnlyQuery === "1" ? true : null,
);
const files = ref([] as firefish.entities.DriveFile[]);
const visibleUsers = ref([] as firefish.entities.User[]);
const files = ref([] as entities.DriveFile[]);
const visibleUsers = ref([] as entities.User[]);
async function init() {
let noteText = "";
@ -83,7 +82,7 @@ async function init() {
? visibleUserIds.split(",").map((userId) => ({ userId }))
: []),
...(visibleAccts
? visibleAccts.split(",").map(acct.parse)
? visibleAccts.split(",").map(stringToAcct)
: []),
]
// TypeScript

View file

@ -21,7 +21,7 @@
/></span>
<span class="sub"
><span class="acct _monospace"
>@{{ acct(user) }}</span
>@{{ acctToString(user) }}</span
></span
>
<span class="state">
@ -348,7 +348,7 @@
<script lang="ts" setup>
import { computed, ref, watch } from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import MkObjectView from "@/components/MkObjectView.vue";
import FormTextarea from "@/components/form/textarea.vue";
import FormSwitch from "@/components/form/switch.vue";
@ -364,7 +364,8 @@ import MkFileListForAdmin from "@/components/MkFileListForAdmin.vue";
import MkInfo from "@/components/MkInfo.vue";
import * as os from "@/os";
import { url } from "@/config";
import { acct, userPage } from "@/filters/user";
import { acctToString } from "sdk";
import { userPage } from "@/filters/user";
import { definePageMetadata } from "@/scripts/page-metadata";
import { i18n } from "@/i18n";
import { isAdmin, isModerator } from "@/reactiveAccount";
@ -376,7 +377,7 @@ const props = defineProps<{
}>();
const tab = ref("overview");
const user = ref<null | firefish.entities.UserDetailed>();
const user = ref<null | entities.UserDetailed>();
const init = ref<ReturnType<typeof createFetcher>>();
const info = ref();
const ips = ref(null);
@ -655,7 +656,7 @@ const headerTabs = computed(() =>
definePageMetadata(
computed(() => ({
title: user.value ? acct(user.value) : i18n.ts.userInfo,
title: user.value ? acctToString(user.value) : i18n.ts.userInfo,
icon: `${icon("ph-info")}`,
})),
);

View file

@ -25,11 +25,11 @@
<script lang="ts" setup>
import { computed } from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import MkPagination from "@/components/MkPagination.vue";
const props = defineProps<{
user: firefish.entities.User;
user: entities.User;
}>();
const pagination = {

View file

@ -24,12 +24,12 @@
<script lang="ts" setup>
import { computed } from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import MkUserInfo from "@/components/MkUserInfo.vue";
import MkPagination from "@/components/MkPagination.vue";
const props = defineProps<{
user: firefish.entities.User;
user: entities.User;
type: "following" | "followers";
}>();

View file

@ -17,7 +17,8 @@
<script lang="ts" setup>
import { computed, ref, watch } from "vue";
import * as firefishJs from "firefish-js";
import type { entities } from "firefish-js";
import { stringToAcct } from "sdk";
import XFollowList from "./follow-list.vue";
import * as os from "@/os";
import { definePageMetadata } from "@/scripts/page-metadata";
@ -31,13 +32,13 @@ const props = withDefaults(
{},
);
const user = ref<null | firefishJs.entities.UserDetailed>(null);
const user = ref<null | entities.UserDetailed>(null);
const error = ref(null);
function fetchUser(): void {
if (props.acct == null) return;
user.value = null;
os.api("users/show", firefishJs.acct.parse(props.acct))
os.api("users/show", stringToAcct(props.acct))
.then((u) => {
user.value = u;
})

View file

@ -17,7 +17,8 @@
<script lang="ts" setup>
import { computed, ref, watch } from "vue";
import * as firefishJs from "firefish-js";
import type { entities } from "firefish-js";
import { stringToAcct } from "sdk";
import XFollowList from "./follow-list.vue";
import * as os from "@/os";
import { definePageMetadata } from "@/scripts/page-metadata";
@ -31,13 +32,13 @@ const props = withDefaults(
{},
);
const user = ref<null | firefishJs.entities.UserDetailed>(null);
const user = ref<null | entities.UserDetailed>(null);
const error = ref(null);
function fetchUser(): void {
if (props.acct == null) return;
user.value = null;
os.api("users/show", firefishJs.acct.parse(props.acct))
os.api("users/show", stringToAcct(props.acct))
.then((u) => {
user.value = u;
})

View file

@ -15,13 +15,13 @@
<script lang="ts" setup>
import { computed } from "vue";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import MkGalleryPostPreview from "@/components/MkGalleryPostPreview.vue";
import MkPagination from "@/components/MkPagination.vue";
const props = withDefaults(
defineProps<{
user: firefish.entities.User;
user: entities.User;
}>(),
{},
);

View file

@ -376,7 +376,7 @@ import {
} from "vue";
import calcAge from "s-age";
import cityTimezones from "city-timezones";
import type * as firefish from "firefish-js";
import type { entities } from "firefish-js";
import XUserTimeline from "./index.timeline.vue";
import XNote from "@/components/MkNote.vue";
import MkFollowButton from "@/components/MkFollowButton.vue";
@ -402,7 +402,7 @@ const emphasizeFollowed = defaultStore.state.emphasizeFollowed;
const emit = defineEmits(["refresh"]);
const props = withDefaults(
defineProps<{
user: firefish.entities.UserDetailed;
user: entities.UserDetailed;
}>(),
{},
);

Some files were not shown because too many files have changed in this diff Show more