1
0
Fork 1
mirror of https://example.com synced 2024-11-22 21:26: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 .eslintcache
# misskey # misskey
built /built
db db
elasticsearch elasticsearch
redis redis

67
Cargo.lock generated
View file

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

View file

@ -1,5 +1,5 @@
[workspace] [workspace]
members = ["packages/backend-rs"] members = ["packages/backend-rs", "packages/sdk"]
resolver = "2" resolver = "2"
[workspace.dependencies] [workspace.dependencies]
@ -7,6 +7,8 @@ napi = { version = "2.15.0", default-features = false }
napi-build = "2.1.0" napi-build = "2.1.0"
napi-derive = "2.15.0" napi-derive = "2.15.0"
wasm-bindgen = "0.2.90"
argon2 = "0.5.3" argon2 = "0.5.3"
async-trait = "0.1.77" async-trait = "0.1.77"
basen = "0.1.0" 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/firefish-js/package.json
PACKAGE_JSONS += packages/megalodon/package.json PACKAGE_JSONS += packages/megalodon/package.json
PACKAGE_JSONS += packages/sw/package.json PACKAGE_JSONS += packages/sw/package.json
PACKAGE_JSONS += packages/sdk/package.json
CARGO_TOMLS := Cargo.toml CARGO_TOMLS := Cargo.toml
CARGO_TOMLS += packages/backend-rs/Cargo.toml CARGO_TOMLS += packages/backend-rs/Cargo.toml
CARGO_TOMLS += packages/sdk/Cargo.toml
RUST_BE_DIR := packages/backend-rs RUST_BE_DIR := packages/backend-rs
RUST_BE_SRC := Cargo.toml RUST_BE_SRC := Cargo.toml
RUST_BE_SRC += $(RUST_BE_DIR)/Cargo.toml RUST_BE_SRC += $(RUST_BE_DIR)/Cargo.toml
RUST_BE_SRC += $(call recursive_wildcard, $(RUST_BE_DIR)/src, *) 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, $(wildcard $(dir)/*))
MIGRATIONS += $(foreach dir, packages/backend/migration-neko, $(wildcard $(dir)/*)) MIGRATIONS += $(foreach dir, packages/backend/migration-neko, $(wildcard $(dir)/*))
@ -85,12 +92,16 @@ format:
.PHONY: rust-lint .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) $(T)/rust-be-lint: $(RUST_BE_SRC)
pnpm --filter='backend-rs' run lint pnpm --filter='backend-rs' run lint
touch $@ touch $@
$(T)/sdk-lint: $(SDK_SRC)
pnpm --filter='sdk' run lint
touch $@
.PHONY: regenerate-entities .PHONY: regenerate-entities
regenerate-entities: $(T)/regenerate-entities regenerate-entities: $(T)/regenerate-entities

View file

@ -1,7 +1,5 @@
/* tslint:disable */ // prettier-ignore
/* eslint-disable */ /* eslint-disable */
/* prettier-ignore */
/* auto-generated by NAPI-RS */ /* auto-generated by NAPI-RS */
const { existsSync, readFileSync } = require('fs') const { existsSync, readFileSync } = require('fs')
@ -13,18 +11,52 @@ let nativeBinding = null
let localFileExisted = false let localFileExisted = false
let loadError = null let loadError = null
function isMusl() { const isMusl = () => {
// For Node 10 let musl = false
if (!process.report || typeof process.report.getReport !== 'function') { 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 { try {
const lddPath = require('child_process').execSync('which ldd').toString().trim() return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
return readFileSync(lddPath, 'utf8').includes('musl') } catch {
} catch (e) { 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 return true
} }
} else { }
const { glibcVersionRuntime } = process.report.getReport().header return false
return !glibcVersionRuntime }
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}`) 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 (!nativeBinding) {
if (loadError) { if (loadError) {
throw loadError throw loadError
@ -295,45 +342,41 @@ if (!nativeBinding) {
throw new Error(`Failed to load native binding`) 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 = nativeBinding.EnvConfig
module.exports.JsDbConn = nativeBinding.JsDbConn
module.exports.EnvConfig = EnvConfig module.exports.AntennaSrcEnum = nativeBinding.AntennaSrcEnum
module.exports.readEnvironmentConfig = readEnvironmentConfig module.exports.checkWordMute = nativeBinding.checkWordMute
module.exports.readServerConfig = readServerConfig module.exports.connectToDatabase = nativeBinding.connectToDatabase
module.exports.JsDbConn = JsDbConn module.exports.convertId = nativeBinding.convertId
module.exports.connectToDatabase = connectToDatabase module.exports.convertToHiddenPost = nativeBinding.convertToHiddenPost
module.exports.AntennaSrcEnum = AntennaSrcEnum module.exports.extractHost = nativeBinding.extractHost
module.exports.MutedNoteReasonEnum = MutedNoteReasonEnum module.exports.fetchMeta = nativeBinding.fetchMeta
module.exports.NoteVisibilityEnum = NoteVisibilityEnum module.exports.formatMilliseconds = nativeBinding.formatMilliseconds
module.exports.NotificationTypeEnum = NotificationTypeEnum module.exports.genString = nativeBinding.genString
module.exports.PageVisibilityEnum = PageVisibilityEnum module.exports.getFullApAccount = nativeBinding.getFullApAccount
module.exports.PollNotevisibilityEnum = PollNotevisibilityEnum module.exports.hashPassword = nativeBinding.hashPassword
module.exports.RelayStatusEnum = RelayStatusEnum module.exports.hasOtherRenoteOfThisNote = nativeBinding.hasOtherRenoteOfThisNote
module.exports.UserEmojimodpermEnum = UserEmojimodpermEnum module.exports.IdConvertType = nativeBinding.IdConvertType
module.exports.UserProfileFfvisibilityEnum = UserProfileFfvisibilityEnum module.exports.isOldPasswordAlgorithm = nativeBinding.isOldPasswordAlgorithm
module.exports.UserProfileMutingnotificationtypesEnum = UserProfileMutingnotificationtypesEnum module.exports.isSelfHost = nativeBinding.isSelfHost
module.exports.stringToAcct = stringToAcct module.exports.metaToPugArgs = nativeBinding.metaToPugArgs
module.exports.acctToString = acctToString module.exports.MutedNoteReasonEnum = nativeBinding.MutedNoteReasonEnum
module.exports.checkWordMute = checkWordMute module.exports.nativeCreateId = nativeBinding.nativeCreateId
module.exports.getFullApAccount = getFullApAccount module.exports.nativeGetTimestamp = nativeBinding.nativeGetTimestamp
module.exports.isSelfHost = isSelfHost module.exports.nativeInitIdGenerator = nativeBinding.nativeInitIdGenerator
module.exports.extractHost = extractHost module.exports.NoteVisibilityEnum = nativeBinding.NoteVisibilityEnum
module.exports.toPuny = toPuny module.exports.NotificationTypeEnum = nativeBinding.NotificationTypeEnum
module.exports.toPunyOptional = toPunyOptional module.exports.nyaify = nativeBinding.nyaify
module.exports.convertToHiddenPost = convertToHiddenPost module.exports.PageVisibilityEnum = nativeBinding.PageVisibilityEnum
module.exports.sqlLikeEscape = sqlLikeEscape module.exports.PollNotevisibilityEnum = nativeBinding.PollNotevisibilityEnum
module.exports.safeForSql = safeForSql module.exports.readEnvironmentConfig = nativeBinding.readEnvironmentConfig
module.exports.formatMilliseconds = formatMilliseconds module.exports.readServerConfig = nativeBinding.readServerConfig
module.exports.nativeInitIdGenerator = nativeInitIdGenerator module.exports.RelayStatusEnum = nativeBinding.RelayStatusEnum
module.exports.nativeCreateId = nativeCreateId module.exports.safeForSql = nativeBinding.safeForSql
module.exports.nativeGetTimestamp = nativeGetTimestamp module.exports.sqlLikeEscape = nativeBinding.sqlLikeEscape
module.exports.fetchMeta = fetchMeta module.exports.toPuny = nativeBinding.toPuny
module.exports.metaToPugArgs = metaToPugArgs module.exports.toPunyOptional = nativeBinding.toPunyOptional
module.exports.hasOtherRenoteOfThisNote = hasOtherRenoteOfThisNote module.exports.UserEmojimodpermEnum = nativeBinding.UserEmojimodpermEnum
module.exports.nyaify = nyaify module.exports.UserProfileFfvisibilityEnum = nativeBinding.UserProfileFfvisibilityEnum
module.exports.hashPassword = hashPassword module.exports.UserProfileMutingnotificationtypesEnum = nativeBinding.UserProfileMutingnotificationtypesEnum
module.exports.verifyPassword = verifyPassword module.exports.verifyPassword = nativeBinding.verifyPassword
module.exports.isOldPasswordAlgorithm = isOldPasswordAlgorithm
module.exports.genString = genString
module.exports.IdConvertType = IdConvertType
module.exports.convertId = convertId

View file

@ -42,6 +42,7 @@ br
say 'Start building Firefish.' say 'Start building Firefish.'
say 'It takes some time! Why not brew a cup of cofe?' 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' run 'NODE_OPTIONS="--max_old_space_size=3072" NODE_ENV="production" pnpm run rebuild'
say "Done! We're almost there." say "Done! We're almost there."

View file

@ -13,7 +13,7 @@
"private": true, "private": true,
"scripts": { "scripts": {
"rebuild": "pnpm run clean && pnpm run build", "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": "pnpm --filter backend run start",
"start:container": "pnpm run gulp && pnpm run migrate && pnpm run start", "start:container": "pnpm run gulp && pnpm run migrate && pnpm run start",
"init": "pnpm run migrate", "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", "dev:staging": "NODE_OPTIONS=--max_old_space_size=3072 NODE_ENV=development pnpm run build && pnpm run start",
"lint": "pnpm -r --parallel run lint", "lint": "pnpm -r --parallel run lint",
"debug": "pnpm run build:debug && pnpm run start", "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", "format": "pnpm -r --parallel run format",
"clean": "pnpm node ./scripts/clean-built.mjs", "clean": "pnpm node ./scripts/clean-built.mjs",
"clean-cargo": "cargo clean", "clean-cargo": "cargo clean",
@ -36,7 +36,6 @@
"dependencies": { "dependencies": {
"@bull-board/api": "5.14.0", "@bull-board/api": "5.14.0",
"@bull-board/ui": "5.14.0", "@bull-board/ui": "5.14.0",
"@napi-rs/cli": "2.18.0",
"gulp": "4.0.2", "gulp": "4.0.2",
"gulp-cssnano": "2.1.3", "gulp-cssnano": "2.1.3",
"gulp-replace": "1.1.4", "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 - `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 - `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 - `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 = { workspace = true, default-features = false, features = ["napi9", "tokio_rt", "chrono_date", "serde-json"] }
napi-derive = { workspace = true } napi-derive = { workspace = true }
sdk = { path = "../sdk" }
argon2 = { workspace = true } argon2 = { workspace = true }
async-trait = { workspace = true } async-trait = { workspace = true }
basen = { workspace = true } basen = { workspace = true }

View file

@ -4,26 +4,11 @@
"main": "built/index.js", "main": "built/index.js",
"types": "built/index.d.ts", "types": "built/index.d.ts",
"napi": { "napi": {
"name": "backend-rs", "binaryName": "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"
]
}
}, },
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@napi-rs/cli": "2.18.0", "@napi-rs/cli": "3.0.0-alpha.36",
"ava": "6.1.1" "ava": "6.1.1"
}, },
"ava": { "ava": {
@ -31,8 +16,8 @@
}, },
"scripts": { "scripts": {
"artifacts": "napi artifacts", "artifacts": "napi artifacts",
"build": "napi build --platform --release ./built/", "build": "napi build --platform --release --output-dir ./built/",
"build:debug": "napi build --platform ./built/", "build:debug": "napi build --platform --output-dir ./built/",
"prepublishOnly": "napi prepublish -t npm", "prepublishOnly": "napi prepublish -t npm",
"universal": "napi universal", "universal": "napi universal",
"version": "napi version", "version": "napi version",

View file

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

View file

@ -1,4 +1,3 @@
pub mod acct;
pub mod check_word_mute; pub mod check_word_mute;
pub mod convert_host; pub mod convert_host;
pub mod convert_to_hidden_post; 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 { queueLogger } from "../../logger.js";
import { resolveUser } from "@/remote/resolve-user.js"; import { resolveUser } from "@/remote/resolve-user.js";
import { downloadTextFile } from "@/misc/download-text-file.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 { Users, DriveFiles } from "@/models/index.js";
import type { DbUserImportJobData } from "@/queue/types.js"; import type { DbUserImportJobData } from "@/queue/types.js";
import block from "@/services/blocking/create.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 { resolveUser } from "@/remote/resolve-user.js";
import { downloadTextFile } from "@/misc/download-text-file.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 { Users, DriveFiles } from "@/models/index.js";
import type { DbUserImportJobData } from "@/queue/types.js"; import type { DbUserImportJobData } from "@/queue/types.js";
import { queueLogger } from "../../logger.js"; import { queueLogger } from "../../logger.js";

View file

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

View file

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

View file

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

View file

@ -1,8 +1,7 @@
import Router from "@koa/router"; import Router from "@koa/router";
import config from "@/config/index.js"; import config from "@/config/index.js";
import { stringToAcct } from "backend-rs"; import { stringToAcct, type Acct } from "backend-rs";
import type { Acct } from "backend-rs";
import { links } from "./nodeinfo.js"; import { links } from "./nodeinfo.js";
import { escapeAttribute, escapeValue } from "@/prelude/xml.js"; import { escapeAttribute, escapeValue } from "@/prelude/xml.js";
import { Users } from "@/models/index.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", "rollup": "4.9.6",
"s-age": "1.1.2", "s-age": "1.1.2",
"sass": "1.70.0", "sass": "1.70.0",
"sdk": "workspace:*",
"seedrandom": "3.0.5", "seedrandom": "3.0.5",
"stringz": "2.1.0", "stringz": "2.1.0",
"swiper": "11.0.5", "swiper": "11.0.5",
@ -85,6 +86,8 @@
"uuid": "9.0.1", "uuid": "9.0.1",
"vite": "5.0.12", "vite": "5.0.12",
"vite-plugin-compression": "0.5.1", "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": "3.4.15",
"vue-draggable-plus": "^0.3.5", "vue-draggable-plus": "^0.3.5",
"vue-plyr": "^7.0.0", "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 { defineAsyncComponent } from "vue";
import { i18n } from "./i18n"; import { i18n } from "./i18n";
import { apiUrl } from "@/config"; import { apiUrl } from "@/config";
@ -10,7 +10,7 @@ import { reloadChannel, unisonReload } from "@/scripts/unison-reload";
// TODO: 他のタブと永続化されたstateを同期 // TODO: 他のタブと永続化されたstateを同期
export type Account = firefish.entities.MeDetailed; export type Account = entities.MeDetailed;
export async function signout() { export async function signout() {
waiting(); waiting();
@ -149,8 +149,8 @@ export async function openAccountMenu(
opts: { opts: {
includeCurrentAccount?: boolean; includeCurrentAccount?: boolean;
withExtraOperation: boolean; withExtraOperation: boolean;
active?: firefish.entities.UserDetailed["id"]; active?: entities.UserDetailed["id"];
onChoose?: (account: firefish.entities.UserDetailed) => void; onChoose?: (account: entities.UserDetailed) => void;
}, },
ev: MouseEvent, ev: MouseEvent,
isMobile?: boolean, 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 storedAccounts = await getAccounts();
const token = storedAccounts.find((x) => x.id === account.id).token; const token = storedAccounts.find((x) => x.id === account.id).token;
switchAccountWithToken(token); switchAccountWithToken(token);
@ -200,7 +200,7 @@ export async function openAccountMenu(
userIds: storedAccounts.map((x) => x.id), userIds: storedAccounts.map((x) => x.id),
}); });
function createItem(account: firefish.entities.UserDetailed) { function createItem(account: entities.UserDetailed) {
return { return {
type: "user", type: "user",
user: account, user: account,

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -32,16 +32,16 @@
<script lang="ts" setup> <script lang="ts" setup>
import { onMounted, ref, watch } from "vue"; 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 MkReactionIcon from "@/components/MkReactionIcon.vue";
import MkUserCardMini from "@/components/MkUserCardMini.vue"; import MkUserCardMini from "@/components/MkUserCardMini.vue";
import * as os from "@/os"; import * as os from "@/os";
const props = defineProps<{ 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 tab = ref<string | null>(null);
const reactions = ref<string[]>(); const reactions = ref<string[]>();
const users = ref(); const users = ref();

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -10,13 +10,13 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import type * as firefish from "firefish-js"; import type { entities } from "firefish-js";
import { defaultStore } from "@/store"; import { defaultStore } from "@/store";
import { $i } from "@/reactiveAccount"; import { $i } from "@/reactiveAccount";
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
user: firefish.entities.User; user: entities.User;
nowrap?: boolean; 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"; import { url } from "@/config";
export const acct = (user: firefish.Acct) => { export const userName = (user: entities.User) => {
return firefish.acct.toString(user);
};
export const userName = (user: firefish.entities.User) => {
return user.name ?? user.username; return user.name ?? user.username;
}; };
export const userPage = (user: firefish.Acct, path?, absolute = false) => { export const userPage = (user: Acct, path?, absolute = false) => {
return `${absolute ? url : ""}/@${acct(user)}${path ? `/${path}` : ""}`; return `${absolute ? url : ""}/@${acctToString(user)}${
path ? `/${path}` : ""
}`;
}; };

View file

@ -1,6 +1,8 @@
/** /**
* Client entry point * Client entry point
*/ */
import * as sdk from "sdk";
Object.assign(window, {sdk});
// https://vitejs.dev/config/build-options.html#build-modulepreload // https://vitejs.dev/config/build-options.html#build-modulepreload
import "vite/modulepreload-polyfill"; 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 { computed, reactive } from "vue";
import { api } from "./os"; import { api } from "./os";
@ -7,7 +7,7 @@ import { api } from "./os";
const instanceData = localStorage.getItem("instance"); const instanceData = localStorage.getItem("instance");
// TODO: instanceをリアクティブにするかは再考の余地あり // TODO: instanceをリアクティブにするかは再考の余地あり
export const instance: firefish.entities.DetailedInstanceMetadata = reactive( export const instance: entities.DetailedInstanceMetadata = reactive(
instanceData instanceData
? JSON.parse(instanceData) ? JSON.parse(instanceData)
: { : {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -89,7 +89,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { computed, markRaw, onMounted, onUnmounted, ref, watch } from "vue"; import { computed, markRaw, onMounted, onUnmounted, ref, watch } from "vue";
import { acct } from "firefish-js"; import { acctToString } from "sdk";
import { Virtual } from "swiper/modules"; import { Virtual } from "swiper/modules";
import { Swiper, SwiperSlide } from "swiper/vue"; import { Swiper, SwiperSlide } from "swiper/vue";
import MkButton from "@/components/MkButton.vue"; import MkButton from "@/components/MkButton.vue";
@ -207,7 +207,7 @@ function onRead(ids): void {
async function startUser(): void { async function startUser(): void {
os.selectUser().then((user) => { 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> <script lang="ts" setup>
import { computed, onMounted, ref, watch } from "vue"; 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 autosize from "autosize";
// import insertTextAtCursor from 'insert-text-at-cursor'; // import insertTextAtCursor from 'insert-text-at-cursor';
import { throttle } from "throttle-debounce"; import { throttle } from "throttle-debounce";
@ -67,8 +67,8 @@ import { uploadFile } from "@/scripts/upload";
import icon from "@/scripts/icon"; import icon from "@/scripts/icon";
const props = defineProps<{ const props = defineProps<{
user?: firefish.entities.UserDetailed | null; user?: entities.UserDetailed | null;
group?: firefish.entities.UserGroup | null; group?: entities.UserGroup | null;
}>(); }>();
const stream = useStream(); const stream = useStream();
@ -77,7 +77,7 @@ const textEl = ref<HTMLTextAreaElement>();
const fileEl = ref<HTMLInputElement>(); const fileEl = ref<HTMLInputElement>();
const text = ref<string>(""); const text = ref<string>("");
const file = ref<firefish.entities.DriveFile | null>(null); const file = ref<entities.DriveFile | null>(null);
const sending = ref(false); const sending = ref(false);
const typing = throttle(3000, () => { const typing = throttle(3000, () => {
stream.send( stream.send(

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

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