fix: linter issues
This commit is contained in:
+5
-5
@@ -1,19 +1,19 @@
|
||||
import JSZip from 'jszip';
|
||||
import { Plugin } from '@/types/plugin';
|
||||
// import { Plugin } from '@/types/plugin'; // apparently unused
|
||||
|
||||
export interface EpubOptions {
|
||||
export type EpubOptions = {
|
||||
title: string;
|
||||
author?: string;
|
||||
description?: string;
|
||||
cover?: string;
|
||||
language?: string;
|
||||
}
|
||||
};
|
||||
|
||||
export interface ChapterData {
|
||||
export type ChapterData = {
|
||||
title: string;
|
||||
content: string;
|
||||
path: string;
|
||||
}
|
||||
};
|
||||
|
||||
function sanitizeHtml(html: string): string {
|
||||
// Remove script tags and their content
|
||||
|
||||
+6
-4
@@ -2,7 +2,7 @@
|
||||
|
||||
import { parse as parseProto } from 'protobufjs';
|
||||
|
||||
type FetchInit = {
|
||||
export type FetchInit = {
|
||||
headers?: Record<string, string | undefined> | Headers;
|
||||
method?: string;
|
||||
body?: FormData | string;
|
||||
@@ -104,7 +104,7 @@ type ProtoRequestInit = {
|
||||
// merged .proto file
|
||||
proto: string;
|
||||
requestType: string;
|
||||
requestData?: any;
|
||||
requestData?: Record<string, unknown>;
|
||||
responseType: string;
|
||||
};
|
||||
|
||||
@@ -117,11 +117,13 @@ export const fetchProto = async function <ReturnType>(
|
||||
) {
|
||||
const protoRoot = parseProto(protoInit.proto).root;
|
||||
const RequestMessge = protoRoot.lookupType(protoInit.requestType);
|
||||
if (RequestMessge.verify(protoInit.requestData)) {
|
||||
if (RequestMessge.verify(protoInit.requestData || {})) {
|
||||
throw new Error('Invalid Proto');
|
||||
}
|
||||
// encode request data
|
||||
const encodedrequest = RequestMessge.encode(protoInit.requestData).finish();
|
||||
const encodedrequest = RequestMessge.encode(
|
||||
protoInit.requestData || {},
|
||||
).finish();
|
||||
const requestLength = BigInt(encodedrequest.length);
|
||||
const headers = new Uint8Array(
|
||||
Array(5)
|
||||
|
||||
+16
-8
@@ -1,5 +1,11 @@
|
||||
export type StorageItem<T = unknown> = {
|
||||
created: Date;
|
||||
value: T;
|
||||
expires?: number;
|
||||
};
|
||||
|
||||
class Storage {
|
||||
private db: Record<string, { created: Date; value: any; expires?: number }>;
|
||||
private db: Record<string, StorageItem>;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the Storage class.
|
||||
@@ -12,10 +18,10 @@ class Storage {
|
||||
* Sets a key-value pair in storage.
|
||||
*
|
||||
* @param {string} key - The key to set.
|
||||
* @param {any} value - The value to set.
|
||||
* @param {T} value - The value to set.
|
||||
* @param {Date | number} [expires] - Optional expiry date or time in milliseconds.
|
||||
*/
|
||||
set(key: string, value: any, expires?: Date | number): void {
|
||||
set<T>(key: string, value: T, expires?: Date | number): void {
|
||||
this.db[key] = {
|
||||
created: new Date(),
|
||||
value,
|
||||
@@ -28,10 +34,12 @@ class Storage {
|
||||
*
|
||||
* @param {string} key - The key to retrieve the value for.
|
||||
* @param {boolean} [raw] - Optional flag to return the raw stored item.
|
||||
* @returns {any} The stored value or undefined if key is not found.
|
||||
* @returns The stored value or undefined if key is not found.
|
||||
*/
|
||||
get(key: string, raw?: boolean): any {
|
||||
const item = this.db[key];
|
||||
get<T = unknown>(key: string, raw: true): StorageItem<T> | undefined;
|
||||
get<T = unknown>(key: string, raw?: false): T | undefined;
|
||||
get<T = unknown>(key: string, raw?: boolean): T | StorageItem<T> | undefined {
|
||||
const item = this.db[key] as StorageItem<T> | undefined;
|
||||
if (item?.expires && Date.now() > item.expires) {
|
||||
this.delete(key);
|
||||
return undefined;
|
||||
@@ -69,7 +77,7 @@ class Storage {
|
||||
export const storage = new Storage();
|
||||
|
||||
/*
|
||||
These parameters cannot be implemented in `test-web`.
|
||||
These parameters cannot be implemented in `test-web`.
|
||||
They are generated in the browser when js-scripts are executed
|
||||
Read more
|
||||
|
||||
@@ -80,7 +88,7 @@ https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage
|
||||
/**
|
||||
* Represents the structure of a storage object with string keys and values.
|
||||
*/
|
||||
type StorageObject = Record<string, any>;
|
||||
type StorageObject = Record<string, string>;
|
||||
|
||||
/**
|
||||
* Represents a simplified version of the browser's localStorage.
|
||||
|
||||
Reference in New Issue
Block a user