pull/134/head
Alex Kern 12 months ago
parent 98c6221b0d
commit 38125b42f9
No known key found for this signature in database
GPG Key ID: EF051FACCACBEE25

@ -1,37 +0,0 @@
'use strict';
module.exports = {
root: true,
parser: "@typescript-eslint/parser",
parserOptions: {
project: './tsconfig.json',
},
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@next/next/recommended"
],
plugins: [
"@typescript-eslint",
],
rules: {
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
"@typescript-eslint/no-use-before-define": ["error", { "variables": false }],
"@typescript-eslint/promise-function-async": "off",
"@typescript-eslint/require-await": "off",
"@typescript-eslint/no-explicit-any": "warn",
"import/no-unused-modules": "off",
"import/group-exports": "off",
"import/no-extraneous-dependencies": "off",
"new-cap": "off",
"no-inline-comments": "off",
"no-shadow": "warn",
"no-use-before-define": "off",
},
ignores: [
'legacy/',
'node_modules/',
'.next/'
]
};

@ -0,0 +1,33 @@
// @ts-check
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
export default tseslint.config({
extends: [
eslint.configs.recommended,
tseslint.configs.recommended,
],
rules: {
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_' },
],
'@typescript-eslint/no-use-before-define': [
'error',
{ variables: false },
],
'@typescript-eslint/promise-function-async': 'off',
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/no-explicit-any': 'warn',
'import/no-unused-modules': 'off',
'import/group-exports': 'off',
'import/no-extraneous-dependencies': 'off',
'new-cap': 'off',
'no-inline-comments': 'off',
'no-shadow': 'warn',
'no-use-before-define': 'off',
},
files: ['src/**/*.ts[x]'],
ignores: ['legacy', 'node_modules', '.next'],
});

@ -10,8 +10,8 @@
"build": "next build",
"start": "next start",
"start:peerjs": "./bin/peerjs.js",
"lint:check": "eslint 'app/**/*.ts[x]'",
"lint:fix": "eslint 'app/**/*.ts[x]' --fix",
"lint:check": "eslint 'src/**/*.ts[x]'",
"lint:fix": "eslint 'src/**/*.ts[x]' --fix",
"docker:build": "docker compose build",
"docker:up": "docker compose up -d",
"docker:down": "docker compose down",
@ -68,7 +68,8 @@
"husky": "^4.3.8",
"lint-staged": "^10.5.4",
"prettier": "^2.8.8",
"typescript": "^4.9.5"
"typescript": "^4.9.5",
"typescript-eslint": "^8.18.2"
},
"husky": {
"hooks": {

@ -112,6 +112,9 @@ devDependencies:
typescript:
specifier: ^4.9.5
version: 4.9.5
typescript-eslint:
specifier: ^8.18.2
version: 8.18.2(eslint@9.17.0)(typescript@4.9.5)
packages:
@ -5804,6 +5807,22 @@ packages:
reflect.getprototypeof: 1.0.6
dev: true
/typescript-eslint@8.18.2(eslint@9.17.0)(typescript@4.9.5):
resolution: {integrity: sha512-KuXezG6jHkvC3MvizeXgupZzaG5wjhU3yE8E7e6viOvAvD9xAWYp8/vy0WULTGe9DYDWcQu7aW03YIV3mSitrQ==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
eslint: ^8.57.0 || ^9.0.0
typescript: '>=4.8.4 <5.8.0'
dependencies:
'@typescript-eslint/eslint-plugin': 8.18.2(@typescript-eslint/parser@8.18.2)(eslint@9.17.0)(typescript@4.9.5)
'@typescript-eslint/parser': 8.18.2(eslint@9.17.0)(typescript@4.9.5)
'@typescript-eslint/utils': 8.18.2(eslint@9.17.0)(typescript@4.9.5)
eslint: 9.17.0
typescript: 4.9.5
transitivePeerDependencies:
- supports-color
dev: true
/typescript@4.9.5:
resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==}
engines: {node: '>=4.2.0'}

@ -11,8 +11,6 @@ export async function POST(request: Request): Promise<NextResponse> {
)
}
const channel = await getOrCreateChannelRepo().createChannel(
uploaderPeerID,
)
const channel = await getOrCreateChannelRepo().createChannel(uploaderPeerID)
return NextResponse.json(channel)
}

@ -35,16 +35,16 @@ export default function RootLayout({
<ViewTransitions>
<html lang="en" suppressHydrationWarning>
<head>
<meta name="monetization" content="$twitter.xrptipbot.com/kernio" />
</head>
<body>
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>
<FilePizzaQueryClientProvider>
<main>{children}</main>
<Footer />
<ModeToggle />
</FilePizzaQueryClientProvider>
</ThemeProvider>
<meta name="monetization" content="$twitter.xrptipbot.com/kernio" />
</head>
<body>
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>
<FilePizzaQueryClientProvider>
<main>{children}</main>
<Footer />
<ModeToggle />
</FilePizzaQueryClientProvider>
</ThemeProvider>
</body>
</html>
</ViewTransitions>

@ -34,7 +34,9 @@ function getLongSlugKey(longSlug: string): string {
return `long:${longSlug}`
}
async function generateShortSlugUntilUnique(checkExists: (key: string) => Promise<boolean>): Promise<string> {
async function generateShortSlugUntilUnique(
checkExists: (key: string) => Promise<boolean>,
): Promise<string> {
for (let i = 0; i < config.shortSlug.maxAttempts; i++) {
const slug = generateShortSlug()
const exists = await checkExists(getShortSlugKey(slug))
@ -46,7 +48,9 @@ async function generateShortSlugUntilUnique(checkExists: (key: string) => Promis
throw new Error('max attempts reached generating short slug')
}
async function generateLongSlugUntilUnique(checkExists: (key: string) => Promise<boolean>): Promise<string> {
async function generateLongSlugUntilUnique(
checkExists: (key: string) => Promise<boolean>,
): Promise<string> {
for (let i = 0; i < config.longSlug.maxAttempts; i++) {
const slug = await generateLongSlug()
const exists = await checkExists(getLongSlugKey(slug))
@ -100,11 +104,11 @@ export class MemoryChannelRepo implements ChannelRepo {
uploaderPeerID: string,
ttl: number = config.channel.ttl,
): Promise<Channel> {
const shortSlug = await generateShortSlugUntilUnique(
async (key) => this.channels.has(key),
const shortSlug = await generateShortSlugUntilUnique(async (key) =>
this.channels.has(key),
)
const longSlug = await generateLongSlugUntilUnique(
async (key) => this.channels.has(key),
const longSlug = await generateLongSlugUntilUnique(async (key) =>
this.channels.has(key),
)
const channel: Channel = {
@ -136,7 +140,7 @@ export class MemoryChannelRepo implements ChannelRepo {
const shortKey = getShortSlugKey(slug)
const shortChannel = this.channels.get(shortKey)
if (shortChannel) {
return scrubSecret
return scrubSecret
? { ...shortChannel.channel, secret: undefined }
: shortChannel.channel
}
@ -216,10 +220,10 @@ export class RedisChannelRepo implements ChannelRepo {
ttl: number = config.channel.ttl,
): Promise<Channel> {
const shortSlug = await generateShortSlugUntilUnique(
async (key) => (await this.client.get(key)) !== null
async (key) => (await this.client.get(key)) !== null,
)
const longSlug = await generateLongSlugUntilUnique(
async (key) => (await this.client.get(key)) !== null
async (key) => (await this.client.get(key)) !== null,
)
const channel: Channel = {
@ -289,7 +293,7 @@ export function getOrCreateChannelRepo(): ChannelRepo {
console.log('[ChannelRepo] Using Redis storage')
} else {
_channelRepo = new MemoryChannelRepo()
console.log('[ChannelRepo] Using in-memory storage')
console.log('[ChannelRepo] Using in-memory storage')
}
}
return _channelRepo

@ -20,7 +20,7 @@ export default function InputLabel({
</label>
{tooltip && (
<div className="relative">
<div
<div
className="text-[11px] text-stone-400 dark:text-stone-400 cursor-help hover:opacity-80 peer focus:opacity-80"
role="button"
aria-label="Show tooltip"

@ -1657,11 +1657,15 @@ function Arrow({ direction }: { direction: 'up' | 'down' }): JSX.Element {
viewBox="0 0 232 335"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className={direction === 'down' ? 'rotate-180 transition-transform duration-150' : 'transition-transform duration-150'}
className={
direction === 'down'
? 'rotate-180 transition-transform duration-150'
: 'transition-transform duration-150'
}
role="img"
aria-label={`Arrow pointing ${direction}`}
style={{
viewTransitionName: 'arrow-direction'
viewTransitionName: 'arrow-direction',
}}
>
<path

@ -57,8 +57,7 @@ async function getOrCreateGlobalPeer(): Promise<Peer> {
globalPeer?.on('open', listener)
})
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return globalPeer!
return globalPeer
}
export default function WebRTCPeerProvider({
@ -80,11 +79,7 @@ export default function WebRTCPeerProvider({
getOrCreateGlobalPeer().then(setPeerValue)
}, [])
const value = useMemo(
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
() => ({ peer: peerValue!, stop }),
[peerValue, stop],
)
const value = useMemo(() => ({ peer: peerValue!, stop }), [peerValue, stop])
if (isStopped) {
return <></>

@ -121,14 +121,14 @@ export function createZipStream(
header.view.setUint16(
6,
(((date.getHours() << 6) | date.getMinutes()) << 5) |
(date.getSeconds() / 2),
(date.getSeconds() / 2),
true,
)
header.view.setUint16(
8,
((((date.getFullYear() - 1980) << 4) | (date.getMonth() + 1)) <<
5) |
date.getDate(),
date.getDate(),
true,
)
header.view.setUint16(22, nameBuf.length, true)
@ -229,7 +229,8 @@ export function createZipStream(
return new ReadableStream({
start: (c) => {
ctrl = c
if (underlyingSource.start) Promise.resolve(underlyingSource.start(zipWriter))
if (underlyingSource.start)
Promise.resolve(underlyingSource.start(zipWriter))
},
pull() {
return (

Loading…
Cancel
Save