@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
@@ -0,0 +1,34 @@
1
+ export type ColorSpace = 'DeviceGray' | 'DeviceRGB';
2
+ export default class PNG {
3
+ static load: (data: Uint8Array) => PNG;
4
+ palette: number[];
5
+ imgData: Uint8Array;
6
+ transparency: {
7
+ indexed?: number[];
8
+ grayscale?: number;
9
+ rgb?: number[];
10
+ };
11
+ text: {
12
+ [key: string]: string;
13
+ };
14
+ width: number;
15
+ height: number;
16
+ bits: number;
17
+ colorType: number;
18
+ compressionMethod: number;
19
+ filterMethod: number;
20
+ interlaceMethod: number;
21
+ colors: 1 | 3;
22
+ hasAlphaChannel: boolean;
23
+ pixelBitlength: number;
24
+ colorSpace: ColorSpace;
25
+ private data;
26
+ private pos;
27
+ constructor(data: Uint8Array);
28
+ decode: () => Uint8Array;
29
+ copyImageDataToBuffer: (imageData: Uint8Array, pixels: Uint8Array) => void;
30
+ decodePixels: () => Uint8Array;
31
+ private read;
32
+ private readUInt32;
33
+ private decodePalette;
34
+ }
@@ -0,0 +1,18 @@
1
+ import { default as util } from 'util';
2
+ import { StartCanvasInfo } from '../download.js';
3
+ import { PdfDictionary } from './common.js';
4
+
5
+ export declare let textEncoder: TextEncoder | util.TextEncoder;
6
+ export declare let textDecoder: TextDecoder | util.TextDecoder;
7
+ export declare const IS_BIG_ENDIAN: boolean;
8
+ export interface TocItem {
9
+ label: string;
10
+ children?: Array<TocItem>;
11
+ startCanvas: StartCanvasInfo;
12
+ }
13
+ export declare function getNumChildren(itm: TocItem): number;
14
+ export declare function randomData(length: number): Uint8Array;
15
+ export declare function tryDeflateStream(pdfStream: Uint8Array | string): Promise<{
16
+ stream: Uint8Array | string;
17
+ dict: PdfDictionary;
18
+ }>;
@@ -0,0 +1,7 @@
1
+ export interface LicenseDescription {
2
+ text: string;
3
+ logo: string;
4
+ }
5
+ export type LicenseList = Record<string, LicenseDescription>;
6
+ export declare const licenses: LicenseList;
7
+ export declare function getLicenseInfo(uri: string): LicenseDescription | null;
@@ -0,0 +1,2 @@
1
+ /** sRGB color profile in ICM format, taken from https://github.com/bencomp/pdfx-ext. */
2
+ export declare const sRGBIEC1966_21: Uint8Array;
package/dist/util.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ export declare let saxParserWasm: Uint8Array | null;
2
+ /** Get a timestamp in milliseconds, prefereably high-resolution */
3
+ export declare function now(): number;
4
+ export declare function isDefined<T>(val: T | undefined | null | void): val is T;
5
+ export declare function crc32(data: Uint8Array): number;
6
+ export declare function runningInNode(): boolean;
7
+ export declare function initializeSaxParser(parserWasm: Uint8Array): void;
8
+ export declare function randomUUIDv4(): string;
@@ -0,0 +1,2 @@
1
+ declare const _default: "0.2.6";
2
+ export default _default;
package/package.json CHANGED
@@ -1,6 +1,151 @@
1
1
  {
2
2
  "name": "@aboutgeo/pdiiif",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.7",
4
+ "description": "Generate fully featured PDFs from IIIF manifests",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "scripts": {
8
+ "build": "vite build",
9
+ "docs": "typedoc --out ../docs src/index.ts",
10
+ "clean": "rm -rf dist",
11
+ "watch": "vite build --watch",
12
+ "format": "prettier -w ./src",
13
+ "lint": "eslint . --ext .ts && tsc --noemit --emitDeclarationOnly false",
14
+ "pretest": "tsc --noemit --emitDeclarationOnly false",
15
+ "posttest": "eslint . --ext .ts",
16
+ "prepack": "rm -rf dist && npm run build",
17
+ "test": "jest"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/jbaiter/pdiiif-lib.git"
22
+ },
23
+ "keywords": [
24
+ "iiif",
25
+ "pdf",
26
+ "ocr",
27
+ "annotations"
28
+ ],
29
+ "author": "Johannes Baiter <johannes.baiter@gmail.com>",
30
+ "license": "MIT",
31
+ "bugs": {
32
+ "url": "https://github.com/jbaiter/pdiiif/issues"
33
+ },
34
+ "homepage": "https://github.com/jbaiter/pdiiif/blob/main/pdiiif-lib/README.md",
35
+ "dependencies": {
36
+ "@atlas-viewer/iiif-image-api": "^2.2.2",
37
+ "@iiif/helpers": "^1.5.3",
38
+ "@iiif/parser": "^2.2.0",
39
+ "@iiif/presentation-2": "1.0.4",
40
+ "@iiif/presentation-3": "2.2.3",
41
+ "@iiif/presentation-3-normalized": "0.9.7",
42
+ "@jsquash/jpeg": "^1.5.0",
43
+ "async-mutex": "^0.4.1",
44
+ "color": "^4.2.3",
45
+ "dedent-js": "^1.0.1",
46
+ "fflate": "^0.8.2",
47
+ "ocr-parser": "^0.2.5",
48
+ "p-queue": "^7.4.1",
49
+ "path-data-polyfill": "^1.0.10",
50
+ "prom-client": "^14.2.0",
51
+ "sax-wasm": "^2.3.2",
52
+ "tslib": "^2.8.1",
53
+ "web-worker": "^1.5.0"
54
+ },
55
+ "overrides": {
56
+ "@iiif/parser": {
57
+ "@iiif/presentation-3": "^2.2.0"
58
+ }
59
+ },
60
+ "devDependencies": {
61
+ "@laynezh/vite-plugin-lib-assets": "^0.5.23",
62
+ "@types/color": "^3.0.6",
63
+ "@types/common-tags": "^1.8.4",
64
+ "@types/jest": "^29.5.12",
65
+ "@types/node": "~20.14.12",
66
+ "@types/tmp": "^0.2.6",
67
+ "@types/wicg-file-system-access": "^2020.9.8",
68
+ "@typescript-eslint/eslint-plugin": "^5.62.0",
69
+ "@typescript-eslint/parser": "^5.62.0",
70
+ "commander": "^10.0.1",
71
+ "eslint": "^8.57.0",
72
+ "eslint-config-prettier": "^8.10.0",
73
+ "globby": "^13.2.2",
74
+ "jest": "^29.7.0",
75
+ "jest-fetch-mock": "^3.0.3",
76
+ "magic-string": "^0.30.10",
77
+ "npm-run-all": "^4.1.5",
78
+ "pdf-lib": "^1.17.1",
79
+ "prettier": "^2.8.8",
80
+ "tmp": "^0.2.3",
81
+ "ts-jest": "^29.2.3",
82
+ "ts-node": "^10.9.2",
83
+ "typedoc": "^0.28.20",
84
+ "typescript": "~5.5.4",
85
+ "vite": "^5.3.5",
86
+ "vite-plugin-dts": "4.0.0-beta.1"
87
+ },
88
+ "engines": {
89
+ "node": ">=16.0.0"
90
+ },
91
+ "browser": {
92
+ "util": false,
93
+ "events": false,
94
+ "zlib": false,
95
+ "prom-client": false,
96
+ "crypto": false
97
+ },
98
+ "files": [
99
+ "/dist",
100
+ "/src"
101
+ ],
102
+ "main": "./dist/index.cjs",
103
+ "module": "./dist/index.mjs",
104
+ "types": "./dist/index.d.ts",
105
+ "exports": {
106
+ "./package.json": "./package.json",
107
+ ".": {
108
+ "types": "./dist/index.d.ts",
109
+ "require": "./dist/index.cjs",
110
+ "import": "./dist/index.mjs"
111
+ }
112
+ },
113
+ "prettier": {
114
+ "trailingComma": "es5",
115
+ "tabWidth": 2,
116
+ "semi": true,
117
+ "singleQuote": true
118
+ },
119
+ "jest": {
120
+ "roots": [
121
+ "<rootDir>/src"
122
+ ],
123
+ "moduleNameMapper": {
124
+ "^(\\.{1,2}/.*)\\.js$": "$1"
125
+ },
126
+ "setupFiles": [
127
+ "<rootDir>/src/__tests__/setupJest.ts"
128
+ ],
129
+ "testMatch": [
130
+ "**/?(*.)+(spec|test).+(ts|tsx|js)"
131
+ ],
132
+ "transform": {
133
+ "^.+\\.(ts|tsx)$": "ts-jest"
134
+ }
135
+ },
136
+ "eslintConfig": {
137
+ "root": true,
138
+ "ignorePatterns": "dist",
139
+ "parser": "@typescript-eslint/parser",
140
+ "plugins": [
141
+ "@typescript-eslint"
142
+ ],
143
+ "extends": [
144
+ "eslint:recommended",
145
+ "plugin:@typescript-eslint/recommended"
146
+ ],
147
+ "rules": {
148
+ "@typescript-eslint/no-explicit-any": "off"
149
+ }
150
+ }
151
+ }