mirror of
https://github.com/ThaUnknown/miru.git
synced 2026-03-11 21:16:12 +00:00
fix: revert in-world torrent port
This commit is contained in:
parent
cbe5392d5f
commit
132b805ff3
5 changed files with 6 additions and 118 deletions
61
nocheck.ts
61
nocheck.ts
|
|
@ -1,61 +0,0 @@
|
||||||
import fs from 'node:fs'
|
|
||||||
import path from 'node:path'
|
|
||||||
import process from 'node:process'
|
|
||||||
|
|
||||||
import { glob } from 'glob'
|
|
||||||
|
|
||||||
const TS_NOCHECK_STRING = '// @ts-nocheck\n\n'
|
|
||||||
|
|
||||||
const main = (args: string[]) => {
|
|
||||||
/**
|
|
||||||
* glob patterns
|
|
||||||
*/
|
|
||||||
const patterns = args[0]!.split(',')
|
|
||||||
.map((pattern) => pattern.trim())
|
|
||||||
.filter(Boolean)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ['path/to/file.ts', 'path/to/file2.ts']
|
|
||||||
*/
|
|
||||||
const files = patterns.flatMap((pattern) =>
|
|
||||||
glob.sync(pattern)
|
|
||||||
)
|
|
||||||
|
|
||||||
const addTsNoCheck = async (file: string) => {
|
|
||||||
const resolvedFilePath = path.resolve(process.cwd(), file)
|
|
||||||
|
|
||||||
const content = fs.readFileSync(resolvedFilePath).toString()
|
|
||||||
|
|
||||||
if (content.includes(TS_NOCHECK_STRING)) {
|
|
||||||
console.log(
|
|
||||||
JSON.stringify(TS_NOCHECK_STRING),
|
|
||||||
'is already in',
|
|
||||||
resolvedFilePath
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
fs.writeFileSync(resolvedFilePath, TS_NOCHECK_STRING + content)
|
|
||||||
console.log(
|
|
||||||
JSON.stringify(TS_NOCHECK_STRING),
|
|
||||||
'added into',
|
|
||||||
resolvedFilePath
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Promise.allSettled(files.map(addTsNoCheck)).then((results) => {
|
|
||||||
let hasErrors = false
|
|
||||||
|
|
||||||
results.forEach((result) => {
|
|
||||||
if (result.status === 'rejected') {
|
|
||||||
hasErrors = true
|
|
||||||
console.error(result.reason)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
if (hasErrors) {
|
|
||||||
process.exit(1)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
main(process.argv.slice(2))
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "ui",
|
"name": "ui",
|
||||||
"version": "6.4.113",
|
"version": "6.4.114",
|
||||||
"license": "BUSL-1.1",
|
"license": "BUSL-1.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"packageManager": "pnpm@9.15.5",
|
"packageManager": "pnpm@9.15.5",
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
"dev": "vite dev --open",
|
"dev": "vite dev --open",
|
||||||
"build": "vite build && scopy ./build/index.html ./build/offline.html",
|
"build": "vite build && scopy ./build/index.html ./build/offline.html",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"sync": "svelte-kit sync && node --experimental-strip-types nocheck.ts \"node_modules/**/torrent-client/*.ts\"",
|
"sync": "svelte-kit sync",
|
||||||
"check": "svelte-check --threshold error --tsconfig ./tsconfig.web.json",
|
"check": "svelte-check --threshold error --tsconfig ./tsconfig.web.json",
|
||||||
"check:watch": "svelte-check -threshold error --tsconfig ./tsconfig.web.json --watch",
|
"check:watch": "svelte-check -threshold error --tsconfig ./tsconfig.web.json --watch",
|
||||||
"test": "pnpm run sync && pnpm run lint && pnpm run gql:check && pnpm run check",
|
"test": "pnpm run sync && pnpm run lint && pnpm run gql:check && pnpm run check",
|
||||||
|
|
@ -30,7 +30,6 @@
|
||||||
"bits-ui": "^0.22.0",
|
"bits-ui": "^0.22.0",
|
||||||
"cmdk-sv": "^0.0.19",
|
"cmdk-sv": "^0.0.19",
|
||||||
"eslint-config-standard-universal": "^1.0.9",
|
"eslint-config-standard-universal": "^1.0.9",
|
||||||
"glob": "^11.0.3",
|
|
||||||
"gql.tada": "^1.8.13",
|
"gql.tada": "^1.8.13",
|
||||||
"hayase-extensions": "github:hayase-app/extensions",
|
"hayase-extensions": "github:hayase-app/extensions",
|
||||||
"jassub": "^1.8.6",
|
"jassub": "^1.8.6",
|
||||||
|
|
@ -43,7 +42,6 @@
|
||||||
"svelte-radix": "^1.1.1",
|
"svelte-radix": "^1.1.1",
|
||||||
"svelte-sonner": "^0.3.28",
|
"svelte-sonner": "^0.3.28",
|
||||||
"tailwindcss": "^3.4.17",
|
"tailwindcss": "^3.4.17",
|
||||||
"torrent-client": "github:hayase-app/torrent-client",
|
|
||||||
"typescript": "^5.9.2",
|
"typescript": "^5.9.2",
|
||||||
"vaul-svelte": "^0.3.2",
|
"vaul-svelte": "^0.3.2",
|
||||||
"vite": "^5.4.11",
|
"vite": "^5.4.11",
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import SUPPORTS from './settings/supports'
|
||||||
|
|
||||||
import type { AuthResponse, Native, TorrentInfo } from 'native'
|
import type { AuthResponse, Native, TorrentInfo } from 'native'
|
||||||
|
|
||||||
import electron from '$lib/modules/torrent/electron'
|
|
||||||
import { sleep } from '$lib/utils'
|
import { sleep } from '$lib/utils'
|
||||||
|
|
||||||
const rnd = (range = 100) => Math.floor(Math.random() * range)
|
const rnd = (range = 100) => Math.floor(Math.random() * range)
|
||||||
|
|
@ -51,7 +50,7 @@ const dummyFiles = [
|
||||||
// dummyPeerInfo.push(makeRandomPeer())
|
// dummyPeerInfo.push(makeRandomPeer())
|
||||||
// }
|
// }
|
||||||
|
|
||||||
const native: Native = {
|
export default Object.assign<Native, Partial<Native>>({
|
||||||
authAL: (url: string) => {
|
authAL: (url: string) => {
|
||||||
return new Promise<AuthResponse>((resolve, reject) => {
|
return new Promise<AuthResponse>((resolve, reject) => {
|
||||||
const popup = open(url, 'authframe', SUPPORTS.isAndroid ? 'popup' : 'popup,width=382,height=582')
|
const popup = open(url, 'authframe', SUPPORTS.isAndroid ? 'popup' : 'popup,width=382,height=582')
|
||||||
|
|
@ -163,10 +162,6 @@ const native: Native = {
|
||||||
defaultTransparency: () => false,
|
defaultTransparency: () => false,
|
||||||
errors: async () => undefined,
|
errors: async () => undefined,
|
||||||
debug: async () => undefined,
|
debug: async () => undefined,
|
||||||
profile: async () => undefined,
|
profile: async () => undefined
|
||||||
// @ts-expect-error idk
|
// @ts-expect-error idk
|
||||||
...globalThis.native as Partial<Native>,
|
}, globalThis.native as Partial<Native>)
|
||||||
...electron
|
|
||||||
}
|
|
||||||
|
|
||||||
export default native
|
|
||||||
|
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
||||||
import { proxy, type Remote } from 'abslink'
|
|
||||||
import { wrap } from 'abslink/w3c'
|
|
||||||
|
|
||||||
import type { Native } from 'native'
|
|
||||||
import type TorrentClient from 'torrent-client'
|
|
||||||
|
|
||||||
const torrent = new Promise<Remote<TorrentClient>>(resolve => {
|
|
||||||
window.addEventListener('message', ({ data, ports, source }) => {
|
|
||||||
if (data === 'TORRENT_PORT' && ports[0] && source === window) {
|
|
||||||
ports[0].start()
|
|
||||||
resolve(wrap<TorrentClient>(ports[0]) as unknown as Remote<TorrentClient>)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
// @ts-expect-error custom
|
|
||||||
window.sendPort?.()
|
|
||||||
})
|
|
||||||
|
|
||||||
const electronNative: Partial<Native> =
|
|
||||||
// @ts-expect-error custom
|
|
||||||
window.sendPort
|
|
||||||
? {
|
|
||||||
checkAvailableSpace: async () => await (await torrent).checkAvailableSpace(),
|
|
||||||
checkIncomingConnections: async (port) => await (await torrent).checkIncomingConnections(port),
|
|
||||||
updatePeerCounts: async (hashes) => await (await torrent).scrape(hashes),
|
|
||||||
playTorrent: async (id, mediaID, episode) => await (await torrent).playTorrent(id, mediaID, episode),
|
|
||||||
rescanTorrents: async (hashes) => await (await torrent).rescanTorrents(hashes),
|
|
||||||
deleteTorrents: async (hashes) => await (await torrent).deleteTorrents(hashes),
|
|
||||||
library: async () => await (await torrent).library(),
|
|
||||||
attachments: async (hash, id) => await (await torrent).attachments.attachments(hash, id),
|
|
||||||
tracks: async (hash, id) => await (await torrent).attachments.tracks(hash, id),
|
|
||||||
subtitles: async (hash, id, cb) => await (await torrent).attachments.subtitle(hash, id, proxy(cb)),
|
|
||||||
errors: async (cb) => await (await torrent).errors(proxy(cb)),
|
|
||||||
chapters: async (hash, id) => await (await torrent).attachments.chapters(hash, id),
|
|
||||||
torrentInfo: async (hash) => await (await torrent).torrentInfo(hash),
|
|
||||||
peerInfo: async (hash) => await (await torrent).peerInfo(hash),
|
|
||||||
fileInfo: async (hash) => await (await torrent).fileInfo(hash),
|
|
||||||
protocolStatus: async (hash) => await (await torrent).protocolStatus(hash),
|
|
||||||
cachedTorrents: async () => await (await torrent).cached(),
|
|
||||||
debug: async (levels) => await (await torrent).debug(levels)
|
|
||||||
}
|
|
||||||
: {}
|
|
||||||
|
|
||||||
export default electronNative
|
|
||||||
|
|
@ -42,8 +42,7 @@
|
||||||
"generateALIntrospection.ts",
|
"generateALIntrospection.ts",
|
||||||
"src/types/**/*.d.ts",
|
"src/types/**/*.d.ts",
|
||||||
"postcss.config.js",
|
"postcss.config.js",
|
||||||
"tsconfig.web.json",
|
"tsconfig.web.json"
|
||||||
"nocheck.ts"
|
|
||||||
],
|
],
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"../node_modules/**"
|
"../node_modules/**"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue