mirror of
https://github.com/Andre-Bzk/twitch4steamdeck.git
synced 2026-11-15 15:43:08 +01:00
refactor: consolidate IPC types into src/shared/types.ts
The 12 cross-process data types were manually copied across src/preload/index.ts and src/renderer/src/types/t4sd.d.ts. A silent field addition or rename in either file would not produce a compile error in the other — the divergence only surfaces at runtime. A shared module makes the compiler enforce consistency. Preload imports from shared/types and re-exports for downstream consumers. The renderer's t4sd.d.ts re-exports the same types from shared/types, so all existing screen imports continue to work without modification. Both tsconfigs are extended to include src/shared so the module is reachable from both composite projects.
This commit is contained in:
@@ -8,10 +8,4 @@ export type Quality =
|
|||||||
| 'audio_only'
|
| 'audio_only'
|
||||||
| 'worst'
|
| 'worst'
|
||||||
|
|
||||||
export interface PlaybackEvent {
|
export type { PlaybackEvent } from '../../shared/types'
|
||||||
kind: 'started' | 'stopped' | 'error'
|
|
||||||
channelLogin?: string
|
|
||||||
message?: string
|
|
||||||
durationSeconds?: number
|
|
||||||
isLive?: boolean
|
|
||||||
}
|
|
||||||
|
|||||||
+27
-85
@@ -1,91 +1,33 @@
|
|||||||
import { contextBridge, ipcRenderer, type IpcRendererEvent } from 'electron'
|
import { contextBridge, ipcRenderer, type IpcRendererEvent } from 'electron'
|
||||||
import { IPC } from '../main/ipc/channels'
|
import { IPC } from '../main/ipc/channels'
|
||||||
|
import type {
|
||||||
|
AuthStatus,
|
||||||
|
DeviceFlowStartInfo,
|
||||||
|
AuthEvent,
|
||||||
|
FollowedChannelInfo,
|
||||||
|
OwnUserInfo,
|
||||||
|
PlaybackEvent,
|
||||||
|
HlsUrlPayload,
|
||||||
|
GameInfo,
|
||||||
|
VodInfo,
|
||||||
|
VodProgress,
|
||||||
|
VodChapter,
|
||||||
|
TopStreamsResult
|
||||||
|
} from '../shared/types'
|
||||||
|
|
||||||
export type AuthStatus = 'logged-out' | 'logged-in'
|
export type {
|
||||||
|
AuthStatus,
|
||||||
export interface DeviceFlowStartInfo {
|
DeviceFlowStartInfo,
|
||||||
userCode: string
|
AuthEvent,
|
||||||
verificationUri: string
|
FollowedChannelInfo,
|
||||||
expiresInSec: number
|
OwnUserInfo,
|
||||||
}
|
PlaybackEvent,
|
||||||
|
HlsUrlPayload,
|
||||||
export type AuthEvent =
|
GameInfo,
|
||||||
| { kind: 'authorized' }
|
VodInfo,
|
||||||
| { kind: 'denied' }
|
VodProgress,
|
||||||
| { kind: 'expired' }
|
VodChapter,
|
||||||
| { kind: 'cancelled' }
|
TopStreamsResult
|
||||||
| { kind: 'error'; message: string }
|
|
||||||
|
|
||||||
export interface FollowedChannelInfo {
|
|
||||||
broadcasterId: string
|
|
||||||
broadcasterLogin: string
|
|
||||||
broadcasterName: string
|
|
||||||
profileImageUrl: string
|
|
||||||
isLive: boolean
|
|
||||||
streamTitle?: string
|
|
||||||
gameId?: string
|
|
||||||
gameName?: string
|
|
||||||
viewerCount?: number
|
|
||||||
thumbnailUrl?: string
|
|
||||||
startedAt?: string
|
|
||||||
language?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface OwnUserInfo {
|
|
||||||
id: string
|
|
||||||
login: string
|
|
||||||
displayName: string
|
|
||||||
profileImageUrl: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface PlaybackEvent {
|
|
||||||
kind: 'started' | 'stopped' | 'error'
|
|
||||||
channelLogin?: string
|
|
||||||
message?: string
|
|
||||||
durationSeconds?: number
|
|
||||||
isLive?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface HlsUrlPayload {
|
|
||||||
url: string
|
|
||||||
isLive: boolean
|
|
||||||
startPosition: number
|
|
||||||
durationSeconds: number
|
|
||||||
vodId?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface GameInfo {
|
|
||||||
id: string
|
|
||||||
name: string
|
|
||||||
boxArtUrl: string
|
|
||||||
viewerCount?: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface VodInfo {
|
|
||||||
id: string
|
|
||||||
title: string
|
|
||||||
createdAt: string
|
|
||||||
durationSeconds: number
|
|
||||||
viewCount: number
|
|
||||||
thumbnailUrl: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface VodProgress {
|
|
||||||
resumePositionSeconds: number
|
|
||||||
watchedAt: number
|
|
||||||
completed: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface VodChapter {
|
|
||||||
positionSeconds: number
|
|
||||||
durationSeconds: number
|
|
||||||
gameName: string
|
|
||||||
gameId: string | null
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TopStreamsResult {
|
|
||||||
streams: FollowedChannelInfo[]
|
|
||||||
cursor?: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const api = {
|
const api = {
|
||||||
|
|||||||
Vendored
+32
-87
@@ -1,92 +1,37 @@
|
|||||||
// Spiegel der Preload-API. Manuell synchron halten zu src/preload/index.ts.
|
// Data types: src/shared/types.ts (canonical source, compiler-enforced).
|
||||||
// IPC-Channel-Namen: src/main/ipc/channels.ts (Renderer kann nicht direkt importieren).
|
// T4sdApi: keep manually in sync with src/preload/index.ts.
|
||||||
|
// Direct import is not possible: tsconfig.web.json and tsconfig.node.json are separate
|
||||||
|
// composite projects — preload/index.ts is not reachable from the renderer build.
|
||||||
|
|
||||||
export type AuthStatus = 'logged-out' | 'logged-in'
|
export type {
|
||||||
|
AuthStatus,
|
||||||
|
DeviceFlowStartInfo,
|
||||||
|
AuthEvent,
|
||||||
|
FollowedChannelInfo,
|
||||||
|
OwnUserInfo,
|
||||||
|
PlaybackEvent,
|
||||||
|
HlsUrlPayload,
|
||||||
|
GameInfo,
|
||||||
|
VodInfo,
|
||||||
|
VodProgress,
|
||||||
|
VodChapter,
|
||||||
|
TopStreamsResult
|
||||||
|
} from '../../../shared/types'
|
||||||
|
|
||||||
export interface DeviceFlowStartInfo {
|
import type {
|
||||||
userCode: string
|
AuthStatus,
|
||||||
verificationUri: string
|
DeviceFlowStartInfo,
|
||||||
expiresInSec: number
|
AuthEvent,
|
||||||
}
|
FollowedChannelInfo,
|
||||||
|
OwnUserInfo,
|
||||||
export type AuthEvent =
|
PlaybackEvent,
|
||||||
| { kind: 'authorized' }
|
HlsUrlPayload,
|
||||||
| { kind: 'denied' }
|
GameInfo,
|
||||||
| { kind: 'expired' }
|
VodInfo,
|
||||||
| { kind: 'cancelled' }
|
VodProgress,
|
||||||
| { kind: 'error'; message: string }
|
VodChapter,
|
||||||
|
TopStreamsResult
|
||||||
export interface FollowedChannelInfo {
|
} from '../../../shared/types'
|
||||||
broadcasterId: string
|
|
||||||
broadcasterLogin: string
|
|
||||||
broadcasterName: string
|
|
||||||
profileImageUrl: string
|
|
||||||
isLive: boolean
|
|
||||||
streamTitle?: string
|
|
||||||
gameId?: string
|
|
||||||
gameName?: string
|
|
||||||
viewerCount?: number
|
|
||||||
thumbnailUrl?: string
|
|
||||||
startedAt?: string
|
|
||||||
language?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface OwnUserInfo {
|
|
||||||
id: string
|
|
||||||
login: string
|
|
||||||
displayName: string
|
|
||||||
profileImageUrl: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface GameInfo {
|
|
||||||
id: string
|
|
||||||
name: string
|
|
||||||
boxArtUrl: string
|
|
||||||
viewerCount?: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface PlaybackEvent {
|
|
||||||
kind: 'started' | 'stopped' | 'error'
|
|
||||||
channelLogin?: string
|
|
||||||
message?: string
|
|
||||||
durationSeconds?: number
|
|
||||||
isLive?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface HlsUrlPayload {
|
|
||||||
url: string
|
|
||||||
isLive: boolean
|
|
||||||
startPosition: number
|
|
||||||
durationSeconds: number
|
|
||||||
vodId?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface VodInfo {
|
|
||||||
id: string
|
|
||||||
title: string
|
|
||||||
createdAt: string
|
|
||||||
durationSeconds: number
|
|
||||||
viewCount: number
|
|
||||||
thumbnailUrl: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface VodProgress {
|
|
||||||
resumePositionSeconds: number
|
|
||||||
watchedAt: number
|
|
||||||
completed: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface VodChapter {
|
|
||||||
positionSeconds: number
|
|
||||||
durationSeconds: number
|
|
||||||
gameName: string
|
|
||||||
gameId: string | null
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TopStreamsResult {
|
|
||||||
streams: FollowedChannelInfo[]
|
|
||||||
cursor?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface T4sdApi {
|
export interface T4sdApi {
|
||||||
appVersion: string
|
appVersion: string
|
||||||
|
|||||||
@@ -0,0 +1,86 @@
|
|||||||
|
export type AuthStatus = 'logged-out' | 'logged-in'
|
||||||
|
|
||||||
|
export interface DeviceFlowStartInfo {
|
||||||
|
userCode: string
|
||||||
|
verificationUri: string
|
||||||
|
expiresInSec: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export type AuthEvent =
|
||||||
|
| { kind: 'authorized' }
|
||||||
|
| { kind: 'denied' }
|
||||||
|
| { kind: 'expired' }
|
||||||
|
| { kind: 'cancelled' }
|
||||||
|
| { kind: 'error'; message: string }
|
||||||
|
|
||||||
|
export interface FollowedChannelInfo {
|
||||||
|
broadcasterId: string
|
||||||
|
broadcasterLogin: string
|
||||||
|
broadcasterName: string
|
||||||
|
profileImageUrl: string
|
||||||
|
isLive: boolean
|
||||||
|
streamTitle?: string
|
||||||
|
gameId?: string
|
||||||
|
gameName?: string
|
||||||
|
viewerCount?: number
|
||||||
|
thumbnailUrl?: string
|
||||||
|
startedAt?: string
|
||||||
|
language?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface OwnUserInfo {
|
||||||
|
id: string
|
||||||
|
login: string
|
||||||
|
displayName: string
|
||||||
|
profileImageUrl: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PlaybackEvent {
|
||||||
|
kind: 'started' | 'stopped' | 'error'
|
||||||
|
channelLogin?: string
|
||||||
|
message?: string
|
||||||
|
durationSeconds?: number
|
||||||
|
isLive?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface HlsUrlPayload {
|
||||||
|
url: string
|
||||||
|
isLive: boolean
|
||||||
|
startPosition: number
|
||||||
|
durationSeconds: number
|
||||||
|
vodId?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GameInfo {
|
||||||
|
id: string
|
||||||
|
name: string
|
||||||
|
boxArtUrl: string
|
||||||
|
viewerCount?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface VodInfo {
|
||||||
|
id: string
|
||||||
|
title: string
|
||||||
|
createdAt: string
|
||||||
|
durationSeconds: number
|
||||||
|
viewCount: number
|
||||||
|
thumbnailUrl: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface VodProgress {
|
||||||
|
resumePositionSeconds: number
|
||||||
|
watchedAt: number
|
||||||
|
completed: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface VodChapter {
|
||||||
|
positionSeconds: number
|
||||||
|
durationSeconds: number
|
||||||
|
gameName: string
|
||||||
|
gameId: string | null
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TopStreamsResult {
|
||||||
|
streams: FollowedChannelInfo[]
|
||||||
|
cursor?: string
|
||||||
|
}
|
||||||
+2
-1
@@ -20,6 +20,7 @@
|
|||||||
"src/main/**/*.ts",
|
"src/main/**/*.ts",
|
||||||
"src/main/**/*.d.ts",
|
"src/main/**/*.d.ts",
|
||||||
"src/preload/**/*.ts",
|
"src/preload/**/*.ts",
|
||||||
"src/preload/**/*.d.ts"
|
"src/preload/**/*.d.ts",
|
||||||
|
"src/shared/**/*.ts"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-1
@@ -17,5 +17,9 @@
|
|||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"allowSyntheticDefaultImports": true
|
"allowSyntheticDefaultImports": true
|
||||||
},
|
},
|
||||||
"include": ["src/renderer/**/*.ts", "src/renderer/**/*.tsx"]
|
"include": [
|
||||||
|
"src/renderer/**/*.ts",
|
||||||
|
"src/renderer/**/*.tsx",
|
||||||
|
"src/shared/**/*.ts"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user