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,
|
maxColumnCount: this.state.maxColumnCount,
|
||||||
gap: this.state.gap,
|
gap: this.state.gap,
|
||||||
fontSize: this.state.fontSize,
|
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,
|
maxInlineSize: this.state.maxInlineSize,
|
||||||
maxBlockSize: this.state.maxBlockSize,
|
maxBlockSize: this.state.maxBlockSize,
|
||||||
fontFamily: this.state.fontFamily,
|
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 {CustomFontService} from '../../../../../shared/service/custom-font.service';
|
||||||
import {CustomFont} from '../../../../../shared/model/custom-font.model';
|
import {CustomFont} from '../../../../../shared/model/custom-font.model';
|
||||||
import {Observable, forkJoin, of, from} from 'rxjs';
|
import {Observable, forkJoin, of, from} from 'rxjs';
|
||||||
@@ -112,7 +112,7 @@ export class EpubCustomFontService {
|
|||||||
return css;
|
return css;
|
||||||
}
|
}
|
||||||
|
|
||||||
injectCustomFontsStylesheet(renderer: any, document: Document): void {
|
injectCustomFontsStylesheet(renderer: Renderer2, document: Document): void {
|
||||||
const css = this.generateCustomFontsStylesheet();
|
const css = this.generateCustomFontsStylesheet();
|
||||||
if (css) {
|
if (css) {
|
||||||
const styleEl = renderer.createElement('style');
|
const styleEl = renderer.createElement('style');
|
||||||
|
|||||||
@@ -6,14 +6,14 @@ import {ReaderIconComponent} from '../../shared/icon.component';
|
|||||||
interface TocItem {
|
interface TocItem {
|
||||||
label: string;
|
label: string;
|
||||||
href: string;
|
href: string;
|
||||||
subitems: any;
|
subitems?: TocItem[];
|
||||||
id: number;
|
id: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PageItem {
|
interface PageItem {
|
||||||
label: string;
|
label: string;
|
||||||
href: string;
|
href: string;
|
||||||
subitems: any;
|
subitems?: PageItem[];
|
||||||
id: number;
|
id: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ interface RelocateEventDetail {
|
|||||||
tocItem: TocItem;
|
tocItem: TocItem;
|
||||||
pageItem: PageItem;
|
pageItem: PageItem;
|
||||||
cfi: string;
|
cfi: string;
|
||||||
range: any;
|
range: Range | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|||||||
@@ -105,9 +105,7 @@ export class ReaderHeaderService {
|
|||||||
maxColumnCount: state.maxColumnCount,
|
maxColumnCount: state.maxColumnCount,
|
||||||
gap: state.gap,
|
gap: state.gap,
|
||||||
fontSize: state.fontSize,
|
fontSize: state.fontSize,
|
||||||
theme: typeof state.theme === 'object' && 'name' in state.theme
|
theme: state.theme.name,
|
||||||
? state.theme.name
|
|
||||||
: (state.theme as any),
|
|
||||||
maxInlineSize: state.maxInlineSize,
|
maxInlineSize: state.maxInlineSize,
|
||||||
maxBlockSize: state.maxBlockSize,
|
maxBlockSize: state.maxBlockSize,
|
||||||
fontFamily: state.fontFamily,
|
fontFamily: state.fontFamily,
|
||||||
|
|||||||
+1
-1
@@ -37,7 +37,7 @@ export class ReaderQuickSettingsComponent {
|
|||||||
maxColumnCount: this.state.maxColumnCount,
|
maxColumnCount: this.state.maxColumnCount,
|
||||||
gap: this.state.gap,
|
gap: this.state.gap,
|
||||||
fontSize: this.state.fontSize,
|
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,
|
maxInlineSize: this.state.maxInlineSize,
|
||||||
maxBlockSize: this.state.maxBlockSize,
|
maxBlockSize: this.state.maxBlockSize,
|
||||||
fontFamily: this.state.fontFamily,
|
fontFamily: this.state.fontFamily,
|
||||||
|
|||||||
@@ -7,6 +7,11 @@ import {SearchResult, SearchState} from '../sidebar/sidebar.service';
|
|||||||
|
|
||||||
export type LeftSidebarTab = 'search' | 'notes';
|
export type LeftSidebarTab = 'search' | 'notes';
|
||||||
|
|
||||||
|
interface ReaderSearchSubitem {
|
||||||
|
cfi: string;
|
||||||
|
excerpt: SearchResult['excerpt'];
|
||||||
|
}
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ReaderLeftSidebarService {
|
export class ReaderLeftSidebarService {
|
||||||
private viewManager = inject(ReaderViewManagerService);
|
private viewManager = inject(ReaderViewManagerService);
|
||||||
@@ -159,7 +164,7 @@ export class ReaderLeftSidebarService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ('subitems' in result && result.subitems) {
|
if ('subitems' in result && result.subitems) {
|
||||||
const sectionResults = result.subitems.map((item: any) => ({
|
const sectionResults = (result.subitems as ReaderSearchSubitem[]).map((item) => ({
|
||||||
cfi: item.cfi,
|
cfi: item.cfi,
|
||||||
excerpt: item.excerpt,
|
excerpt: item.excerpt,
|
||||||
sectionLabel: result.label
|
sectionLabel: result.label
|
||||||
|
|||||||
@@ -8,10 +8,15 @@ export interface ThemeInfo {
|
|||||||
bg: string;
|
bg: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface DecoratedRenderer {
|
||||||
|
heads?: HTMLElement[];
|
||||||
|
feet?: HTMLElement[];
|
||||||
|
}
|
||||||
|
|
||||||
export class PageDecorator {
|
export class PageDecorator {
|
||||||
private static readonly DEFAULT_FONT_SIZE = '0.875rem';
|
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) {
|
if (!renderer) {
|
||||||
return;
|
return;
|
||||||
@@ -24,7 +29,7 @@ export class PageDecorator {
|
|||||||
this.updateFooters(renderer, pageInfo, isSingleColumn, theme, timeRemainingLabel);
|
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) {
|
if (!renderer.heads || !Array.isArray(renderer.heads) || renderer.heads.length === 0) {
|
||||||
return;
|
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) {
|
if (!renderer.feet || !Array.isArray(renderer.feet) || renderer.feet.length === 0 || !pageInfo) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ export interface ReaderState {
|
|||||||
flow: 'paginated' | 'scrolled';
|
flow: 'paginated' | 'scrolled';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface LegacyViewerSetting {
|
||||||
|
customFontId?: string | number | null;
|
||||||
|
}
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
@@ -113,8 +117,11 @@ export class ReaderStateService {
|
|||||||
newState.fontFamily = settings.fontFamily;
|
newState.fontFamily = settings.fontFamily;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ((settings as any).customFontId != null) {
|
} else {
|
||||||
newState.fontFamily = `custom:${(settings as any).customFontId}`;
|
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);
|
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 {ReadingSessionService} from '../../../shared/service/reading-session.service';
|
||||||
import {Location} from '@angular/common';
|
import {Location} from '@angular/common';
|
||||||
|
|
||||||
|
interface SerializedPdfAnnotation extends Record<string, unknown> {
|
||||||
|
id?: unknown;
|
||||||
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-pdf-reader',
|
selector: 'app-pdf-reader',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
@@ -219,7 +223,7 @@ export class PdfReaderComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
const serialized = this.pdfViewerService.getSerializedAnnotations();
|
const serialized = this.pdfViewerService.getSerializedAnnotations();
|
||||||
if (serialized && serialized.length > 0) {
|
if (serialized && serialized.length > 0) {
|
||||||
const cleaned = serialized.map((annotation: any) => {
|
const cleaned = serialized.map((annotation: SerializedPdfAnnotation) => {
|
||||||
const {id, ...rest} = annotation;
|
const {id, ...rest} = annotation;
|
||||||
void id;
|
void id;
|
||||||
return rest;
|
return rest;
|
||||||
|
|||||||
Reference in New Issue
Block a user