chore(ui): clear reader utility any bucket
Replace reader-adjacent any usages in footer data shapes, settings sync helpers, panel search mapping, legacy font migration, and PDF annotation serialization. Keep the remaining no-explicit-any backlog isolated to the ebook reader core and annotation/progress surfaces. Validation: just ui lint
This commit is contained in:
@@ -73,7 +73,7 @@ export class ReaderSettingsDialogComponent implements OnInit {
|
||||
maxColumnCount: this.state.maxColumnCount,
|
||||
gap: this.state.gap,
|
||||
fontSize: this.state.fontSize,
|
||||
theme: typeof this.state.theme === 'object' && 'name' in this.state.theme ? this.state.theme.name : (this.state.theme as any),
|
||||
theme: this.state.theme.name,
|
||||
maxInlineSize: this.state.maxInlineSize,
|
||||
maxBlockSize: this.state.maxBlockSize,
|
||||
fontFamily: this.state.fontFamily,
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
import {Injectable, inject} from '@angular/core';
|
||||
import {Injectable, inject, Renderer2} from '@angular/core';
|
||||
import {CustomFontService} from '../../../../../shared/service/custom-font.service';
|
||||
import {CustomFont} from '../../../../../shared/model/custom-font.model';
|
||||
import {Observable, forkJoin, of, from} from 'rxjs';
|
||||
@@ -112,7 +112,7 @@ export class EpubCustomFontService {
|
||||
return css;
|
||||
}
|
||||
|
||||
injectCustomFontsStylesheet(renderer: any, document: Document): void {
|
||||
injectCustomFontsStylesheet(renderer: Renderer2, document: Document): void {
|
||||
const css = this.generateCustomFontsStylesheet();
|
||||
if (css) {
|
||||
const styleEl = renderer.createElement('style');
|
||||
|
||||
@@ -6,14 +6,14 @@ import {ReaderIconComponent} from '../../shared/icon.component';
|
||||
interface TocItem {
|
||||
label: string;
|
||||
href: string;
|
||||
subitems: any;
|
||||
subitems?: TocItem[];
|
||||
id: number;
|
||||
}
|
||||
|
||||
interface PageItem {
|
||||
label: string;
|
||||
href: string;
|
||||
subitems: any;
|
||||
subitems?: PageItem[];
|
||||
id: number;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ interface RelocateEventDetail {
|
||||
tocItem: TocItem;
|
||||
pageItem: PageItem;
|
||||
cfi: string;
|
||||
range: any;
|
||||
range: Range | null;
|
||||
}
|
||||
|
||||
@Component({
|
||||
|
||||
@@ -105,9 +105,7 @@ export class ReaderHeaderService {
|
||||
maxColumnCount: state.maxColumnCount,
|
||||
gap: state.gap,
|
||||
fontSize: state.fontSize,
|
||||
theme: typeof state.theme === 'object' && 'name' in state.theme
|
||||
? state.theme.name
|
||||
: (state.theme as any),
|
||||
theme: state.theme.name,
|
||||
maxInlineSize: state.maxInlineSize,
|
||||
maxBlockSize: state.maxBlockSize,
|
||||
fontFamily: state.fontFamily,
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ export class ReaderQuickSettingsComponent {
|
||||
maxColumnCount: this.state.maxColumnCount,
|
||||
gap: this.state.gap,
|
||||
fontSize: this.state.fontSize,
|
||||
theme: typeof this.state.theme === 'object' && 'name' in this.state.theme ? this.state.theme.name : (this.state.theme as any),
|
||||
theme: this.state.theme.name,
|
||||
maxInlineSize: this.state.maxInlineSize,
|
||||
maxBlockSize: this.state.maxBlockSize,
|
||||
fontFamily: this.state.fontFamily,
|
||||
|
||||
@@ -7,6 +7,11 @@ import {SearchResult, SearchState} from '../sidebar/sidebar.service';
|
||||
|
||||
export type LeftSidebarTab = 'search' | 'notes';
|
||||
|
||||
interface ReaderSearchSubitem {
|
||||
cfi: string;
|
||||
excerpt: SearchResult['excerpt'];
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class ReaderLeftSidebarService {
|
||||
private viewManager = inject(ReaderViewManagerService);
|
||||
@@ -159,7 +164,7 @@ export class ReaderLeftSidebarService {
|
||||
}
|
||||
|
||||
if ('subitems' in result && result.subitems) {
|
||||
const sectionResults = result.subitems.map((item: any) => ({
|
||||
const sectionResults = (result.subitems as ReaderSearchSubitem[]).map((item) => ({
|
||||
cfi: item.cfi,
|
||||
excerpt: item.excerpt,
|
||||
sectionLabel: result.label
|
||||
|
||||
@@ -8,10 +8,15 @@ export interface ThemeInfo {
|
||||
bg: string;
|
||||
}
|
||||
|
||||
interface DecoratedRenderer {
|
||||
heads?: HTMLElement[];
|
||||
feet?: HTMLElement[];
|
||||
}
|
||||
|
||||
export class PageDecorator {
|
||||
private static readonly DEFAULT_FONT_SIZE = '0.875rem';
|
||||
|
||||
static updateHeadersAndFooters(renderer: any, chapterName: string, pageInfo?: PageInfo, theme?: ThemeInfo, timeRemainingLabel?: string): void {
|
||||
static updateHeadersAndFooters(renderer: DecoratedRenderer | null | undefined, chapterName: string, pageInfo?: PageInfo, theme?: ThemeInfo, timeRemainingLabel?: string): void {
|
||||
|
||||
if (!renderer) {
|
||||
return;
|
||||
@@ -24,7 +29,7 @@ export class PageDecorator {
|
||||
this.updateFooters(renderer, pageInfo, isSingleColumn, theme, timeRemainingLabel);
|
||||
}
|
||||
|
||||
private static updateHeaders(renderer: any, chapterName: string, isSingleColumn: boolean, theme?: ThemeInfo): void {
|
||||
private static updateHeaders(renderer: DecoratedRenderer, chapterName: string, isSingleColumn: boolean, theme?: ThemeInfo): void {
|
||||
if (!renderer.heads || !Array.isArray(renderer.heads) || renderer.heads.length === 0) {
|
||||
return;
|
||||
}
|
||||
@@ -40,7 +45,7 @@ export class PageDecorator {
|
||||
});
|
||||
}
|
||||
|
||||
private static updateFooters(renderer: any, pageInfo: PageInfo | undefined, isSingleColumn: boolean, theme?: ThemeInfo, timeRemainingLabel?: string): void {
|
||||
private static updateFooters(renderer: DecoratedRenderer, pageInfo: PageInfo | undefined, isSingleColumn: boolean, theme?: ThemeInfo, timeRemainingLabel?: string): void {
|
||||
if (!renderer.feet || !Array.isArray(renderer.feet) || renderer.feet.length === 0 || !pageInfo) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,10 @@ export interface ReaderState {
|
||||
flow: 'paginated' | 'scrolled';
|
||||
}
|
||||
|
||||
interface LegacyViewerSetting {
|
||||
customFontId?: string | number | null;
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
@@ -113,8 +117,11 @@ export class ReaderStateService {
|
||||
newState.fontFamily = settings.fontFamily;
|
||||
}
|
||||
}
|
||||
} else if ((settings as any).customFontId != null) {
|
||||
newState.fontFamily = `custom:${(settings as any).customFontId}`;
|
||||
} else {
|
||||
const legacySettings = settings as LegacyViewerSetting;
|
||||
if (legacySettings.customFontId != null) {
|
||||
newState.fontFamily = `custom:${legacySettings.customFontId}`;
|
||||
}
|
||||
}
|
||||
|
||||
if (settings.gap != null) newState.gap = Math.min(settings.gap, 0.5);
|
||||
|
||||
@@ -17,6 +17,10 @@ import {TranslocoService, TranslocoPipe} from '@jsverse/transloco';
|
||||
import {ReadingSessionService} from '../../../shared/service/reading-session.service';
|
||||
import {Location} from '@angular/common';
|
||||
|
||||
interface SerializedPdfAnnotation extends Record<string, unknown> {
|
||||
id?: unknown;
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-pdf-reader',
|
||||
standalone: true,
|
||||
@@ -219,7 +223,7 @@ export class PdfReaderComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
const serialized = this.pdfViewerService.getSerializedAnnotations();
|
||||
if (serialized && serialized.length > 0) {
|
||||
const cleaned = serialized.map((annotation: any) => {
|
||||
const cleaned = serialized.map((annotation: SerializedPdfAnnotation) => {
|
||||
const {id, ...rest} = annotation;
|
||||
void id;
|
||||
return rest;
|
||||
|
||||
Reference in New Issue
Block a user