@aboutgeo/pdiiif 0.0.0-stage → 0.2.7

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.
Files changed (69) hide show
  1. package/README.md +169 -2
  2. package/dist/__tests__/parser.test.d.ts +1 -0
  3. package/dist/__tests__/pdf.spec.d.ts +1 -0
  4. package/dist/__tests__/region.test.d.ts +1 -0
  5. package/dist/__tests__/setupJest.d.ts +0 -0
  6. package/dist/assets/optimization.worker-C8u4PFfM.js +886 -0
  7. package/dist/assets/optimization.worker-C8u4PFfM.js.map +1 -0
  8. package/dist/convert.d.ts +223 -0
  9. package/dist/download.d.ts +115 -0
  10. package/dist/iiif.d.ts +110 -0
  11. package/dist/index.cjs +65 -0
  12. package/dist/index.cjs.map +1 -0
  13. package/dist/index.d.ts +7 -0
  14. package/dist/index.mjs +11137 -0
  15. package/dist/index.mjs.map +1 -0
  16. package/dist/io.d.ts +75 -0
  17. package/dist/log.d.ts +21 -0
  18. package/dist/metrics.d.ts +10 -0
  19. package/dist/ocr.d.ts +36 -0
  20. package/dist/optimization.d.ts +48 -0
  21. package/dist/optimization.worker.d.ts +1 -0
  22. package/dist/pdf/annos-text.d.ts +19 -0
  23. package/dist/pdf/annos.d.ts +4 -0
  24. package/dist/pdf/common.d.ts +48 -0
  25. package/dist/pdf/generator.d.ts +197 -0
  26. package/dist/pdf/image.d.ts +34 -0
  27. package/dist/pdf/parser.d.ts +131 -0
  28. package/dist/pdf/pkzip.d.ts +23 -0
  29. package/dist/pdf/png.d.ts +34 -0
  30. package/dist/pdf/util.d.ts +18 -0
  31. package/dist/res/licenses.d.ts +7 -0
  32. package/dist/res/srgbColorspace.d.ts +2 -0
  33. package/dist/util.d.ts +8 -0
  34. package/dist/version.d.ts +2 -0
  35. package/package.json +149 -4
  36. package/src/__tests__/fixtures/deep_toc.json +2953 -0
  37. package/src/__tests__/fixtures/flat_toc.json +2917 -0
  38. package/src/__tests__/fixtures/physdim.json +294 -0
  39. package/src/__tests__/fixtures/region_target.json +58 -0
  40. package/src/__tests__/fixtures/wunder.jpg +0 -0
  41. package/src/__tests__/parser.test.ts +42 -0
  42. package/src/__tests__/pdf.spec.ts +216 -0
  43. package/src/__tests__/region.test.ts +194 -0
  44. package/src/__tests__/setupJest.ts +2 -0
  45. package/src/convert.ts +1098 -0
  46. package/src/download.ts +703 -0
  47. package/src/global.d.ts +10 -0
  48. package/src/iiif.ts +605 -0
  49. package/src/index.ts +7 -0
  50. package/src/io.ts +243 -0
  51. package/src/log.ts +51 -0
  52. package/src/metrics.ts +47 -0
  53. package/src/ocr.ts +176 -0
  54. package/src/optimization.ts +201 -0
  55. package/src/optimization.worker.ts +118 -0
  56. package/src/pdf/annos-text.ts +382 -0
  57. package/src/pdf/annos.ts +240 -0
  58. package/src/pdf/common.ts +158 -0
  59. package/src/pdf/generator.ts +1665 -0
  60. package/src/pdf/image.ts +340 -0
  61. package/src/pdf/parser.ts +811 -0
  62. package/src/pdf/pkzip.ts +228 -0
  63. package/src/pdf/png.ts +397 -0
  64. package/src/pdf/util.ts +111 -0
  65. package/src/res/licenses.ts +266 -0
  66. package/src/res/srgbColorspace.ts +405 -0
  67. package/src/types.d.ts +6 -0
  68. package/src/util.ts +55 -0
  69. package/src/version.ts +1 -0
package/dist/iiif.d.ts ADDED
@@ -0,0 +1,110 @@
1
+ import { InternationalString, ExternalWebResource, IIIFExternalWebResource, ContentResource, ImageProfile, ImageService, Reference, W3CAnnotationTarget } from '@iiif/presentation-3';
2
+ import { ManifestNormalized, CanvasNormalized, AnnotationNormalized } from '@iiif/presentation-3-normalized';
3
+ import { Vault, SupportedTarget } from '@iiif/helpers';
4
+
5
+ export declare const vault: Vault;
6
+ /** Given a language preference in descending order,
7
+ * determine the best set of strings from the
8
+ * internationalized string.
9
+ */
10
+ export declare function getI18nValue(val: string | InternationalString, languagePreference: readonly string[]): string[];
11
+ export declare function getI18nValue(val: string | InternationalString, languagePreference: readonly string[], separator: string): string;
12
+ export declare const getPaintables: (paintingAnnotationsOrCanvas: string | CanvasNormalized | AnnotationNormalized[], enabledChoices?: string[]) => import('@iiif/helpers').Paintables, getAllPaintingAnnotations: (canvasOrId: string | CanvasNormalized | undefined | null) => AnnotationNormalized[], extractChoices: (paintingAnnotationsOrCanvas: string | CanvasNormalized | AnnotationNormalized[]) => import('@iiif/helpers').ChoiceDescription | null;
13
+ /** Determine best thumbnail image for the manifest. */
14
+ export declare function getThumbnail(manifest: ManifestNormalized, maxDimension: number): Promise<string | undefined>;
15
+ /** Like a regular external web resource, but with an associated
16
+ profile URI, needed for OCR discovery */
17
+ export interface ExternalWebResourceWithProfile extends ExternalWebResource {
18
+ profile: string;
19
+ }
20
+ /** Check if a resource is an external resource with an
21
+ * associated profile. */
22
+ export declare function isExternalWebResourceWithProfile(res: ContentResource): res is ExternalWebResourceWithProfile;
23
+ /** See https://iiif.io/api/annex/services/#physical-dimensions */
24
+ export interface PhysicalDimensionService {
25
+ '@context': 'http://iiif.io/api/annex/services/physdim/1/context.json';
26
+ profile: 'http://iiif.io/api/annex/services/physdim';
27
+ '@id': string;
28
+ physicalScale: number;
29
+ physicalUnits: 'in' | 'cm' | 'mm';
30
+ }
31
+ /** Check if a service is a IIIF Physical Dimensions service */
32
+ export declare function isPhysicalDimensionService(service: any): service is PhysicalDimensionService;
33
+ /** Check if a IIIF Image endpoint supports arbitrary downscaling. */
34
+ export declare function supportsScaling(profile: ImageProfile): boolean;
35
+ /** Fetch the full IIIF Image service definition from
36
+ * its info.json endpoint. */
37
+ export declare function fetchFullImageService(serviceRef: ImageService): Promise<ImageService>;
38
+ export type ImageInfo = {
39
+ resource: (ExternalWebResource | IIIFExternalWebResource) & {
40
+ type: 'Image';
41
+ };
42
+ x: number;
43
+ y: number;
44
+ width: number;
45
+ height: number;
46
+ nativeWidth?: number;
47
+ nativeHeight?: number;
48
+ region?: string;
49
+ ppi?: number;
50
+ format?: 'jpeg' | 'png' | 'unsupported';
51
+ choiceInfo?: {
52
+ enabled: boolean;
53
+ optional: boolean;
54
+ visibleByDefault: boolean;
55
+ label?: InternationalString;
56
+ };
57
+ };
58
+ /** Information about a canvas that can be obtained without
59
+ * fetching any external resources */
60
+ export type CanvasInfo = {
61
+ canvas: Reference<'Canvas'>;
62
+ ocr?: {
63
+ id: string;
64
+ };
65
+ images: ImageInfo[];
66
+ numAnnotations: number;
67
+ };
68
+ /** Extract all non-painting annotations that are of interest for PDF generation
69
+ * from a canvas */
70
+ export declare function getCanvasAnnotations(canvas: CanvasNormalized): Annotation[];
71
+ /** Obtain all information about a canvas and its images
72
+ * without hitting any external endpoints.
73
+ */
74
+ export declare function getCanvasInfo(canvas: CanvasNormalized): CanvasInfo;
75
+ /** A annotation prepared for rendering to PDF. */
76
+ export interface Annotation {
77
+ id: string;
78
+ target: SupportedTarget;
79
+ markup: string;
80
+ lastModified?: Date;
81
+ author?: string;
82
+ }
83
+ /** Parse a IIIF annotation into a format that is more
84
+ * suitable for rendering to a PDF. */
85
+ export declare function parseAnnotation(anno: Omit<AnnotationNormalized, 'target'> & {
86
+ target: string | W3CAnnotationTarget | Array<Reference<'ContentResource'>>;
87
+ }, langPrefs: readonly string[]): Annotation | undefined;
88
+ export interface CompatibilityReport {
89
+ compatibility: 'compatible' | 'incompatible' | 'degraded';
90
+ incompatibleElements: {
91
+ [canvasId: string]: Set<'no-jpeg' | 'no-image' | 'annotations' | 'unsupported-painting'>;
92
+ };
93
+ }
94
+ export declare function checkCompatibility(manifest: ManifestNormalized): CompatibilityReport | undefined;
95
+ /** Parse a IIIF target specification */
96
+ export declare function parseTarget(targetStr: string): {
97
+ x: number;
98
+ y: number;
99
+ width: number;
100
+ height: number;
101
+ };
102
+ export declare function getImageFormat(image: ExternalWebResource | IIIFExternalWebResource): 'jpeg' | 'png' | 'unsupported' | undefined;
103
+ /** Extract the image region from the selector(s) of a `SpecificResource`.
104
+ *
105
+ * Supports the `ImageApiSelector` and, for plain image resources, a media
106
+ * fragment `FragmentSelector` (`xywh=`). Returns an IIIF Image API region string.
107
+ */
108
+ export declare function getRegionFromSelector(selector: any): string | undefined;
109
+ /** Get information about images on a Canvas. */
110
+ export declare function getImageInfos(canvas: CanvasNormalized): ImageInfo[];