@prose-reader/streamer 1.286.0 → 1.289.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.
@@ -9,7 +9,7 @@ type OnManifestSuccess = (params: {
9
9
  }) => Observable<Manifest> | Promise<Manifest>;
10
10
  type WithArchiveResponse = (archive: Archive) => Observable<Response> | Promise<Response>;
11
11
  export declare class Streamer {
12
- protected epubLoader: ReturnType<typeof createArchiveLoader>;
12
+ protected archiveLoader: ReturnType<typeof createArchiveLoader>;
13
13
  protected onError: OnError;
14
14
  protected onManifestSuccess: OnManifestSuccess;
15
15
  protected lastAccessedKey: string | undefined;
@@ -1,6 +1,8 @@
1
1
  import { Archive } from '../archives/types';
2
- export declare const getSpineItemFilesFromArchive: ({ archive, }: {
2
+ import { ArchiveOpfParsed } from './readArchiveOpf';
3
+ export declare const getSpineItemFilesFromArchive: ({ archive, archiveOpf, }: {
3
4
  archive: Archive;
5
+ archiveOpf: ArchiveOpfParsed | undefined;
4
6
  }) => Promise<({
5
7
  dir: false;
6
8
  basename: string;
@@ -0,0 +1,17 @@
1
+ import { OpfMetadata } from '@prose-reader/archive-parser';
2
+ import { Archive } from '../archives/types';
3
+ export type ArchiveOpfParsed = {
4
+ opf: OpfMetadata;
5
+ basePath: string;
6
+ };
7
+ /**
8
+ * Loads and parses the package OPF from `archive`.
9
+ *
10
+ * **Attention — not memoized:** every call re-reads the OPF record and runs
11
+ * `parseOpf`. Manifest generation already avoids redundant parses by awaiting
12
+ * this once and passing `archiveOpf` into manifest hooks. The resource pipeline
13
+ * (`generateResourceFromArchive` → `defaultHook`) invokes this again per
14
+ * resource unless callers later thread parsed OPF in explicitly (optional
15
+ * parameter, archive open hook, etc.).
16
+ */
17
+ export declare function readArchiveOpf(archive: Archive): Promise<ArchiveOpfParsed | undefined>;
@@ -1,10 +1,6 @@
1
1
  import { Manifest } from '@prose-reader/shared';
2
2
  import { Archive } from '../../../archives/types';
3
- /**
4
- * Handle archive which contains ComicInfo.xml. This is a meta file
5
- * used to define cbz, etc. I believe it comes from some sites or apps.
6
- */
7
- export declare const comicInfoHook: ({ archive }: {
3
+ export declare const comicInfo: ({ archive }: {
8
4
  archive: Archive;
9
5
  baseUrl: string;
10
6
  }) => (manifest: Manifest) => Promise<Manifest>;
@@ -1,12 +1,17 @@
1
1
  import { Manifest } from '@prose-reader/shared';
2
- import { XmlDocument, XmlElement } from 'xmldoc';
3
2
  import { Archive } from '../../../../archives/types';
4
- export declare const getItemsFromDoc: (doc: XmlDocument, archive: Archive, getBaseUrl?: (element: XmlElement) => string) => {
3
+ import { ArchiveOpfParsed } from '../../../../epubs/readArchiveOpf';
4
+ export declare const getItemsFromDoc: (manifestItems: ReadonlyArray<{
5
+ id: string;
6
+ href: string;
7
+ mediaType?: string;
8
+ }>, archive: Archive, getBaseUrlForHref?: (href: string) => string) => {
5
9
  href: string;
6
10
  id: string;
7
11
  mediaType: string | undefined;
8
12
  }[];
9
- export declare const epubHook: ({ archive, baseUrl }: {
13
+ export declare const epubHook: ({ archive, baseUrl, archiveOpf, }: {
10
14
  archive: Archive;
11
15
  baseUrl: string;
16
+ archiveOpf: ArchiveOpfParsed | undefined;
12
17
  }) => (manifest: Manifest) => Promise<Manifest>;
@@ -1,6 +1,8 @@
1
1
  import { Manifest } from '@prose-reader/shared';
2
2
  import { Archive } from '../../../archives/types';
3
- export declare const epubOptimizerHook: ({ archive }: {
3
+ import { ArchiveOpfParsed } from '../../../epubs/readArchiveOpf';
4
+ export declare const epubOptimizerHook: ({ archive, archiveOpf, }: {
4
5
  archive: Archive;
5
6
  baseUrl: string;
7
+ archiveOpf: ArchiveOpfParsed | undefined;
6
8
  }) => (manifest: Manifest) => Promise<Manifest>;
@@ -1,10 +1,12 @@
1
1
  import { Manifest } from '@prose-reader/shared';
2
2
  import { Archive } from '../../../archives/types';
3
+ import { ArchiveOpfParsed } from '../../../epubs/readArchiveOpf';
3
4
  /**
4
5
  * Resolve the table of contents from a single entry point.
5
6
  * Internally handles EPUB nav, NCX, and folder fallback.
6
7
  */
7
- export declare const tocHook: ({ archive, baseUrl }: {
8
+ export declare const tocHook: ({ archive, baseUrl, archiveOpf, }: {
8
9
  archive: Archive;
9
10
  baseUrl: string;
11
+ archiveOpf: ArchiveOpfParsed | undefined;
10
12
  }) => (manifest: Manifest) => Promise<Manifest>;
@@ -1,4 +1,16 @@
1
1
  import { Archive } from '../..';
2
+ /**
3
+ * Builds one streamed asset from `archive` (hot path: typically once per
4
+ * fetched file in the reader).
5
+ *
6
+ * **OPF limitation:** Unlike manifest generation, this API does not take
7
+ * `ArchiveOpfParsed`. `defaultHook` calls `readArchiveOpf(archive)` to resolve
8
+ * `media-type` from the package document, so EPUBs repeat OPF I/O + parse per
9
+ * resource. Usually fine (small OPF); if profiling shows regressions, address
10
+ * explicitly—e.g. optional `archiveOpf` (or equivalent) threaded from
11
+ * `Streamer.fetchResource` / manifest, or an opt-in cache on `Archive` wired at
12
+ * construction time—rather than hidden process-wide memoization.
13
+ */
2
14
  export declare const generateResourceFromArchive: (archive: Archive, resourcePath: string) => Promise<{
3
15
  body: string | Blob;
4
16
  params: {