@prose-reader/streamer 1.28.0 → 1.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,16 +1,10 @@
1
- import { Archive } from "./types"
2
- export declare const createArchiveFromArrayBufferList: (
3
- list: {
4
- isDir: boolean
5
- name: string
6
- size: number
7
- data: () => Promise<ArrayBuffer>
8
- }[],
9
- {
10
- orderByAlpha,
11
- name,
12
- }?: {
13
- orderByAlpha?: boolean | undefined
14
- name?: string | undefined
15
- }
16
- ) => Promise<Archive>
1
+ import { Archive } from "./types";
2
+ export declare const createArchiveFromArrayBufferList: (list: {
3
+ isDir: boolean;
4
+ name: string;
5
+ size: number;
6
+ data: () => Promise<ArrayBuffer>;
7
+ }[], { orderByAlpha, name }?: {
8
+ orderByAlpha?: boolean | undefined;
9
+ name?: string | undefined;
10
+ }) => Promise<Archive>;
@@ -1,40 +1,34 @@
1
1
  /// <reference types="node" />
2
- import { Archive, StreamResult } from "./types"
2
+ import { Archive, StreamResult } from "./types";
3
3
  interface OutputByType {
4
- base64: string
5
- string: string
6
- text: string
7
- binarystring: string
8
- array: number[]
9
- uint8array: Uint8Array
10
- arraybuffer: ArrayBuffer
11
- blob: Blob
12
- nodebuffer: Buffer
4
+ base64: string;
5
+ string: string;
6
+ text: string;
7
+ binarystring: string;
8
+ array: number[];
9
+ uint8array: Uint8Array;
10
+ arraybuffer: ArrayBuffer;
11
+ blob: Blob;
12
+ nodebuffer: Buffer;
13
13
  }
14
- type OutputType = keyof OutputByType
14
+ type OutputType = keyof OutputByType;
15
15
  interface JSZipObject {
16
- name: string
17
- dir: boolean
18
- date: Date
19
- comment: string
20
- unixPermissions: number | string | null
21
- dosPermissions: number | null
22
- async<T extends OutputType>(type: T): Promise<OutputByType[T]>
23
- internalStream?: (type?: `uint8array`) => StreamResult
16
+ name: string;
17
+ dir: boolean;
18
+ date: Date;
19
+ comment: string;
20
+ unixPermissions: number | string | null;
21
+ dosPermissions: number | null;
22
+ async<T extends OutputType>(type: T): Promise<OutputByType[T]>;
23
+ internalStream?: (type?: `uint8array`) => StreamResult;
24
24
  }
25
25
  interface JSZip {
26
- files: {
27
- [key: string]: JSZipObject
28
- }
26
+ files: {
27
+ [key: string]: JSZipObject;
28
+ };
29
29
  }
30
- export declare const createArchiveFromJszip: (
31
- jszip: JSZip,
32
- {
33
- orderByAlpha,
34
- name,
35
- }?: {
36
- orderByAlpha?: boolean | undefined
37
- name?: string | undefined
38
- }
39
- ) => Promise<Archive>
40
- export {}
30
+ export declare const createArchiveFromJszip: (jszip: JSZip, { orderByAlpha, name }?: {
31
+ orderByAlpha?: boolean | undefined;
32
+ name?: string | undefined;
33
+ }) => Promise<Archive>;
34
+ export {};
@@ -1,14 +1,8 @@
1
- import { Archive } from "./types"
1
+ import { Archive } from "./types";
2
2
  /**
3
3
  * Useful to create archive from txt content
4
4
  */
5
- export declare const createArchiveFromText: (
6
- content: string | Blob,
7
- {
8
- mimeType,
9
- direction,
10
- }?: {
11
- direction?: "ltr" | "rtl" | undefined
12
- mimeType?: string | undefined
13
- }
14
- ) => Promise<Archive>
5
+ export declare const createArchiveFromText: (content: string | Blob, { mimeType, direction, }?: {
6
+ direction?: "ltr" | "rtl" | undefined;
7
+ mimeType?: string | undefined;
8
+ }) => Promise<Archive>;
@@ -1,12 +1,9 @@
1
- import { Archive } from "./types"
1
+ import { Archive } from "./types";
2
2
  /**
3
3
  * @important
4
4
  * Make sure the urls are on the same origin or the cors header is set otherwise
5
5
  * the resource cannot be consumed as it is on the web.
6
6
  */
7
- export declare const createArchiveFromUrls: (
8
- urls: string[],
9
- options?: {
10
- useRenditionFlow: boolean
11
- }
12
- ) => Promise<Archive>
7
+ export declare const createArchiveFromUrls: (urls: string[], options?: {
8
+ useRenditionFlow: boolean;
9
+ }) => Promise<Archive>;
@@ -1,17 +1,15 @@
1
- import { Archive } from "./types"
1
+ import { Archive } from "./types";
2
2
  export declare const getArchiveOpfInfo: (archive: Archive) => {
3
- data:
4
- | {
5
- dir: boolean
6
- basename: string
7
- uri: string
8
- blob: () => Promise<Blob>
9
- string: () => Promise<string>
10
- base64: () => Promise<string>
11
- stream?: (() => import("./types").StreamResult) | undefined
12
- size: number
13
- encodingFormat?: string | undefined
14
- }
15
- | undefined
16
- basePath: string
17
- }
3
+ data: {
4
+ dir: boolean;
5
+ basename: string;
6
+ uri: string;
7
+ blob: () => Promise<Blob>;
8
+ string: () => Promise<string>;
9
+ base64: () => Promise<string>;
10
+ stream?: (() => import("./types").StreamResult) | undefined;
11
+ size: number;
12
+ encodingFormat?: string | undefined;
13
+ } | undefined;
14
+ basePath: string;
15
+ };
@@ -1,20 +1,20 @@
1
1
  export interface StreamResult {
2
- on(e: `data`, cb: (data: Uint8Array) => void): void
3
- on(e: `error`, cb: (error: Error) => void): void
4
- on(e: `end`, cb: () => void): void
5
- resume(): void
2
+ on(e: `data`, cb: (data: Uint8Array) => void): void;
3
+ on(e: `error`, cb: (error: Error) => void): void;
4
+ on(e: `end`, cb: () => void): void;
5
+ resume(): void;
6
6
  }
7
7
  export type Archive = {
8
- filename: string
9
- files: {
10
- dir: boolean
11
- basename: string
12
- uri: string
13
- blob: () => Promise<Blob>
14
- string: () => Promise<string>
15
- base64: () => Promise<string>
16
- stream?: () => StreamResult
17
- size: number
18
- encodingFormat?: string
19
- }[]
20
- }
8
+ filename: string;
9
+ files: {
10
+ dir: boolean;
11
+ basename: string;
12
+ uri: string;
13
+ blob: () => Promise<Blob>;
14
+ string: () => Promise<string>;
15
+ base64: () => Promise<string>;
16
+ stream?: () => StreamResult;
17
+ size: number;
18
+ encodingFormat?: string;
19
+ }[];
20
+ };
@@ -1 +1,3 @@
1
- export declare const configure: ({ enableReport }?: { enableReport?: boolean | undefined }) => void
1
+ export declare const configure: ({ enableReport }?: {
2
+ enableReport?: boolean | undefined;
3
+ }) => void;
@@ -1,14 +1,14 @@
1
- import { Archive } from "../archives/types"
2
- export declare const getSpineItemFilesFromArchive: ({ archive }: { archive: Archive }) => Promise<
3
- {
4
- dir: boolean
5
- basename: string
6
- uri: string
7
- blob: () => Promise<Blob>
8
- string: () => Promise<string>
9
- base64: () => Promise<string>
10
- stream?: (() => import("../archives/types").StreamResult) | undefined
11
- size: number
12
- encodingFormat?: string | undefined
13
- }[]
14
- >
1
+ import { Archive } from "../archives/types";
2
+ export declare const getSpineItemFilesFromArchive: ({ archive }: {
3
+ archive: Archive;
4
+ }) => Promise<{
5
+ dir: boolean;
6
+ basename: string;
7
+ uri: string;
8
+ blob: () => Promise<Blob>;
9
+ string: () => Promise<string>;
10
+ base64: () => Promise<string>;
11
+ stream?: (() => import("../archives/types").StreamResult) | undefined;
12
+ size: number;
13
+ encodingFormat?: string | undefined;
14
+ }[]>;
@@ -1,13 +1,10 @@
1
- import { Manifest } from "@prose-reader/shared"
2
- import { Archive } from "../../../archives/types"
1
+ import { Manifest } from "@prose-reader/shared";
2
+ import { Archive } from "../../../archives/types";
3
3
  /**
4
4
  * Handle archive which contains ComicInfo.xml. This is a meta file
5
5
  * used to define cbz, etc. I believe it comes from some sites or apps.
6
6
  */
7
- export declare const comicInfoHook: ({
8
- archive,
9
- baseUrl,
10
- }: {
11
- archive: Archive
12
- baseUrl: string
13
- }) => (manifest: Manifest) => Promise<Manifest>
7
+ export declare const comicInfoHook: ({ archive, baseUrl }: {
8
+ archive: Archive;
9
+ baseUrl: string;
10
+ }) => (manifest: Manifest) => Promise<Manifest>;
@@ -1,3 +1,6 @@
1
- import { Manifest } from "@prose-reader/shared"
2
- import { Archive } from "../../../archives/types"
3
- export declare const defaultHook: ({ archive, baseUrl }: { archive: Archive; baseUrl: string }) => () => Promise<Manifest>
1
+ import { Manifest } from "@prose-reader/shared";
2
+ import { Archive } from "../../../archives/types";
3
+ export declare const defaultHook: ({ archive, baseUrl }: {
4
+ archive: Archive;
5
+ baseUrl: string;
6
+ }) => () => Promise<Manifest>;
@@ -1,15 +1,12 @@
1
- import xmldoc from "xmldoc"
2
- import type { Manifest } from "@prose-reader/shared"
3
- import { Archive } from "../../../archives/types"
1
+ import xmldoc from "xmldoc";
2
+ import type { Manifest } from "@prose-reader/shared";
3
+ import { Archive } from "../../../archives/types";
4
4
  export declare const getItemsFromDoc: (doc: xmldoc.XmlDocument) => {
5
- href: string
6
- id: string
7
- mediaType: string | undefined
8
- }[]
9
- export declare const epubHook: ({
10
- archive,
11
- baseUrl,
12
- }: {
13
- archive: Archive
14
- baseUrl: string
15
- }) => (manifest: Manifest) => Promise<Manifest>
5
+ href: string;
6
+ id: string;
7
+ mediaType: string | undefined;
8
+ }[];
9
+ export declare const epubHook: ({ archive, baseUrl }: {
10
+ archive: Archive;
11
+ baseUrl: string;
12
+ }) => (manifest: Manifest) => Promise<Manifest>;
@@ -1,9 +1,6 @@
1
- import { Manifest } from "@prose-reader/shared"
2
- import { Archive } from "../../../archives/types"
3
- export declare const epubOptimizerHook: ({
4
- archive,
5
- baseUrl,
6
- }: {
7
- archive: Archive
8
- baseUrl: string
9
- }) => (manifest: Manifest) => Promise<Manifest>
1
+ import { Manifest } from "@prose-reader/shared";
2
+ import { Archive } from "../../../archives/types";
3
+ export declare const epubOptimizerHook: ({ archive, baseUrl }: {
4
+ archive: Archive;
5
+ baseUrl: string;
6
+ }) => (manifest: Manifest) => Promise<Manifest>;
@@ -1,15 +1,12 @@
1
- import { Manifest } from "@prose-reader/shared"
2
- import { Archive } from "../../../archives/types"
1
+ import { Manifest } from "@prose-reader/shared";
2
+ import { Archive } from "../../../archives/types";
3
3
  /**
4
4
  * In case no navigation was generated prior to this hook, we will try
5
5
  * to generate something based on the structure of the archive.
6
6
  *
7
7
  * We use folders as chapters.
8
8
  */
9
- export declare const navigationFallbackHook: ({
10
- archive,
11
- baseUrl,
12
- }: {
13
- archive: Archive
14
- baseUrl: string
15
- }) => (manifest: Manifest) => Promise<Manifest>
9
+ export declare const navigationFallbackHook: ({ archive, baseUrl }: {
10
+ archive: Archive;
11
+ baseUrl: string;
12
+ }) => (manifest: Manifest) => Promise<Manifest>;
@@ -1,10 +1,5 @@
1
- import type { Manifest } from "@prose-reader/shared"
2
- import { Archive } from "../../archives/types"
3
- export declare const generateManifestFromArchive: (
4
- archive: Archive,
5
- {
6
- baseUrl,
7
- }?: {
8
- baseUrl?: string | undefined
9
- }
10
- ) => Promise<Manifest>
1
+ import type { Manifest } from "@prose-reader/shared";
2
+ import { Archive } from "../../archives/types";
3
+ export declare const generateManifestFromArchive: (archive: Archive, { baseUrl }?: {
4
+ baseUrl?: string | undefined;
5
+ }) => Promise<Manifest>;
@@ -1,9 +1,6 @@
1
- import { Archive } from "../../../archives/types"
2
- import { HookResource } from "./types"
3
- export declare const cssFixHook: ({
4
- archive,
5
- resourcePath,
6
- }: {
7
- archive: Archive
8
- resourcePath: string
9
- }) => (resource: HookResource) => Promise<HookResource>
1
+ import { Archive } from "../../../archives/types";
2
+ import { HookResource } from "./types";
3
+ export declare const cssFixHook: ({ archive, resourcePath }: {
4
+ archive: Archive;
5
+ resourcePath: string;
6
+ }) => (resource: HookResource) => Promise<HookResource>;
@@ -1,9 +1,6 @@
1
- import { Archive } from "../../../archives/types"
2
- import { HookResource } from "./types"
3
- export declare const defaultHook: ({
4
- archive,
5
- resourcePath,
6
- }: {
7
- archive: Archive
8
- resourcePath: string
9
- }) => (resource: HookResource) => Promise<HookResource>
1
+ import { Archive } from "../../../archives/types";
2
+ import { HookResource } from "./types";
3
+ export declare const defaultHook: ({ archive, resourcePath }: {
4
+ archive: Archive;
5
+ resourcePath: string;
6
+ }) => (resource: HookResource) => Promise<HookResource>;
@@ -1,7 +1,7 @@
1
1
  export type HookResource = {
2
- body?: string
3
- params: {
4
- headers?: Record<string, string>
5
- status: number
6
- }
7
- }
2
+ body?: string;
3
+ params: {
4
+ headers?: Record<string, string>;
5
+ status: number;
6
+ };
7
+ };
@@ -1,20 +1,17 @@
1
- import { Archive } from "../.."
2
- export declare const generateResourceFromArchive: (
3
- archive: Archive,
4
- resourcePath: string
5
- ) => Promise<{
6
- body: string | Blob
7
- params: {
8
- headers?: Record<string, string> | undefined
9
- status: number
10
- }
11
- }>
1
+ import { Archive } from "../..";
2
+ export declare const generateResourceFromArchive: (archive: Archive, resourcePath: string) => Promise<{
3
+ body: string | Blob;
4
+ params: {
5
+ headers?: Record<string, string> | undefined;
6
+ status: number;
7
+ };
8
+ }>;
12
9
  export declare const generateResourceFromError: (error: unknown) => {
13
- body: string
14
- params: {
15
- status: number
16
- headers: {
17
- "Content-Type": string
18
- }
19
- }
20
- }
10
+ body: string;
11
+ params: {
12
+ status: number;
13
+ headers: {
14
+ "Content-Type": string;
15
+ };
16
+ };
17
+ };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- export { generateResourceFromArchive, generateResourceFromError } from "./generators/resources"
2
- export { generateManifestFromArchive } from "./generators/manifest"
3
- export { getArchiveOpfInfo } from "./archives/getArchiveOpfInfo"
4
- export { createArchiveFromUrls } from "./archives/createArchiveFromUrls"
5
- export { createArchiveFromText } from "./archives/createArchiveFromText"
6
- export { createArchiveFromJszip } from "./archives/createArchiveFromJszip"
7
- export { createArchiveFromArrayBufferList } from "./archives/createArchiveFromArrayBufferList"
8
- export type { Manifest } from "@prose-reader/shared"
9
- export type { Archive } from "./archives/types"
10
- export { configure } from "./configure"
1
+ export { generateResourceFromArchive, generateResourceFromError } from "./generators/resources";
2
+ export { generateManifestFromArchive } from "./generators/manifest";
3
+ export { getArchiveOpfInfo } from "./archives/getArchiveOpfInfo";
4
+ export { createArchiveFromUrls } from "./archives/createArchiveFromUrls";
5
+ export { createArchiveFromText } from "./archives/createArchiveFromText";
6
+ export { createArchiveFromJszip } from "./archives/createArchiveFromJszip";
7
+ export { createArchiveFromArrayBufferList } from "./archives/createArchiveFromArrayBufferList";
8
+ export type { Manifest } from "@prose-reader/shared";
9
+ export type { Archive } from "./archives/types";
10
+ export { configure } from "./configure";
@@ -1,6 +1,6 @@
1
- import { Archive } from ".."
1
+ import { Archive } from "..";
2
2
  type KoboInformation = {
3
- renditionLayout?: `reflowable` | `pre-paginated` | undefined
4
- }
5
- export declare const extractKoboInformationFromArchive: (archive: Archive) => Promise<KoboInformation>
6
- export {}
3
+ renditionLayout?: `reflowable` | `pre-paginated` | undefined;
4
+ };
5
+ export declare const extractKoboInformationFromArchive: (archive: Archive) => Promise<KoboInformation>;
6
+ export {};
@@ -1,11 +1,5 @@
1
- import xmldoc from "xmldoc"
2
- import { Archive } from ".."
3
- export declare const parseToc: (
4
- opfXmlDoc: xmldoc.XmlDocument,
5
- archive: Archive,
6
- {
7
- baseUrl,
8
- }: {
9
- baseUrl: string
10
- }
11
- ) => Promise<import("@prose-reader/shared").TocItem[] | undefined>
1
+ import xmldoc from "xmldoc";
2
+ import { Archive } from "..";
3
+ export declare const parseToc: (opfXmlDoc: xmldoc.XmlDocument, archive: Archive, { baseUrl }: {
4
+ baseUrl: string;
5
+ }) => Promise<import("@prose-reader/shared").TocItem[] | undefined>;