From fa4c1cea56697fb50ea0d6931e1f1201e9df3446 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Mon, 10 Jun 2024 14:10:58 -0500 Subject: [PATCH 1/6] feat: unique tagging --- src/components/Ad.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/Ad.tsx b/src/components/Ad.tsx index d303ee603..afa0cc654 100644 --- a/src/components/Ad.tsx +++ b/src/components/Ad.tsx @@ -1,6 +1,7 @@ 'use client'; -import { ComponentProps, useEffect } from 'react'; +import { uniqueId } from 'lodash'; +import { ComponentProps, useEffect, useRef } from 'react'; export enum AdType { TankopediaHorizontal800 = 738182777, @@ -11,11 +12,16 @@ interface AdProps extends ComponentProps<'div'> { } export function Ad({ type, ...props }: AdProps) { + const id = useRef(uniqueId()); + useEffect(() => { (window as any).msAdsQueue.push(function () { - (window as any).mmnow.render({ adUnitId: type, elementId: type }); + (window as any).mmnow.render({ + adUnitId: type, + elementId: `${type}-${id.current}`, + }); }); }); - return
; + return
; } From 903a2e9be1d21e70dead6d9e7f33a4959f58c04b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Tue, 11 Jun 2024 11:02:27 -0500 Subject: [PATCH 2/6] feat: dunno mate --- scripts/discoverIds.ts | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/scripts/discoverIds.ts b/scripts/discoverIds.ts index 5d575deef..a3ac1643c 100644 --- a/scripts/discoverIds.ts +++ b/scripts/discoverIds.ts @@ -28,7 +28,7 @@ console.log(`Running in ${production ? 'production' : 'development'} mode`); const startTime = Date.now(); const indexableRegions = [...REGIONS]; -const ids: number[] = []; +let ids: number[] = []; const preDiscoveredManifest = (await fetch( asset('ids/manifest.json', !production), ).then((response) => response.json())) as DiscoverIdsManifest; @@ -48,7 +48,7 @@ while (chunkIndex < preDiscoveredManifest.chunks) { }); // no spread syntax: https://github.com/oven-sh/bun/issues/11734 - preDiscovered.forEach((id) => ids.push(id)); + ids = ids.concat(preDiscovered); console.log( `Pre-discovered ${preDiscovered.length} ids (chunk ${chunkIndex})`, @@ -134,19 +134,25 @@ const interval = setInterval(async () => { function post() { clearInterval(interval); + ids = uniq(ids).sort((a, b) => a - b); console.log(`Uploading ${ids.length} ids...`); - const idsSorted = uniq(ids).sort((a, b) => a - b); - const idsChunked = chunk(idsSorted, CHUNK_SIZE); - const files = idsChunked.map((ids, chunk) => { - const didsWriteStream = new DidsWriteStream().dids(ids); - const compressed = compress(didsWriteStream.uint8Array); + const idsChunked = chunk(ids, CHUNK_SIZE); + const files = idsChunked.map((chunk, index) => { + const didsWriteStream = new DidsWriteStream().dids(chunk); + const buffer = didsWriteStream.uint8Array; + const compressed = compress(buffer); + + console.log( + `Chunk ${index} with ${chunk.length} ids (compressed: ${compressed.length}; uncompressed: ${buffer.length})`, + ); + const content = Buffer.from(compressed).toString('base64'); return { content, encoding: 'base64' as const, - path: `ids/${chunk}.dids.lz4`, + path: `ids/${index}.dids.lz4`, }; }); From c26dd277a8529ca66b649e35021fae852ba3d322 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Tue, 11 Jun 2024 13:36:02 -0500 Subject: [PATCH 3/6] feat: debug --- src/app/tools/tankopedia/page.tsx | 4 +-- src/components/Ad.tsx | 57 +++++++++++++++++++++++++++++-- 2 files changed, 56 insertions(+), 5 deletions(-) diff --git a/src/app/tools/tankopedia/page.tsx b/src/app/tools/tankopedia/page.tsx index a6b4a70b2..1db60188f 100644 --- a/src/app/tools/tankopedia/page.tsx +++ b/src/app/tools/tankopedia/page.tsx @@ -20,8 +20,8 @@ export default function Page() { /> - {times(2, () => ( - + {times(2, (index) => ( + ))} diff --git a/src/components/Ad.tsx b/src/components/Ad.tsx index afa0cc654..444e51679 100644 --- a/src/components/Ad.tsx +++ b/src/components/Ad.tsx @@ -1,18 +1,34 @@ 'use client'; +import { Box, Flex, Text } from '@radix-ui/themes'; import { uniqueId } from 'lodash'; import { ComponentProps, useEffect, useRef } from 'react'; +import { Vector2Tuple } from 'three'; +import { imgur } from '../core/blitzkit/imgur'; +import { useApp } from '../stores/app'; export enum AdType { - TankopediaHorizontal800 = 738182777, + MediumRectangleHorizontalPurple = 738182777, + LeaderboardHorizontalPurple = 84051521, + WideSkyscraperVerticalPurple = 1755617140, + HalfPageVerticalPurple = 880185176, } +const AD_DIMENSIONS: Record = { + [AdType.MediumRectangleHorizontalPurple]: [300, 250], + [AdType.LeaderboardHorizontalPurple]: [728, 90], + [AdType.WideSkyscraperVerticalPurple]: [160, 600], + [AdType.HalfPageVerticalPurple]: [300, 600], +}; + interface AdProps extends ComponentProps<'div'> { type: AdType; } export function Ad({ type, ...props }: AdProps) { const id = useRef(uniqueId()); + const dimensions = AD_DIMENSIONS[type]; + const developerMode = useApp((state) => state.developerMode); useEffect(() => { (window as any).msAdsQueue.push(function () { @@ -21,7 +37,42 @@ export function Ad({ type, ...props }: AdProps) { elementId: `${type}-${id.current}`, }); }); - }); + }, [type]); - return
; + return ( + + + {!developerMode && Advertisement} + {developerMode && ( + <> + + {AdType[type]} + + + {dimensions[0]}x{dimensions[1]} + + + )} + + + + + ); } From ac81c68889a9a98b6d66e2ca4524aa09ca58eaed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Tue, 11 Jun 2024 13:38:25 -0500 Subject: [PATCH 4/6] fix: box props --- src/components/Ad.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/Ad.tsx b/src/components/Ad.tsx index 444e51679..eee774d05 100644 --- a/src/components/Ad.tsx +++ b/src/components/Ad.tsx @@ -1,8 +1,8 @@ 'use client'; -import { Box, Flex, Text } from '@radix-ui/themes'; +import { Box, BoxProps, Flex, Text } from '@radix-ui/themes'; import { uniqueId } from 'lodash'; -import { ComponentProps, useEffect, useRef } from 'react'; +import { useEffect, useRef } from 'react'; import { Vector2Tuple } from 'three'; import { imgur } from '../core/blitzkit/imgur'; import { useApp } from '../stores/app'; @@ -21,9 +21,9 @@ const AD_DIMENSIONS: Record = { [AdType.HalfPageVerticalPurple]: [300, 600], }; -interface AdProps extends ComponentProps<'div'> { +type AdProps = BoxProps & { type: AdType; -} +}; export function Ad({ type, ...props }: AdProps) { const id = useRef(uniqueId()); From 22cc7b367c3c8b19a27499c390271f656def1d1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Tue, 11 Jun 2024 13:38:38 -0500 Subject: [PATCH 5/6] fix: style --- src/components/Ad.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/Ad.tsx b/src/components/Ad.tsx index eee774d05..f8e05abc7 100644 --- a/src/components/Ad.tsx +++ b/src/components/Ad.tsx @@ -25,7 +25,7 @@ type AdProps = BoxProps & { type: AdType; }; -export function Ad({ type, ...props }: AdProps) { +export function Ad({ type, style, ...props }: AdProps) { const id = useRef(uniqueId()); const dimensions = AD_DIMENSIONS[type]; const developerMode = useApp((state) => state.developerMode); @@ -48,6 +48,7 @@ export function Ad({ type, ...props }: AdProps) { outline: '1px solid var(--gray-3)', borderRadius: 'var(--radius-1)', background: `url(${imgur('DK21EHY')})`, + ...style, }} {...props} > From 690ed2aa7e8615bbf8e119cdc3f36587d3886aeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Tue, 11 Jun 2024 19:49:15 -0500 Subject: [PATCH 6/6] feat: stricter ad boundaries --- src/app/tools/tankopedia/map/page.tsx | 26 -------------------------- src/app/tools/tankopedia/page.tsx | 5 ----- src/components/Ad.tsx | 26 ++++++++++++-------------- 3 files changed, 12 insertions(+), 45 deletions(-) delete mode 100644 src/app/tools/tankopedia/map/page.tsx diff --git a/src/app/tools/tankopedia/map/page.tsx b/src/app/tools/tankopedia/map/page.tsx deleted file mode 100644 index 0f55246cb..000000000 --- a/src/app/tools/tankopedia/map/page.tsx +++ /dev/null @@ -1,26 +0,0 @@ -'use client'; - -import { Flex, Link } from '@radix-ui/themes'; -import { use } from 'react'; -import PageWrapper from '../../../../components/PageWrapper'; -import { tankDefinitions } from '../../../../core/blitzkit/tankDefinitions'; - -export default function Page() { - const awaitedTankDefinitions = use(tankDefinitions); - - return ( - - Super duper secret map for SEO - - - {Object.values(awaitedTankDefinitions) - .sort((a, b) => b.tier - a.tier) - .map((tank) => ( - - {tank.name} - - ))} - - - ); -} diff --git a/src/app/tools/tankopedia/page.tsx b/src/app/tools/tankopedia/page.tsx index 1db60188f..31d7bd068 100644 --- a/src/app/tools/tankopedia/page.tsx +++ b/src/app/tools/tankopedia/page.tsx @@ -2,7 +2,6 @@ import { Flex } from '@radix-ui/themes'; import { times } from 'lodash'; -import Link from 'next/link'; import { useRouter } from 'next/navigation'; import { Ad, AdType } from '../../../components/Ad'; import PageWrapper from '../../../components/PageWrapper'; @@ -24,10 +23,6 @@ export default function Page() { ))} - - - Super duper secret map - ); } diff --git a/src/components/Ad.tsx b/src/components/Ad.tsx index f8e05abc7..fef5a0fea 100644 --- a/src/components/Ad.tsx +++ b/src/components/Ad.tsx @@ -5,7 +5,6 @@ import { uniqueId } from 'lodash'; import { useEffect, useRef } from 'react'; import { Vector2Tuple } from 'three'; import { imgur } from '../core/blitzkit/imgur'; -import { useApp } from '../stores/app'; export enum AdType { MediumRectangleHorizontalPurple = 738182777, @@ -28,7 +27,6 @@ type AdProps = BoxProps & { export function Ad({ type, style, ...props }: AdProps) { const id = useRef(uniqueId()); const dimensions = AD_DIMENSIONS[type]; - const developerMode = useApp((state) => state.developerMode); useEffect(() => { (window as any).msAdsQueue.push(function () { @@ -44,10 +42,12 @@ export function Ad({ type, style, ...props }: AdProps) { position="relative" width={`${dimensions[0]}px`} height={`${dimensions[1]}px`} + overflow="hidden" style={{ outline: '1px solid var(--gray-3)', borderRadius: 'var(--radius-1)', background: `url(${imgur('DK21EHY')})`, + ...style, }} {...props} @@ -60,20 +60,18 @@ export function Ad({ type, style, ...props }: AdProps) { direction="column" align="center" > - {!developerMode && Advertisement} - {developerMode && ( - <> - - {AdType[type]} - - - {dimensions[0]}x{dimensions[1]} - - - )} + Advertisement + + {dimensions[0]}x{dimensions[1]} + - + ); }