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

@ -112,6 +112,9 @@ devDependencies:
typescript: typescript:
specifier: ^4.9.5 specifier: ^4.9.5
version: 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: packages:
@ -5804,6 +5807,22 @@ packages:
reflect.getprototypeof: 1.0.6 reflect.getprototypeof: 1.0.6
dev: true 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: /typescript@4.9.5:
resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==} resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==}
engines: {node: '>=4.2.0'} engines: {node: '>=4.2.0'}

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

@ -34,7 +34,9 @@ function getLongSlugKey(longSlug: string): string {
return `long:${longSlug}` 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++) { for (let i = 0; i < config.shortSlug.maxAttempts; i++) {
const slug = generateShortSlug() const slug = generateShortSlug()
const exists = await checkExists(getShortSlugKey(slug)) 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') 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++) { for (let i = 0; i < config.longSlug.maxAttempts; i++) {
const slug = await generateLongSlug() const slug = await generateLongSlug()
const exists = await checkExists(getLongSlugKey(slug)) const exists = await checkExists(getLongSlugKey(slug))
@ -100,11 +104,11 @@ export class MemoryChannelRepo implements ChannelRepo {
uploaderPeerID: string, uploaderPeerID: string,
ttl: number = config.channel.ttl, ttl: number = config.channel.ttl,
): Promise<Channel> { ): Promise<Channel> {
const shortSlug = await generateShortSlugUntilUnique( const shortSlug = await generateShortSlugUntilUnique(async (key) =>
async (key) => this.channels.has(key), this.channels.has(key),
) )
const longSlug = await generateLongSlugUntilUnique( const longSlug = await generateLongSlugUntilUnique(async (key) =>
async (key) => this.channels.has(key), this.channels.has(key),
) )
const channel: Channel = { const channel: Channel = {
@ -216,10 +220,10 @@ export class RedisChannelRepo implements ChannelRepo {
ttl: number = config.channel.ttl, ttl: number = config.channel.ttl,
): Promise<Channel> { ): Promise<Channel> {
const shortSlug = await generateShortSlugUntilUnique( const shortSlug = await generateShortSlugUntilUnique(
async (key) => (await this.client.get(key)) !== null async (key) => (await this.client.get(key)) !== null,
) )
const longSlug = await generateLongSlugUntilUnique( const longSlug = await generateLongSlugUntilUnique(
async (key) => (await this.client.get(key)) !== null async (key) => (await this.client.get(key)) !== null,
) )
const channel: Channel = { const channel: Channel = {

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

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

@ -229,7 +229,8 @@ export function createZipStream(
return new ReadableStream({ return new ReadableStream({
start: (c) => { start: (c) => {
ctrl = c ctrl = c
if (underlyingSource.start) Promise.resolve(underlyingSource.start(zipWriter)) if (underlyingSource.start)
Promise.resolve(underlyingSource.start(zipWriter))
}, },
pull() { pull() {
return ( return (

Loading…
Cancel
Save