@prose-reader/streamer 1.290.0 → 1.292.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.
@@ -0,0 +1,13 @@
1
+ /**
2
+ * This detector intentionally stays filename-only and conservative.
3
+ *
4
+ * Future improvements should consider archive sequence context before widening
5
+ * detection. For example, a spread such as `p002-003.jpg` is safer to split
6
+ * when neighboring resources make the sequence plausible, like `p001.jpg` and
7
+ * `p004.jpg`.
8
+ */
9
+ export type DetectedPageSpread = {
10
+ firstPageLabel: string;
11
+ secondPageLabel: string;
12
+ };
13
+ export declare const detectPageSpreadFromBasename: (basename: string) => DetectedPageSpread | undefined;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,48 @@
1
+ import { Manifest } from '@prose-reader/shared';
2
+ import { Archive } from '../archives/types';
3
+ export { type DetectedPageSpread, detectPageSpreadFromBasename, } from './detectPageSpreadFromBasename';
4
+ export type PageSpreadCropSide = "left" | "right";
5
+ export type VirtualPageSpreadResource = {
6
+ originalUri: string;
7
+ cropSide: PageSpreadCropSide;
8
+ };
9
+ export declare const PAGE_SPREAD_RESOURCE_PREFIX = "__prose-reader__/page-spread";
10
+ export declare const PAGE_SPREAD_SPLIT_DOCUMENT_MEDIA_TYPE = "application/xhtml+xml";
11
+ export declare const isPageSpreadSplitSupportedImage: (mimeType: string | undefined) => boolean;
12
+ type ArchiveRecord = Archive["records"][number];
13
+ type ArchiveFileRecord = Extract<ArchiveRecord, {
14
+ dir: false;
15
+ }>;
16
+ export declare const buildVirtualPageSpreadResourcePath: ({ cropSide, originalUri, }: {
17
+ originalUri: string;
18
+ cropSide: PageSpreadCropSide;
19
+ }) => string;
20
+ export declare const getArchiveRecordForManifestItem: ({ archive, baseUrl, spineItem, }: {
21
+ archive: Archive;
22
+ baseUrl: string;
23
+ spineItem: Manifest["spineItems"][number];
24
+ }) => {
25
+ dir: false;
26
+ basename: string;
27
+ uri: string;
28
+ blob: () => Promise<Blob>;
29
+ string: () => Promise<string>;
30
+ stream?: () => import('../archives/types').StreamResult;
31
+ size: number;
32
+ encodingFormat?: string;
33
+ } | {
34
+ dir: true;
35
+ basename: string;
36
+ uri: string;
37
+ size: number;
38
+ encodingFormat?: undefined;
39
+ } | undefined;
40
+ export declare const mediaTypeFromArchiveRecord: (record: {
41
+ basename: string;
42
+ encodingFormat?: string;
43
+ } | undefined) => string | undefined;
44
+ export declare const isPageSpreadSplitSupportedArchiveRecord: (record: ArchiveRecord | undefined) => record is ArchiveFileRecord;
45
+ export declare const pageSpreadSplit: ({ archive, baseUrl }: {
46
+ archive: Archive;
47
+ baseUrl: string;
48
+ }) => (manifest: Manifest) => Promise<Manifest>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,18 @@
1
+ import { Archive } from '../archives/types';
2
+ import { HookResource } from '../generators/resources/hooks/types';
3
+ import { PageSpreadCropSide, VirtualPageSpreadResource } from './pageSpreadSplitManifest';
4
+ type ImageDimensions = {
5
+ width: number;
6
+ height: number;
7
+ };
8
+ export declare const parseVirtualPageSpreadResourcePath: (resourcePath: string) => VirtualPageSpreadResource | undefined;
9
+ export declare const createPageSpreadSplitXhtml: ({ cropSide, imageDimensions, originalUri, }: {
10
+ cropSide: PageSpreadCropSide;
11
+ imageDimensions: ImageDimensions;
12
+ originalUri: string;
13
+ }) => string;
14
+ export declare const pageSpreadSplitResourceHook: ({ archive, resourcePath }: {
15
+ archive: Archive;
16
+ resourcePath: string;
17
+ }) => (resource: HookResource) => Promise<HookResource>;
18
+ export {};
@@ -0,0 +1,4 @@
1
+ export declare const createManifestResourceHref: ({ baseUrl, resourcePath, }: {
2
+ baseUrl?: string;
3
+ resourcePath: string;
4
+ }) => string;
@@ -1,5 +1,5 @@
1
1
  export type HookResource = {
2
- body?: string;
2
+ body?: Blob | string;
3
3
  params: {
4
4
  contentType?: string;
5
5
  };
@@ -1,4 +1,5 @@
1
1
  import { Archive } from '../..';
2
+ import { HookResource } from './hooks/types';
2
3
  /**
3
4
  * Builds one streamed asset from `archive` (hot path: typically once per
4
5
  * fetched file in the reader).
@@ -11,9 +12,4 @@ import { Archive } from '../..';
11
12
  * `Streamer.fetchResource` / manifest, or an opt-in cache on `Archive` wired at
12
13
  * construction time—rather than hidden process-wide memoization.
13
14
  */
14
- export declare const generateResourceFromArchive: (archive: Archive, resourcePath: string) => Promise<{
15
- body: string | Blob;
16
- params: {
17
- contentType?: string;
18
- };
19
- }>;
15
+ export declare const generateResourceFromArchive: (archive: Archive, resourcePath: string) => Promise<HookResource>;
@@ -0,0 +1 @@
1
+ export {};