feat: remove @auth/core

This commit is contained in:
DIYgod 2025-03-13 18:14:40 +08:00
parent 55c1def859
commit d54535dc45
No known key found for this signature in database
11 changed files with 38 additions and 75 deletions

View File

@ -52,6 +52,7 @@
"vscode-languagedetection": "npm:@vscode/vscode-languagedetection@1.0.22"
},
"devDependencies": {
"@follow/models": "workspace:*",
"@follow/types": "workspace:*",
"@types/js-yaml": "4.0.9",
"@types/node": "22.13.10",

View File

@ -1,5 +1,5 @@
import type { User } from "@auth/core/types"
import type { Credentials } from "@eneris/push-receiver/dist/types"
import type { UserModel } from "@follow/models"
import { logger } from "~/logger"
@ -12,8 +12,8 @@ export const getBetterAuthSessionCookie = () => store.get(BetterAuthKey)
export const cleanBetterAuthSessionCookie = () => store.set(BetterAuthKey, null)
const UserKey = "user"
export const setUser = (user: User) => store.set(UserKey, JSON.stringify(user))
export const getUser = (): User | null => {
export const setUser = (user: UserModel) => store.set(UserKey, JSON.stringify(user))
export const getUser = (): UserModel | null => {
const user = store.get(UserKey)
return user ? JSON.parse(user) : null
}

View File

@ -1,4 +1,4 @@
import type { User } from "@auth/core/types"
import type { UserModel } from "@follow/models"
import { setUser } from "../lib/user"
import { t } from "./_instance"
@ -6,7 +6,7 @@ import { t } from "./_instance"
export const trackerRoute = {
trackerIdentify: t.procedure
.input<{
user: User
user: UserModel
}>()
.action(async ({ input }) => {
const { user } = input

View File

@ -3,7 +3,7 @@
"compilerOptions": {
"composite": true,
"outDir": "dist",
"types": ["electron-vite/node", "@follow/types/vite"],
"types": ["electron-vite/node", "@follow/types/vite", "@follow/types/global"],
"moduleResolution": "Bundler",
"noImplicitReturns": false,
"noUnusedLocals": false,

View File

@ -1,4 +1,3 @@
import type { User } from "@auth/core/types"
import { isMobile, useMobile } from "@follow/components/hooks/useMobile.js"
import { PhUsersBold } from "@follow/components/icons/users.jsx"
import { Avatar, AvatarFallback, AvatarImage } from "@follow/components/ui/avatar/index.jsx"
@ -6,7 +5,7 @@ import { ActionButton, Button } from "@follow/components/ui/button/index.js"
import { LoadingWithIcon } from "@follow/components/ui/loading/index.jsx"
import { ScrollArea } from "@follow/components/ui/scroll-area/index.js"
import { EllipsisHorizontalTextWithTooltip } from "@follow/components/ui/typography/index.js"
import type { FeedModel, Models } from "@follow/models"
import type { FeedModel, Models, UserModel } from "@follow/models"
import { stopPropagation } from "@follow/utils/dom"
import { cn } from "@follow/utils/utils"
import { useQuery } from "@tanstack/react-query"
@ -150,7 +149,7 @@ const UserCount: Component<{ count: number }> = ({ count, className }) => {
}
interface TopUserAvatarProps {
user: User
user: UserModel
position: string
}
@ -170,7 +169,7 @@ const TopUserAvatar: React.FC<TopUserAvatarProps> = ({ user, position }) => (
</div>
)
const TrendingUsers: FC<{ data: User[] }> = ({ data }) => {
const TrendingUsers: FC<{ data: UserModel[] }> = ({ data }) => {
const profile = usePresentUserProfileModal("dialog")
const { t } = useTranslation()
return (

View File

@ -1,8 +1,8 @@
import type { User } from "@auth/core/types"
import type { UserModel } from "@follow/models"
import { createAtomHooks } from "@follow/utils/jotai"
import { atom } from "jotai"
export const [, , useWhoami, , whoami, setWhoami] = createAtomHooks(atom<Nullable<User>>(null))
export const [, , useWhoami, , whoami, setWhoami] = createAtomHooks(atom<Nullable<UserModel>>(null))
export const [, , useLoginModalShow, useSetLoginModalShow, getLoginModalShow, setLoginModalShow] =
createAtomHooks(atom<boolean>(false))

View File

@ -22,8 +22,10 @@ export const UserAvatar = ({ className }: { className?: string }) => {
if (!user) {
if (import.meta.env.DEV) {
user = {
id: "1",
name: "Innei",
image: "https://avatars-githubusercontent-webp.webp.se/u/41265413?v=4",
handle: "innei",
}
} else {
return null

View File

@ -1,8 +1,18 @@
import type { User } from "@auth/core/types"
import { createAtomHooks } from "@follow/utils/jotai"
import { atom } from "jotai"
export const [, , useWhoami, , whoami, setWhoami] = createAtomHooks(atom<Nullable<User>>())
export const [, , useWhoami, , whoami, setWhoami] =
createAtomHooks(
atom<
Nullable<{
id: string
name: string | null
image: string | null
handle: string | null
email?: string
}>
>(),
)
export const [, , useLoginModalShow, useSetLoginModalShow, getLoginModalShow, setLoginModalShow] =
createAtomHooks(atom<boolean>(false))

View File

@ -20,7 +20,6 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@auth/core": "0.37.4",
"@follow/constants": "workspace:*",
"@follow/shared": "workspace:*",
"@follow/types": "workspace:*",

View File

@ -1,6 +1,4 @@
import type { User } from "@auth/core/types"
import type { FeedModel, ListModelPoplutedFeeds } from "./types"
import type { FeedModel, ListModelPoplutedFeeds, UserModel } from "./types"
export * from "./types"
@ -22,7 +20,7 @@ export namespace Models {
trendingFeeds: FeedModel[]
trendingLists: ListModelPoplutedFeeds[]
trendingEntries: TrendingEntry[]
trendingUsers: User[]
trendingUsers: UserModel[]
}
export interface TrendingEntry {

View File

@ -431,6 +431,9 @@ importers:
specifier: npm:@vscode/vscode-languagedetection@1.0.22
version: '@vscode/vscode-languagedetection@1.0.22'
devDependencies:
'@follow/models':
specifier: workspace:*
version: link:../../../../packages/models
'@follow/types':
specifier: workspace:*
version: link:../../../../packages/types
@ -1467,9 +1470,6 @@ importers:
packages/models:
dependencies:
'@auth/core':
specifier: 0.37.4
version: 0.37.4
'@follow/constants':
specifier: workspace:*
version: link:../constants
@ -1599,20 +1599,6 @@ packages:
peerDependencies:
ajv: '>=8'
'@auth/core@0.37.4':
resolution: {integrity: sha512-HOXJwXWXQRhbBDHlMU0K/6FT1v+wjtzdKhsNg0ZN7/gne6XPsIrjZ4daMcFnbq0Z/vsAbYBinQhhua0d77v7qw==}
peerDependencies:
'@simplewebauthn/browser': ^9.0.1
'@simplewebauthn/server': ^9.0.2
nodemailer: ^6.8.0
peerDependenciesMeta:
'@simplewebauthn/browser':
optional: true
'@simplewebauthn/server':
optional: true
nodemailer:
optional: true
'@babel/cli@7.26.4':
resolution: {integrity: sha512-+mORf3ezU3p3qr+82WvJSnQNE1GAYeoCfEv4fik6B5/2cvKZ75AX8oawWQdXtM9MmndooQj15Jr9kelRFWsuRw==}
engines: {node: '>=6.9.0'}
@ -2466,7 +2452,7 @@ packages:
'@egoist/tipc@0.3.2':
resolution: {integrity: sha512-p8g35BhErVkYIgDqkw/HQJSli1TOsZRIUU9U7PYnYfwru6J/Ep1lwFGH2N6+sQMFi1HkqGTTUlJEISJ1DClfQw==}
peerDependencies:
electron: '>=26.0.0'
electron: 34.2.0
'@electron-forge/cli@7.7.0':
resolution: {integrity: sha512-QfnjghmlHMb7dyArR5cbPA+MP9ff/ulWZi6R/a5MkHlKyhrysRfjzDtZDsmkEv9mGQgRwylssgXrZrKHGlxFkw==}
@ -2550,7 +2536,7 @@ packages:
'@electron-toolkit/preload@3.0.1':
resolution: {integrity: sha512-EzoQmpK8jqqU8YnM5jRe0GJjGVJPke2KtANqz8QtN2JPT96ViOvProBdK5C6riCm0j1T8jjAGVQCZLQy9OVoIA==}
peerDependencies:
electron: '>=13.0.0'
electron: 34.2.0
'@electron-toolkit/tsconfig@1.0.1':
resolution: {integrity: sha512-M0Mol3odspvtCuheyujLNAW7bXq7KFNYVMRtpjFa4ZfES4MuklXBC7Nli/omvc+PRKlrklgAGx3l4VakjNo8jg==}
@ -4527,9 +4513,6 @@ packages:
peerDependencies:
'@opentelemetry/api': ^1.1.0
'@panva/hkdf@1.2.1':
resolution: {integrity: sha512-6oclG6Y3PiDFcoyk8srjLfVKyMfVCKJ27JwNPViuXziFpmdz+MZnZN/aKY0JGXgYuO/VghU0jcOAZgWXZ1Dmrw==}
'@peculiar/asn1-android@2.3.15':
resolution: {integrity: sha512-8U2TIj59cRlSXTX2d0mzUKP7whfWGFMzTeC3qPgAbccXFrPNZLaDhpNEdG5U2QZ/tBv/IHlCJ8s+KYXpJeop6w==}
@ -4678,7 +4661,7 @@ packages:
'@radix-ui/react-compose-refs@1.1.1':
resolution: {integrity: sha512-Y9VzoRDSJtgFMUCoiZBDVo084VQ5hfpXxVE+NgkdNsjiDBByiImMZKKhxMwCbdHvhlENG6a833CbFkOQvTricw==}
peerDependencies:
'@types/react': '*'
'@types/react': npm:@types/react@18.3.12
react: 18.3.1
peerDependenciesMeta:
'@types/react':
@ -4700,7 +4683,7 @@ packages:
'@radix-ui/react-context@1.1.1':
resolution: {integrity: sha512-UASk9zi+crv9WteK/NU4PLvOoL3OuE6BWVKNF6hPRBtYBDXQ2u5iu3O59zUlJiTVvkyuycnqrztsHVJwcK9K+Q==}
peerDependencies:
'@types/react': '*'
'@types/react': npm:@types/react@18.3.12
react: 18.3.1
peerDependenciesMeta:
'@types/react':
@ -4757,7 +4740,7 @@ packages:
'@radix-ui/react-focus-guards@1.1.1':
resolution: {integrity: sha512-pSIwfrT1a6sIoDASCSpFwOasEwKTZWDw/iBdtnqKO7v6FeOzYJ7U53cPzYFVR3geGGXgVHaH+CdngrrAzqUGxg==}
peerDependencies:
'@types/react': '*'
'@types/react': npm:@types/react@18.3.12
react: 18.3.1
peerDependenciesMeta:
'@types/react':
@ -5045,7 +5028,7 @@ packages:
'@radix-ui/react-use-controllable-state@1.1.0':
resolution: {integrity: sha512-MtfMVJiSr2NjzS0Aa90NPTnvTSg6C/JLCV7ma0W6+OMV78vd8OyRpID+Ng9LxzsPbLeuBnWBA1Nq30AtBIDChw==}
peerDependencies:
'@types/react': '*'
'@types/react': npm:@types/react@18.3.12
react: 18.3.1
peerDependenciesMeta:
'@types/react':
@ -12113,9 +12096,6 @@ packages:
engines: {node: ^14.16.0 || >=16.10.0}
hasBin: true
oauth4webapi@3.3.1:
resolution: {integrity: sha512-ZwX7UqYrP3Lr+Glhca3a1/nF2jqf7VVyJfhGuW5JtrfDUxt0u+IoBPzFjZ2dd7PJGkdM6CFPVVYzuDYKHv101A==}
ob1@0.81.3:
resolution: {integrity: sha512-wd8zdH0DWsn2iDVn2zT/QURihcqoc73K8FhNCmQ16qkJaoYJLNb/N+huOwdCgsbNP8Lk/s1+dPnDETx+RzsrWA==}
engines: {node: '>=18.18'}
@ -12882,14 +12862,6 @@ packages:
engines: {node: '>=14.0.0'}
hasBin: true
preact-render-to-string@6.5.11:
resolution: {integrity: sha512-ubnauqoGczeGISiOh6RjX0/cdaF8v/oDXIjO85XALCQjwQP+SB4RDXXtvZ6yTYSjG+PC1QRP2AhPgCEsM2EvUw==}
peerDependencies:
preact: '>=10'
preact@10.24.3:
resolution: {integrity: sha512-Z2dPnBnMUfyQfSQ+GBdsGa16hz35YmLmtTLhM169uW944hYL6xzTYkJjC07j+Wosz733pMWx0fgON3JNw1jJQA==}
preact@10.26.4:
resolution: {integrity: sha512-KJhO7LBFTjP71d83trW+Ilnjbo+ySsaAgCfXOXUlmGzJ4ygYPWmysm77yg4emwfmoz3b22yvH5IsVFHbhUaH5w==}
@ -15961,14 +15933,6 @@ snapshots:
jsonpointer: 5.0.1(patch_hash=prxuhlhyjugus5tiew4vc3pahu)
leven: 3.1.0
'@auth/core@0.37.4':
dependencies:
'@panva/hkdf': 1.2.1
jose: 5.10.0
oauth4webapi: 3.3.1
preact: 10.24.3
preact-render-to-string: 6.5.11(preact@10.24.3)
'@babel/cli@7.26.4(@babel/core@7.26.10)':
dependencies:
'@babel/core': 7.26.10
@ -17909,7 +17873,7 @@ snapshots:
'@expo/env': 0.4.2
'@expo/image-utils': 0.6.5
'@expo/json-file': 9.0.2
'@expo/metro-config': 0.19.12
'@expo/metro-config': 0.19.10
'@expo/osascript': 2.1.6
'@expo/package-manager': 1.7.2
'@expo/plist': 0.2.2
@ -20156,8 +20120,6 @@ snapshots:
'@opentelemetry/api': 1.9.0
'@opentelemetry/core': 1.30.1(@opentelemetry/api@1.9.0)
'@panva/hkdf@1.2.1': {}
'@peculiar/asn1-android@2.3.15':
dependencies:
'@peculiar/asn1-schema': 2.3.15
@ -29891,8 +29853,6 @@ snapshots:
tinyexec: 0.3.2
ufo: 1.5.4
oauth4webapi@3.3.1: {}
ob1@0.81.3:
dependencies:
flow-enums-runtime: 0.0.6
@ -30793,12 +30753,6 @@ snapshots:
dependencies:
commander: 9.5.0
preact-render-to-string@6.5.11(preact@10.24.3):
dependencies:
preact: 10.24.3
preact@10.24.3: {}
preact@10.26.4: {}
prebuild-install@7.1.3: