@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.
- package/README.md +169 -2
- package/dist/__tests__/parser.test.d.ts +1 -0
- package/dist/__tests__/pdf.spec.d.ts +1 -0
- package/dist/__tests__/region.test.d.ts +1 -0
- package/dist/__tests__/setupJest.d.ts +0 -0
- package/dist/assets/optimization.worker-C8u4PFfM.js +886 -0
- package/dist/assets/optimization.worker-C8u4PFfM.js.map +1 -0
- package/dist/convert.d.ts +223 -0
- package/dist/download.d.ts +115 -0
- package/dist/iiif.d.ts +110 -0
- package/dist/index.cjs +65 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.mjs +11137 -0
- package/dist/index.mjs.map +1 -0
- package/dist/io.d.ts +75 -0
- package/dist/log.d.ts +21 -0
- package/dist/metrics.d.ts +10 -0
- package/dist/ocr.d.ts +36 -0
- package/dist/optimization.d.ts +48 -0
- package/dist/optimization.worker.d.ts +1 -0
- package/dist/pdf/annos-text.d.ts +19 -0
- package/dist/pdf/annos.d.ts +4 -0
- package/dist/pdf/common.d.ts +48 -0
- package/dist/pdf/generator.d.ts +197 -0
- package/dist/pdf/image.d.ts +34 -0
- package/dist/pdf/parser.d.ts +131 -0
- package/dist/pdf/pkzip.d.ts +23 -0
- package/dist/pdf/png.d.ts +34 -0
- package/dist/pdf/util.d.ts +18 -0
- package/dist/res/licenses.d.ts +7 -0
- package/dist/res/srgbColorspace.d.ts +2 -0
- package/dist/util.d.ts +8 -0
- package/dist/version.d.ts +2 -0
- package/package.json +149 -4
- package/src/__tests__/fixtures/deep_toc.json +2953 -0
- package/src/__tests__/fixtures/flat_toc.json +2917 -0
- package/src/__tests__/fixtures/physdim.json +294 -0
- package/src/__tests__/fixtures/region_target.json +58 -0
- package/src/__tests__/fixtures/wunder.jpg +0 -0
- package/src/__tests__/parser.test.ts +42 -0
- package/src/__tests__/pdf.spec.ts +216 -0
- package/src/__tests__/region.test.ts +194 -0
- package/src/__tests__/setupJest.ts +2 -0
- package/src/convert.ts +1098 -0
- package/src/download.ts +703 -0
- package/src/global.d.ts +10 -0
- package/src/iiif.ts +605 -0
- package/src/index.ts +7 -0
- package/src/io.ts +243 -0
- package/src/log.ts +51 -0
- package/src/metrics.ts +47 -0
- package/src/ocr.ts +176 -0
- package/src/optimization.ts +201 -0
- package/src/optimization.worker.ts +118 -0
- package/src/pdf/annos-text.ts +382 -0
- package/src/pdf/annos.ts +240 -0
- package/src/pdf/common.ts +158 -0
- package/src/pdf/generator.ts +1665 -0
- package/src/pdf/image.ts +340 -0
- package/src/pdf/parser.ts +811 -0
- package/src/pdf/pkzip.ts +228 -0
- package/src/pdf/png.ts +397 -0
- package/src/pdf/util.ts +111 -0
- package/src/res/licenses.ts +266 -0
- package/src/res/srgbColorspace.ts +405 -0
- package/src/types.d.ts +6 -0
- package/src/util.ts +55 -0
- package/src/version.ts +1 -0
package/src/pdf/util.ts
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import util from 'util';
|
|
2
|
+
import zlib from 'zlib';
|
|
3
|
+
import { zlibSync } from 'fflate';
|
|
4
|
+
import nodeCrypto from 'crypto';
|
|
5
|
+
|
|
6
|
+
import { StartCanvasInfo } from '../download.js';
|
|
7
|
+
import { PdfDictionary } from './common.js';
|
|
8
|
+
import log from '../log.js';
|
|
9
|
+
import { runningInNode } from '../util.js';
|
|
10
|
+
|
|
11
|
+
// Browsers have native encoders/decoders in the global namespace, use these
|
|
12
|
+
export let textEncoder: TextEncoder | util.TextEncoder;
|
|
13
|
+
export let textDecoder: TextDecoder | util.TextDecoder;
|
|
14
|
+
if (typeof TextEncoder !== 'undefined' && typeof TextDecoder !== 'undefined') {
|
|
15
|
+
textEncoder = new TextEncoder();
|
|
16
|
+
textDecoder = new TextDecoder();
|
|
17
|
+
} else {
|
|
18
|
+
textEncoder = new util.TextEncoder();
|
|
19
|
+
textDecoder = new util.TextDecoder();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// If running in node, use the web compatible crypto implementation
|
|
23
|
+
let cryptoImpl: Crypto;
|
|
24
|
+
if (runningInNode()) {
|
|
25
|
+
cryptoImpl = nodeCrypto.webcrypto as Crypto;
|
|
26
|
+
} else {
|
|
27
|
+
cryptoImpl = crypto;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const IS_BIG_ENDIAN = (() => {
|
|
31
|
+
const array = new Uint8Array(4);
|
|
32
|
+
const view = new Uint32Array(array.buffer);
|
|
33
|
+
return !((view[0] = 1) & array[0]);
|
|
34
|
+
})();
|
|
35
|
+
|
|
36
|
+
export interface TocItem {
|
|
37
|
+
label: string;
|
|
38
|
+
children?: Array<TocItem>;
|
|
39
|
+
startCanvas: StartCanvasInfo;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function getNumChildren(itm: TocItem): number {
|
|
43
|
+
const children = itm.children ?? [];
|
|
44
|
+
return (
|
|
45
|
+
children.length + children.map(getNumChildren).reduce((a, b) => a + b, 0)
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function randomData(length: number): Uint8Array {
|
|
50
|
+
if (length > 2 ** 16) {
|
|
51
|
+
length = 2 ** 16;
|
|
52
|
+
}
|
|
53
|
+
const buf = new Uint8Array(length);
|
|
54
|
+
if (cryptoImpl !== undefined) {
|
|
55
|
+
cryptoImpl.getRandomValues(buf);
|
|
56
|
+
} else {
|
|
57
|
+
const u32View = new Uint32Array(buf.buffer);
|
|
58
|
+
for (let i = 0; i < u32View.length; i++) {
|
|
59
|
+
u32View[i] = Math.floor(Math.random() * 2 ** 32);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return buf;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export async function tryDeflateStream(
|
|
66
|
+
pdfStream: Uint8Array | string
|
|
67
|
+
): Promise<{ stream: Uint8Array | string; dict: PdfDictionary }> {
|
|
68
|
+
const data =
|
|
69
|
+
pdfStream instanceof Uint8Array ? pdfStream : textEncoder.encode(pdfStream);
|
|
70
|
+
let compressed: Uint8Array;
|
|
71
|
+
if (!runningInNode()) {
|
|
72
|
+
if (typeof CompressionStream === 'undefined') {
|
|
73
|
+
// Browser doesn't support CompressionStream API, try to use the JS implementation
|
|
74
|
+
try {
|
|
75
|
+
let bytes: Uint8Array;
|
|
76
|
+
if (pdfStream instanceof Uint8Array) {
|
|
77
|
+
bytes = pdfStream;
|
|
78
|
+
} else {
|
|
79
|
+
bytes = textEncoder.encode(pdfStream);
|
|
80
|
+
}
|
|
81
|
+
compressed = zlibSync(bytes);
|
|
82
|
+
return Promise.resolve({
|
|
83
|
+
stream: compressed,
|
|
84
|
+
dict: { Length: compressed.length, Filter: '/FlateDecode' },
|
|
85
|
+
});
|
|
86
|
+
} catch (err) {
|
|
87
|
+
log.warn(
|
|
88
|
+
`Failed to use JS deflate implementation, data will be written uncompressed: ${err}`
|
|
89
|
+
);
|
|
90
|
+
return Promise.resolve({
|
|
91
|
+
stream: pdfStream,
|
|
92
|
+
dict: { Length: pdfStream.length },
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const compStream = new CompressionStream('deflate');
|
|
97
|
+
const c = new Blob([data]).stream().pipeThrough(compStream);
|
|
98
|
+
compressed = new Uint8Array(await new Response(c).arrayBuffer());
|
|
99
|
+
} else {
|
|
100
|
+
compressed = await new Promise((resolve, reject) =>
|
|
101
|
+
zlib.deflate(data, (err, buf) => (err ? reject(err) : resolve(buf)))
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
dict: {
|
|
106
|
+
Length: compressed.length,
|
|
107
|
+
Filter: '/FlateDecode',
|
|
108
|
+
},
|
|
109
|
+
stream: compressed,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
export interface LicenseDescription {
|
|
2
|
+
text: string;
|
|
3
|
+
logo: string;
|
|
4
|
+
}
|
|
5
|
+
export type LicenseList = Record<string, LicenseDescription>;
|
|
6
|
+
|
|
7
|
+
// TODO: Re-generate this list based on the official CC RDF files:
|
|
8
|
+
// https://github.com/creativecommons/cc-licenses-data/blob/main/legacy/rdf-licenses
|
|
9
|
+
export const licenses: LicenseList = {
|
|
10
|
+
'http://creativecommons.org/licenses/by-nc-sa/2.0/fr/': {
|
|
11
|
+
text: 'Creative Commons Attribution-NonCommercial-ShareAlike 2.0 France (CC-BY-NC-SA-2.0-FR)',
|
|
12
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nc-sa.svg',
|
|
13
|
+
},
|
|
14
|
+
'http://creativecommons.org/licenses/by-sa/4.0/': {
|
|
15
|
+
text: 'Creative Commons Attribution Share Alike 4.0 International (CC-BY-SA-4.0)',
|
|
16
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-sa.svg',
|
|
17
|
+
},
|
|
18
|
+
'http://creativecommons.org/licenses/by/3.0/de/': {
|
|
19
|
+
text: 'Creative Commons Attribution 3.0 Germany (CC-BY-3.0-DE)',
|
|
20
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by.svg',
|
|
21
|
+
},
|
|
22
|
+
'http://creativecommons.org/licenses/by-nc-nd/3.0/': {
|
|
23
|
+
text: 'Creative Commons Attribution Non Commercial No Derivatives 3.0 Unported (CC-BY-NC-ND-3.0)',
|
|
24
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nc-nd.svg',
|
|
25
|
+
},
|
|
26
|
+
'http://creativecommons.org/licenses/by/1.0/': {
|
|
27
|
+
text: 'Creative Commons Attribution 1.0 Generic (CC-BY-1.0)',
|
|
28
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by.svg',
|
|
29
|
+
},
|
|
30
|
+
'http://creativecommons.org/licenses/by-nd/1.0/': {
|
|
31
|
+
text: 'Creative Commons Attribution No Derivatives 1.0 Generic (CC-BY-ND-1.0)',
|
|
32
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nd.svg',
|
|
33
|
+
},
|
|
34
|
+
'http://creativecommons.org/licenses/by-nc-sa/3.0/de/': {
|
|
35
|
+
text: 'Creative Commons Attribution Non Commercial Share Alike 3.0 Germany (CC-BY-NC-SA-3.0-DE)',
|
|
36
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nc-sa.svg',
|
|
37
|
+
},
|
|
38
|
+
'http://creativecommons.org/licenses/by-nc-sa/1.0/': {
|
|
39
|
+
text: 'Creative Commons Attribution Non Commercial Share Alike 1.0 Generic (CC-BY-NC-SA-1.0)',
|
|
40
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nc-sa.svg',
|
|
41
|
+
},
|
|
42
|
+
'http://creativecommons.org/licenses/by-nd/4.0/': {
|
|
43
|
+
text: 'Creative Commons Attribution No Derivatives 4.0 International (CC-BY-ND-4.0)',
|
|
44
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nd.svg',
|
|
45
|
+
},
|
|
46
|
+
'http://creativecommons.org/licenses/by-sa/3.0/at/': {
|
|
47
|
+
text: 'Creative Commons Attribution Share Alike 3.0 Austria (CC-BY-SA-3.0-AT)',
|
|
48
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-sa.svg',
|
|
49
|
+
},
|
|
50
|
+
'http://creativecommons.org/licenses/by/3.0/at/': {
|
|
51
|
+
text: 'Creative Commons Attribution 3.0 Austria (CC-BY-3.0-AT)',
|
|
52
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by.svg',
|
|
53
|
+
},
|
|
54
|
+
'http://creativecommons.org/licenses/by/3.0/': {
|
|
55
|
+
text: 'Creative Commons Attribution 3.0 Unported (CC-BY-3.0)',
|
|
56
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by.svg',
|
|
57
|
+
},
|
|
58
|
+
'http://creativecommons.org/licenses/by-nc/2.0/': {
|
|
59
|
+
text: 'Creative Commons Attribution Non Commercial 2.0 Generic (CC-BY-NC-2.0)',
|
|
60
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nc.svg',
|
|
61
|
+
},
|
|
62
|
+
'http://creativecommons.org/licenses/by-nc-sa/2.5/': {
|
|
63
|
+
text: 'Creative Commons Attribution Non Commercial Share Alike 2.5 Generic (CC-BY-NC-SA-2.5)',
|
|
64
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nc-sa.svg',
|
|
65
|
+
},
|
|
66
|
+
'http://creativecommons.org/licenses/by-nc/2.5/': {
|
|
67
|
+
text: 'Creative Commons Attribution Non Commercial 2.5 Generic (CC-BY-NC-2.5)',
|
|
68
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nc.svg',
|
|
69
|
+
},
|
|
70
|
+
'http://creativecommons.org/licenses/by-nd-nc/1.0/': {
|
|
71
|
+
text: 'Creative Commons Attribution Non Commercial No Derivatives 1.0 Generic (CC-BY-NC-ND-1.0)',
|
|
72
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nc-nd.svg',
|
|
73
|
+
},
|
|
74
|
+
'http://creativecommons.org/licenses/by-nd/3.0/': {
|
|
75
|
+
text: 'Creative Commons Attribution No Derivatives 3.0 Unported (CC-BY-ND-3.0)',
|
|
76
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nd.svg',
|
|
77
|
+
},
|
|
78
|
+
'http://creativecommons.org/licenses/by-sa/2.5/': {
|
|
79
|
+
text: 'Creative Commons Attribution Share Alike 2.5 Generic (CC-BY-SA-2.5)',
|
|
80
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-sa.svg',
|
|
81
|
+
},
|
|
82
|
+
'http://creativecommons.org/licenses/by-nc-sa/2.0/uk/': {
|
|
83
|
+
text: 'Creative Commons Attribution Non Commercial Share Alike 2.0 England and Wales (CC-BY-NC-SA-2.0-UK)',
|
|
84
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nc-sa.svg',
|
|
85
|
+
},
|
|
86
|
+
'http://creativecommons.org/licenses/by/2.0/': {
|
|
87
|
+
text: 'Creative Commons Attribution 2.0 Generic (CC-BY-2.0)',
|
|
88
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by.svg',
|
|
89
|
+
},
|
|
90
|
+
'http://creativecommons.org/licenses/by-nd/2.5/': {
|
|
91
|
+
text: 'Creative Commons Attribution No Derivatives 2.5 Generic (CC-BY-ND-2.5)',
|
|
92
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nd.svg',
|
|
93
|
+
},
|
|
94
|
+
'http://creativecommons.org/licenses/by-nc-nd/2.0/': {
|
|
95
|
+
text: 'Creative Commons Attribution Non Commercial No Derivatives 2.0 Generic (CC-BY-NC-ND-2.0)',
|
|
96
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nc-nd.svg',
|
|
97
|
+
},
|
|
98
|
+
'http://creativecommons.org/licenses/by-nc-sa/3.0/igo/': {
|
|
99
|
+
text: 'Creative Commons Attribution Non Commercial Share Alike 3.0 IGO (CC-BY-NC-SA-3.0-IGO)',
|
|
100
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nc-sa.svg',
|
|
101
|
+
},
|
|
102
|
+
'http://creativecommons.org/licenses/publicdomain//': {
|
|
103
|
+
text: 'Creative Commons Public Domain Dedication and Certification (CC-PDDC)',
|
|
104
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/publicdomain.svg',
|
|
105
|
+
},
|
|
106
|
+
'http://creativecommons.org/licenses/by-nc-sa/2.0/': {
|
|
107
|
+
text: 'Creative Commons Attribution Non Commercial Share Alike 2.0 Generic (CC-BY-NC-SA-2.0)',
|
|
108
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nc-sa.svg',
|
|
109
|
+
},
|
|
110
|
+
'http://creativecommons.org/licenses/by-nc-nd/3.0/de/': {
|
|
111
|
+
text: 'Creative Commons Attribution Non Commercial No Derivatives 3.0 Germany (CC-BY-NC-ND-3.0-DE)',
|
|
112
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nc-nd.svg',
|
|
113
|
+
},
|
|
114
|
+
'http://creativecommons.org/licenses/by-nc/3.0/': {
|
|
115
|
+
text: 'Creative Commons Attribution Non Commercial 3.0 Unported (CC-BY-NC-3.0)',
|
|
116
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nc.svg',
|
|
117
|
+
},
|
|
118
|
+
'http://creativecommons.org/licenses/by-nc/3.0/de/': {
|
|
119
|
+
text: 'Creative Commons Attribution Non Commercial 3.0 Germany (CC-BY-NC-3.0-DE)',
|
|
120
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nc.svg',
|
|
121
|
+
},
|
|
122
|
+
'http://creativecommons.org/licenses/by-sa/1.0/': {
|
|
123
|
+
text: 'Creative Commons Attribution Share Alike 1.0 Generic (CC-BY-SA-1.0)',
|
|
124
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-sa.svg',
|
|
125
|
+
},
|
|
126
|
+
'http://creativecommons.org/licenses/by-nd/3.0/de/': {
|
|
127
|
+
text: 'Creative Commons Attribution No Derivatives 3.0 Germany (CC-BY-ND-3.0-DE)',
|
|
128
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nd.svg',
|
|
129
|
+
},
|
|
130
|
+
'http://creativecommons.org/licenses/by-nc-nd/2.5/': {
|
|
131
|
+
text: 'Creative Commons Attribution Non Commercial No Derivatives 2.5 Generic (CC-BY-NC-ND-2.5)',
|
|
132
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nc-nd.svg',
|
|
133
|
+
},
|
|
134
|
+
'http://creativecommons.org/licenses/by-sa/3.0/': {
|
|
135
|
+
text: 'Creative Commons Attribution Share Alike 3.0 Unported (CC-BY-SA-3.0)',
|
|
136
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-sa.svg',
|
|
137
|
+
},
|
|
138
|
+
'http://creativecommons.org/licenses/by-nc-sa/4.0/': {
|
|
139
|
+
text: 'Creative Commons Attribution Non Commercial Share Alike 4.0 International (CC-BY-NC-SA-4.0)',
|
|
140
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nc-sa.svg',
|
|
141
|
+
},
|
|
142
|
+
'http://creativecommons.org/licenses/by-sa/2.0/': {
|
|
143
|
+
text: 'Creative Commons Attribution Share Alike 2.0 Generic (CC-BY-SA-2.0)',
|
|
144
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-sa.svg',
|
|
145
|
+
},
|
|
146
|
+
'http://creativecommons.org/licenses/by-sa/2.1/jp/': {
|
|
147
|
+
text: 'Creative Commons Attribution Share Alike 2.1 Japan (CC-BY-SA-2.1-JP)',
|
|
148
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-sa.svg',
|
|
149
|
+
},
|
|
150
|
+
'http://creativecommons.org/licenses/by/2.5/': {
|
|
151
|
+
text: 'Creative Commons Attribution 2.5 Generic (CC-BY-2.5)',
|
|
152
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by.svg',
|
|
153
|
+
},
|
|
154
|
+
'http://creativecommons.org/licenses/by-sa/2.0/uk/': {
|
|
155
|
+
text: 'Creative Commons Attribution Share Alike 2.0 England and Wales (CC-BY-SA-2.0-UK)',
|
|
156
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-sa.svg',
|
|
157
|
+
},
|
|
158
|
+
'http://creativecommons.org/licenses/by/3.0/nl/': {
|
|
159
|
+
text: 'Creative Commons Attribution 3.0 Netherlands (CC-BY-3.0-NL)',
|
|
160
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by.svg',
|
|
161
|
+
},
|
|
162
|
+
'http://creativecommons.org/licenses/by-nc-sa/3.0/': {
|
|
163
|
+
text: 'Creative Commons Attribution Non Commercial Share Alike 3.0 Unported (CC-BY-NC-SA-3.0)',
|
|
164
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nc-sa.svg',
|
|
165
|
+
},
|
|
166
|
+
'http://creativecommons.org/licenses/by/4.0/': {
|
|
167
|
+
text: 'Creative Commons Attribution 4.0 International (CC-BY-4.0)',
|
|
168
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by.svg',
|
|
169
|
+
},
|
|
170
|
+
'http://creativecommons.org/licenses/by/3.0/us/': {
|
|
171
|
+
text: 'Creative Commons Attribution 3.0 United States (CC-BY-3.0-US)',
|
|
172
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by.svg',
|
|
173
|
+
},
|
|
174
|
+
'http://creativecommons.org/licenses/by-nc-nd/4.0/': {
|
|
175
|
+
text: 'Creative Commons Attribution Non Commercial No Derivatives 4.0 International (CC-BY-NC-ND-4.0)',
|
|
176
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nc-nd.svg',
|
|
177
|
+
},
|
|
178
|
+
'http://creativecommons.org/licenses/by-sa/3.0/de/': {
|
|
179
|
+
text: 'Creative Commons Attribution Share Alike 3.0 Germany (CC-BY-SA-3.0-DE)',
|
|
180
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-sa.svg',
|
|
181
|
+
},
|
|
182
|
+
'http://creativecommons.org/licenses/by-nc-nd/3.0/igo/': {
|
|
183
|
+
text: 'Creative Commons Attribution Non Commercial No Derivatives 3.0 IGO (CC-BY-NC-ND-3.0-IGO)',
|
|
184
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nc-nd.svg',
|
|
185
|
+
},
|
|
186
|
+
'http://creativecommons.org/publicdomain/zero/1.0/': {
|
|
187
|
+
text: 'Creative Commons Zero v1.0 Universal (CC0-1.0)',
|
|
188
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/cc-zero.svg',
|
|
189
|
+
},
|
|
190
|
+
'http://creativecommons.org/publicdomain/mark/1.0/': {
|
|
191
|
+
text: 'Public Domain Mark 1.0: No Copyright',
|
|
192
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/publicdomain.svg',
|
|
193
|
+
},
|
|
194
|
+
'http://creativecommons.org/licenses/by/2.5/au/': {
|
|
195
|
+
text: 'Creative Commons Attribution 2.5 Australia (CC-BY-2.5-AU)',
|
|
196
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by.svg',
|
|
197
|
+
},
|
|
198
|
+
'http://creativecommons.org/licenses/by-nd/2.0/': {
|
|
199
|
+
text: 'Creative Commons Attribution No Derivatives 2.0 Generic (CC-BY-ND-2.0)',
|
|
200
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nd.svg',
|
|
201
|
+
},
|
|
202
|
+
'http://creativecommons.org/licenses/by-nc/1.0/': {
|
|
203
|
+
text: 'Creative Commons Attribution Non Commercial 1.0 Generic (CC-BY-NC-1.0)',
|
|
204
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nc.svg',
|
|
205
|
+
},
|
|
206
|
+
'http://creativecommons.org/licenses/by-nc/4.0/': {
|
|
207
|
+
text: 'Creative Commons Attribution Non Commercial 4.0 International (CC-BY-NC-4.0)',
|
|
208
|
+
logo: 'https://mirrors.creativecommons.org/presskit/buttons/88x31/svg/by-nc.svg',
|
|
209
|
+
},
|
|
210
|
+
'http://rightsstatements.org/vocab/InC/1.0/': {
|
|
211
|
+
text: 'In Copyright',
|
|
212
|
+
logo: 'https://rightsstatements.org/files/buttons/InC.dark.svg',
|
|
213
|
+
},
|
|
214
|
+
'http://rightsstatements.org/vocab/InC-OW-EU/1.0/': {
|
|
215
|
+
text: 'In Copyright - EU Orphan Work',
|
|
216
|
+
logo: 'https://rightsstatements.org/files/buttons/InC-OW-EU.dark.svg',
|
|
217
|
+
},
|
|
218
|
+
'http://rightsstatements.org/vocab/InC-EDU/1.0/': {
|
|
219
|
+
text: 'In Copyright - Educational Use Permitted',
|
|
220
|
+
logo: 'https://rightsstatements.org/files/buttons/InC-EDU.dark.svg',
|
|
221
|
+
},
|
|
222
|
+
'http://rightsstatements.org/vocab/InC-NC/1.0/': {
|
|
223
|
+
text: 'In Copyright - Non-Commercial Use Permitted',
|
|
224
|
+
logo: 'https://rightsstatements.org/files/buttons/InC-NC.dark.svg',
|
|
225
|
+
},
|
|
226
|
+
'http://rightsstatements.org/vocab/InC-RUU/1.0/': {
|
|
227
|
+
text: 'In Copyright - Rights-holder(s) Unlocatable or Unidentifiable',
|
|
228
|
+
logo: 'https://rightsstatements.org/files/buttons/InC-RUU.dark.svg',
|
|
229
|
+
},
|
|
230
|
+
'http://rightsstatements.org/vocab/NoC-CR/1.0/': {
|
|
231
|
+
text: 'No Copyright - Contractual Restrictions',
|
|
232
|
+
logo: 'https://rightsstatements.org/files/buttons/NoC-CR.dark.svg',
|
|
233
|
+
},
|
|
234
|
+
'http://rightsstatements.org/vocab/NoC-NC/1.0/': {
|
|
235
|
+
text: 'No Copyright - Non-Commercial Use Only',
|
|
236
|
+
logo: 'https://rightsstatements.org/files/buttons/NoC-NC.dark.svg',
|
|
237
|
+
},
|
|
238
|
+
'http://rightsstatements.org/vocab/NoC-OKLR/1.0/': {
|
|
239
|
+
text: 'No Copyright - Other Known Legal Restrictions',
|
|
240
|
+
logo: 'https://rightsstatements.org/files/buttons/NoC-OKLR.dark.svg',
|
|
241
|
+
},
|
|
242
|
+
'http://rightsstatements.org/vocab/NoC-US/1.0/': {
|
|
243
|
+
text: 'No Copyright - United States',
|
|
244
|
+
logo: 'https://rightsstatements.org/files/buttons/NoC-US.dark.svg',
|
|
245
|
+
},
|
|
246
|
+
'http://rightsstatements.org/vocab/CNE/1.0/': {
|
|
247
|
+
text: 'Copyright Not Evaluated',
|
|
248
|
+
logo: 'https://rightsstatements.org/files/buttons/CNE.dark.svg',
|
|
249
|
+
},
|
|
250
|
+
'http://rightsstatements.org/vocab/UND/1.0/': {
|
|
251
|
+
text: 'Copyright Undetermined',
|
|
252
|
+
logo: 'https://rightsstatements.org/files/buttons/UND.dark.svg',
|
|
253
|
+
},
|
|
254
|
+
'http://rightsstatements.org/vocab/NKC/1.0/': {
|
|
255
|
+
text: 'No Known Copyright',
|
|
256
|
+
logo: 'https://rightsstatements.org/files/buttons/NKC.dark.svg',
|
|
257
|
+
},
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
export function getLicenseInfo(uri: string): LicenseDescription | null {
|
|
261
|
+
uri = uri.replace(/^https:/, 'http:').replace(/\/deed\.[a-z]{2}$/, '');
|
|
262
|
+
if (!uri.endsWith('/')) {
|
|
263
|
+
uri += '/';
|
|
264
|
+
}
|
|
265
|
+
return licenses[uri];
|
|
266
|
+
}
|