diff options
feat: optimize output when no anim
| -rw-r--r-- | src/routes/IndexPage.svelte | 16 | ||||
| -rw-r--r-- | src/routes/anim-gen.ts | 4 | ||||
| -rw-r--r-- | src/routes/distro-info.ts | 4 | ||||
| -rw-r--r-- | src/routes/shared.ts | 130 |
4 files changed, 60 insertions, 94 deletions
diff --git a/src/routes/IndexPage.svelte b/src/routes/IndexPage.svelte index f7588d3..c2d07eb 100644 --- a/src/routes/IndexPage.svelte +++ b/src/routes/IndexPage.svelte @@ -15,7 +15,13 @@ <script lang="ts"> import logo from './boot-logo.webp'; import { architecture, hostname, tty, versions } from './distro-info'; - import { login, ttyLines, type RenderBlock, type TTYText } from './shared'; + import { + joinSimilarTTYLines, + login, + ttyLines, + type RenderBlock, + type TTYText, + } from './shared'; import { onDestroy, onMount } from 'svelte'; import { base } from '$app/paths'; @@ -78,8 +84,8 @@ {#snippet ttyTextInnerRenderer(section: RenderBlock)} <span class="ttytext-block {section.colour - ? ` text-[${section.colour}]` - : ''}{section.bg ? ` bg-[${section.bg}]` : ''} {section.weight + ? ` t${section.colour}` + : ''}{section.bg ? ` b${section.bg}` : ''} {section.weight ? ` ${['', 'font-thin', 'font-extralight', 'font-light', 'font-normal', 'font-medium', 'font-semibold', 'font-bold', 'font-extrabold', 'font-black'][section.weight / 100]}` : ''}{typeof section.italic === 'undefined' ? '' @@ -394,7 +400,7 @@ <div class="line ttylines-openrc font-mono text-[#070505] flex flex-col" > - {#each ttyLines.filter(((maxidx) => (_, i) => i < (maxidx === -1 ? Infinity : maxidx))(ttyLines.findIndex((v) => v.kind === 'clear'))) as line} + {#each joinSimilarTTYLines(ttyLines.filter(((maxidx) => (_, i) => i < (maxidx === -1 ? Infinity : maxidx))(ttyLines.findIndex((v) => v.kind === 'clear')))) as line} {@render ttyText(line)} {/each} </div> @@ -415,7 +421,7 @@ > <div class="mb-auto"></div> <div class="font-mono leading-4 text-[#070505] flex flex-col p-4"> - {#each ttyLines.filter((v, i) => i >= idx && i < (nextIdx ?? Infinity) && (!skipAnimation || !('classes' in v) || !Array.isArray(v.classes) || !v.classes.includes('ttytext-removed-after-done'))) as line} + {#each joinSimilarTTYLines(ttyLines.filter((v, i) => i >= idx && i < (nextIdx ?? Infinity) && (!skipAnimation || !('classes' in v) || !Array.isArray(v.classes) || !v.classes.includes('ttytext-removed-after-done')))) as line} {@render ttyText(line)} {/each} </div> diff --git a/src/routes/anim-gen.ts b/src/routes/anim-gen.ts index 67b1d6f..fcbb23d 100644 --- a/src/routes/anim-gen.ts +++ b/src/routes/anim-gen.ts @@ -475,9 +475,9 @@ ${ttyLines ...(v.kind === 'text' ? [ v.colour - ? `.ttytext-block.text-\\[\\${v.colour}\\]{color:${v.colour};}` + ? `.ttytext-block.t\\${v.colour}{color:${v.colour};}` : '', - v.bg ? `.ttytext-block.bg-\\[\\${v.bg}\\]{background:${v.bg};}` : '', + v.bg ? `.ttytext-block.b\\${v.bg}{background:${v.bg};}` : '', ] : []), ]) diff --git a/src/routes/distro-info.ts b/src/routes/distro-info.ts index 84d7938..307a463 100644 --- a/src/routes/distro-info.ts +++ b/src/routes/distro-info.ts @@ -10,11 +10,11 @@ export const architecture = 'x86_64'; export const versions = { alpine: { - number: '3.21.2', + number: '3.23.2', isEdge: false, }, kernel: { - id: '6.12.9-0-lts', + id: '6.18.5-0-lts', humanReadable: 'Linux lts', }, openrc: '0.55.1.ba16daf355', diff --git a/src/routes/shared.ts b/src/routes/shared.ts index e4a3e6d..5d20dd6 100644 --- a/src/routes/shared.ts +++ b/src/routes/shared.ts @@ -37,37 +37,37 @@ export type RenderBlock = { italic?: boolean; underlined?: boolean; url?: - | `newtab:${string}` - | `currenttab:${string}` - | ((textObj: TTYText & { kind: 'text' }) => void); + | `newtab:${string}` + | `currenttab:${string}` + | ((textObj: TTYText & { kind: 'text' }) => void); bg?: string; raw?: boolean; dl?: string; }; export type TTYText = | { - kind: 'text'; - renderrestriction?: 'everywhere' | 'js-only' | 'noscript'; - value: RenderBlock[]; - id: string; - classes: string[]; - } + kind: 'text'; + renderrestriction?: 'everywhere' | 'js-only' | 'noscript'; + value: RenderBlock[]; + id: string; + classes: string[]; + } | { - kind: 'removeNode'; - removedId: string; - removedItemClassList: string[]; - } + kind: 'removeNode'; + removedId: string; + removedItemClassList: string[]; + } | { - kind: 'time'; - delay: number; - } + kind: 'time'; + delay: number; + } | { - kind: 'cursorVisibility'; - visible: boolean; - } + kind: 'cursorVisibility'; + visible: boolean; + } | { - kind: 'clear'; - }; + kind: 'clear'; + }; export type Only<Obj, Keys extends keyof Obj> = { [k in Keys]: Obj[k]; }; @@ -396,7 +396,7 @@ export const ttyLines: TTYText[] = (() => { colour: '#7a7a7a', }, ], - ['GPG Root Key: ', { colour: '#cdcdcd' }], + ['GPG Key: ', { colour: '#cdcdcd' }], ); wait(1000); replaceLast((v) => [ @@ -412,19 +412,9 @@ export const ttyLines: TTYText[] = (() => { }, ], ]); - wait(100); - replaceLast((v) => [ - ...v, - [ - ' (root key)', - { - colour: '#999999', - }, - ], - ]); wait(400); text([ - ' - ', + ' - ', { colour: '#7a7a7a', }, @@ -469,58 +459,6 @@ export const ttyLines: TTYText[] = (() => { ], [')', { colour: '#999999' }], ]); - wait(45); - text([ - ' - ', - { - colour: '#7a7a7a', - }, - ]); - wait(70); - replaceLast((v) => [ - ...v, - [ - 'GPG Release Signing Key: ', - { - colour: '#cdcdcd', - }, - ], - ]); - wait(100); - replaceLast((v) => [ - ...v, - [ - '0D93102265071798C7B65A4C9F0739B9E0C8FD60', - { - colour: '#ffffff', - underlined: true, - weight: 700, - url: `currenttab:/keys/memdmp/release.pgp`, - dl: 'memdmp-release.pgp', - }, - ], - ]); - wait(100); - replaceLast((v) => [ - ...v, - [ - ' (', - { - colour: '#999999', - }, - ], - [ - 'signed', - { - colour: '#ffffff', - underlined: true, - weight: 500, - url: `currenttab:/keys/memdmp/release.pgp.sig`, - dl: 'memdmp-release.pgp.sig', - }, - ], - [')', { colour: '#999999' }], - ]); wait(100); text([ ' - ', @@ -620,3 +558,25 @@ export const ttyLines: TTYText[] = (() => { return lines; })(); +export const joinSimilarTTYLines = (lines: TTYText[]) => { + for (const line of lines) + if (line.kind === 'text') { + const newvalues = [] as RenderBlock[]; + let lastvalue: string = ''; + for (const value of line.value) { + const thisvalue_raw = { ...value } as Omit<RenderBlock, 'value'> & { + value?: string + }; + delete (thisvalue_raw as Partial<RenderBlock>)['value'] + const thisvalue = Object.entries(thisvalue_raw).toSorted((a, b) => a[0] > b[0] ? 1 : a[0] === b[0] ? 0 : -1).map(v => v[1]).join('\r\n\n\r\r\n') + if (thisvalue === lastvalue) { + newvalues[newvalues.length - 1].value += value.value + } else { + lastvalue = thisvalue + newvalues.push(value) + } + } + line.value = newvalues + } + return lines +} |