@readium/shared 2.2.0-beta.3 → 2.2.1
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/dist/index.js +391 -377
- package/dist/index.umd.cjs +3 -3
- package/package.json +1 -1
- package/src/fetcher/Fetcher.ts +2 -2
- package/src/fetcher/HttpFetcher.ts +3 -3
- package/src/fetcher/Resource.ts +1 -1
- package/src/fetcher/index.ts +3 -3
- package/src/index.ts +4 -4
- package/src/opds/Availability.ts +1 -1
- package/src/opds/Copies.ts +1 -1
- package/src/opds/Holds.ts +1 -1
- package/src/opds/Price.ts +1 -1
- package/src/opds/index.ts +5 -5
- package/src/publication/BelongsTo.ts +1 -1
- package/src/publication/Contributor.ts +4 -4
- package/src/publication/GuidedNavigation.ts +19 -19
- package/src/publication/Link.ts +6 -6
- package/src/publication/Locator.ts +1 -1
- package/src/publication/LocatorCollection.ts +4 -4
- package/src/publication/Manifest.ts +29 -20
- package/src/publication/Metadata.ts +13 -13
- package/src/publication/Publication.ts +15 -17
- package/src/publication/PublicationCollection.ts +1 -1
- package/src/publication/ReadingProgression.ts +1 -1
- package/src/publication/Subject.ts +2 -2
- package/src/publication/accessibility/AccessibilityMetadataDisplayGuide.ts +20 -20
- package/src/publication/accessibility/Localization.ts +15 -15
- package/src/publication/accessibility/index.ts +3 -3
- package/src/publication/encryption/Properties.ts +2 -2
- package/src/publication/encryption/index.ts +2 -2
- package/src/publication/epub/Metadata.ts +3 -3
- package/src/publication/epub/Properties.ts +1 -1
- package/src/publication/epub/Publication.ts +2 -2
- package/src/publication/epub/index.ts +4 -4
- package/src/publication/html/DomRange.ts +1 -1
- package/src/publication/html/DomRangePoint.ts +1 -1
- package/src/publication/html/Locations.ts +3 -3
- package/src/publication/html/index.ts +3 -3
- package/src/publication/index.ts +24 -24
- package/src/publication/opds/Properties.ts +4 -4
- package/src/publication/opds/Publication.ts +2 -2
- package/src/publication/opds/index.ts +2 -2
- package/src/publication/services/content/Content.ts +3 -3
- package/src/publication/services/content/ContentTokenizer.ts +6 -6
- package/src/publication/services/content/Iterator.ts +2 -2
- package/src/publication/services/content/element/attributes.ts +2 -2
- package/src/publication/services/content/element/element.ts +5 -5
- package/src/publication/services/content/element/index.ts +3 -3
- package/src/publication/services/content/index.ts +5 -5
- package/src/publication/services/content/iterators/HTMLResourceContentIterator.ts +8 -8
- package/src/publication/services/content/iterators/PDFTextContentIterator.ts +21 -21
- package/src/publication/services/content/iterators/PublicationContentIterator.ts +7 -7
- package/src/publication/services/content/iterators/helpers.ts +1 -1
- package/src/publication/services/content/iterators/index.ts +3 -3
- package/src/publication/services/index.ts +2 -2
- package/src/publication/services/timeline/Timeline.ts +52 -29
- package/src/publication/services/timeline/index.ts +2 -2
- package/src/util/index.ts +5 -5
- package/src/util/mediatype/index.ts +1 -1
- package/src/util/tokenizer/TextTokenizer.ts +5 -5
- package/src/util/tokenizer/index.ts +2 -2
- package/types/src/fetcher/Fetcher.d.ts +2 -2
- package/types/src/fetcher/HttpFetcher.d.ts +3 -3
- package/types/src/fetcher/Resource.d.ts +1 -1
- package/types/src/fetcher/index.d.ts +3 -3
- package/types/src/index.d.ts +4 -4
- package/types/src/opds/index.d.ts +5 -5
- package/types/src/publication/BelongsTo.d.ts +1 -1
- package/types/src/publication/Contributor.d.ts +3 -3
- package/types/src/publication/GuidedNavigation.d.ts +1 -1
- package/types/src/publication/Link.d.ts +3 -3
- package/types/src/publication/LocatorCollection.d.ts +3 -3
- package/types/src/publication/Manifest.d.ts +6 -6
- package/types/src/publication/Metadata.d.ts +10 -10
- package/types/src/publication/Publication.d.ts +12 -13
- package/types/src/publication/PublicationCollection.d.ts +1 -1
- package/types/src/publication/ReadingProgression.d.ts +1 -1
- package/types/src/publication/Subject.d.ts +2 -2
- package/types/src/publication/accessibility/AccessibilityMetadataDisplayGuide.d.ts +2 -2
- package/types/src/publication/accessibility/index.d.ts +3 -3
- package/types/src/publication/encryption/Properties.d.ts +1 -1
- package/types/src/publication/encryption/index.d.ts +2 -2
- package/types/src/publication/epub/Metadata.d.ts +1 -1
- package/types/src/publication/epub/Publication.d.ts +1 -1
- package/types/src/publication/epub/index.d.ts +4 -4
- package/types/src/publication/html/DomRange.d.ts +1 -1
- package/types/src/publication/html/Locations.d.ts +1 -1
- package/types/src/publication/html/index.d.ts +3 -3
- package/types/src/publication/index.d.ts +24 -24
- package/types/src/publication/opds/Properties.d.ts +2 -2
- package/types/src/publication/opds/Publication.d.ts +1 -1
- package/types/src/publication/opds/index.d.ts +2 -2
- package/types/src/publication/services/content/Content.d.ts +2 -2
- package/types/src/publication/services/content/ContentTokenizer.d.ts +2 -2
- package/types/src/publication/services/content/Iterator.d.ts +1 -1
- package/types/src/publication/services/content/element/attributes.d.ts +1 -1
- package/types/src/publication/services/content/element/element.d.ts +4 -4
- package/types/src/publication/services/content/element/index.d.ts +3 -3
- package/types/src/publication/services/content/index.d.ts +5 -5
- package/types/src/publication/services/content/iterators/HTMLResourceContentIterator.d.ts +4 -4
- package/types/src/publication/services/content/iterators/PDFTextContentIterator.d.ts +3 -3
- package/types/src/publication/services/content/iterators/PublicationContentIterator.d.ts +5 -5
- package/types/src/publication/services/content/iterators/helpers.d.ts +1 -1
- package/types/src/publication/services/content/iterators/index.d.ts +3 -3
- package/types/src/publication/services/index.d.ts +2 -2
- package/types/src/publication/services/timeline/Timeline.d.ts +9 -6
- package/types/src/publication/services/timeline/index.d.ts +2 -2
- package/types/src/util/index.d.ts +5 -5
- package/types/src/util/mediatype/index.d.ts +1 -1
- package/types/src/util/tokenizer/TextTokenizer.d.ts +2 -2
- package/types/src/util/tokenizer/index.d.ts +2 -2
- package/types/test/AltIdentifier.test.d.ts +0 -1
- package/types/test/Contributor.test.d.ts +0 -1
- package/types/test/GuidedNavigation.test.d.ts +0 -1
- package/types/test/Link.test.d.ts +0 -1
- package/types/test/LocalizedString.test.d.ts +0 -1
- package/types/test/Locator.test.d.ts +0 -1
- package/types/test/LocatorCollection.test.d.ts +0 -1
- package/types/test/Manifest.test.d.ts +0 -1
- package/types/test/Metadata.test.d.ts +0 -1
- package/types/test/Properties.test.d.ts +0 -1
- package/types/test/Publication.test.d.ts +0 -1
- package/types/test/PublicationCollection.test.d.ts +0 -1
- package/types/test/Subject.test.d.ts +0 -1
- package/types/test/TDM.test.d.ts +0 -1
- package/types/test/Timeline.test.d.ts +0 -1
- package/types/test/accessibility/Accessibility.test.d.ts +0 -1
- package/types/test/accessibility/AccessibilityMetadataDisplayGuide.test.d.ts +0 -1
- package/types/test/accessibility/Localization.test.d.ts +0 -1
- package/types/test/encryption/Encryption.test.d.ts +0 -1
- package/types/test/encryption/Properties.test.d.ts +0 -1
- package/types/test/epub/MediaOverlay.test.d.ts +0 -1
- package/types/test/epub/Metadata.test.d.ts +0 -1
- package/types/test/epub/PropertiesTest.test.d.ts +0 -1
- package/types/test/epub/PublicationTest.test.d.ts +0 -1
- package/types/test/html/DomRange.test.d.ts +0 -1
- package/types/test/html/Locator.test.d.ts +0 -1
- package/types/test/opds/PropertiesTest.test.d.ts +0 -1
- package/types/test/opds/PublicationTest.test.d.ts +0 -1
- package/types/test/util/URITemplate.test.d.ts +0 -1
- package/types/test/util/mediatype/MediaType.test.d.ts +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Accessibility, Feature, AccessMode, PrimaryAccessMode, Hazard } from './Accessibility';
|
|
2
|
-
import { Publication } from '../Publication';
|
|
3
|
-
import { AccessibilityProfile } from './Accessibility';
|
|
1
|
+
import { Accessibility, Feature, AccessMode, PrimaryAccessMode, Hazard } from './Accessibility.ts';
|
|
2
|
+
import { Publication } from '../Publication.ts';
|
|
3
|
+
import { AccessibilityProfile } from './Accessibility.ts';
|
|
4
4
|
|
|
5
|
-
import { Localization } from './Localization';
|
|
6
|
-
import { Layout } from '../Layout';
|
|
5
|
+
import { Localization } from './Localization.ts';
|
|
6
|
+
import { Layout } from '../Layout.ts';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Represents a single accessibility claim
|
|
@@ -90,19 +90,19 @@ export class WaysOfReading implements AccessibilityDisplayField {
|
|
|
90
90
|
|
|
91
91
|
// This should be displayed even if there is no metadata
|
|
92
92
|
this.shouldDisplay = true;
|
|
93
|
-
|
|
93
|
+
|
|
94
94
|
const titleLocale = Localization.getString(this.id);
|
|
95
95
|
this.title = titleLocale.compact;
|
|
96
96
|
|
|
97
97
|
this.statements = [];
|
|
98
|
-
|
|
98
|
+
|
|
99
99
|
// Visual Adjustments
|
|
100
100
|
const visualAdjustmentsKey = visualAdjustments === VisualAdjustments.Modifiable
|
|
101
101
|
? "ways-of-reading.visual-adjustments.modifiable"
|
|
102
102
|
: visualAdjustments === VisualAdjustments.Unmodifiable
|
|
103
103
|
? "ways-of-reading.visual-adjustments.unmodifiable"
|
|
104
104
|
: "ways-of-reading.visual-adjustments.unknown";
|
|
105
|
-
|
|
105
|
+
|
|
106
106
|
const visualAdjustmentsLocale = Localization.getString(visualAdjustmentsKey);
|
|
107
107
|
this.statements.push({
|
|
108
108
|
id: visualAdjustmentsKey,
|
|
@@ -121,7 +121,7 @@ export class WaysOfReading implements AccessibilityDisplayField {
|
|
|
121
121
|
} else if (nonvisualReading === NonvisualReading.NoMetadata) {
|
|
122
122
|
nonvisualReadingKey = "ways-of-reading.nonvisual-reading.no-metadata";
|
|
123
123
|
}
|
|
124
|
-
|
|
124
|
+
|
|
125
125
|
const nonvisualReadingLocale = Localization.getString(nonvisualReadingKey);
|
|
126
126
|
this.statements.push({
|
|
127
127
|
id: nonvisualReadingKey,
|
|
@@ -150,7 +150,7 @@ export class WaysOfReading implements AccessibilityDisplayField {
|
|
|
150
150
|
} else if (prerecordedAudio === PrerecordedAudio.NoMetadata) {
|
|
151
151
|
prerecordedAudioKey = "ways-of-reading.prerecorded-audio.no-metadata";
|
|
152
152
|
}
|
|
153
|
-
|
|
153
|
+
|
|
154
154
|
const prerecordedAudioLocale = Localization.getString(prerecordedAudioKey);
|
|
155
155
|
this.statements.push({
|
|
156
156
|
id: prerecordedAudioKey,
|
|
@@ -389,7 +389,7 @@ export class RichContent implements AccessibilityDisplayField {
|
|
|
389
389
|
!closedCaptions && !openCaptions && !transcript;
|
|
390
390
|
|
|
391
391
|
this.shouldDisplay = !this.noMetadata;
|
|
392
|
-
|
|
392
|
+
|
|
393
393
|
const titleLocale = Localization.getString(this.id);
|
|
394
394
|
this.title = titleLocale.compact;
|
|
395
395
|
|
|
@@ -553,7 +553,7 @@ export class AdditionalInformation implements AccessibilityDisplayField {
|
|
|
553
553
|
!signLanguage && !tactileGraphics && !tactileObjects && !textToSpeechHinting;
|
|
554
554
|
|
|
555
555
|
this.shouldDisplay = !this.noMetadata;
|
|
556
|
-
|
|
556
|
+
|
|
557
557
|
const titleLocale = Localization.getString(this.id);
|
|
558
558
|
this.title = titleLocale.compact;
|
|
559
559
|
|
|
@@ -716,7 +716,7 @@ export class Hazards implements AccessibilityDisplayField {
|
|
|
716
716
|
this.flashing = flashing;
|
|
717
717
|
this.motion = motion;
|
|
718
718
|
this.sound = sound;
|
|
719
|
-
|
|
719
|
+
|
|
720
720
|
const titleLocale = Localization.getString(this.id);
|
|
721
721
|
this.title = titleLocale.compact;
|
|
722
722
|
|
|
@@ -879,10 +879,10 @@ export class Conformance implements AccessibilityDisplayField {
|
|
|
879
879
|
|
|
880
880
|
private constructor(profiles: AccessibilityProfile[] = []) {
|
|
881
881
|
this.profiles = profiles;
|
|
882
|
-
|
|
882
|
+
|
|
883
883
|
// This should be displayed even if there is no metadata
|
|
884
884
|
this.shouldDisplay = true;
|
|
885
|
-
|
|
885
|
+
|
|
886
886
|
const titleLocale = Localization.getString(this.id);
|
|
887
887
|
this.title = titleLocale.compact;
|
|
888
888
|
|
|
@@ -948,7 +948,7 @@ export class Legal implements AccessibilityDisplayField {
|
|
|
948
948
|
) {
|
|
949
949
|
this.exemption = exemption;
|
|
950
950
|
this.shouldDisplay = this.exemption;
|
|
951
|
-
|
|
951
|
+
|
|
952
952
|
const titleLocale = Localization.getString(this.id);
|
|
953
953
|
this.title = titleLocale.compact;
|
|
954
954
|
|
|
@@ -989,13 +989,13 @@ export class AccessibilitySummary implements AccessibilityDisplayField {
|
|
|
989
989
|
|
|
990
990
|
private constructor(publication: Publication) {
|
|
991
991
|
this.shouldDisplay = true;
|
|
992
|
-
|
|
992
|
+
|
|
993
993
|
const titleLocale = Localization.getString(this.id);
|
|
994
994
|
this.title = titleLocale.compact;
|
|
995
|
-
|
|
995
|
+
|
|
996
996
|
const summary = publication.metadata.accessibility?.summary;
|
|
997
997
|
this.statements = [];
|
|
998
|
-
|
|
998
|
+
|
|
999
999
|
if (this.shouldDisplay && summary) {
|
|
1000
1000
|
this.statements.push({
|
|
1001
1001
|
id: "accessibility-summary.summary",
|
|
@@ -1052,4 +1052,4 @@ export class AccessibilityMetadataDisplayGuide {
|
|
|
1052
1052
|
this.accessibilitySummary
|
|
1053
1053
|
];
|
|
1054
1054
|
}
|
|
1055
|
-
}
|
|
1055
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Localization.ts
|
|
2
2
|
|
|
3
|
-
import { SUPPORTED_LANGUAGES } from './SupportedLanguages';
|
|
3
|
+
import { SUPPORTED_LANGUAGES } from './SupportedLanguages.ts';
|
|
4
4
|
// Static import for English (default locale)
|
|
5
5
|
import enLocale from '@edrlab/thorium-locales/publication-metadata/en.json';
|
|
6
6
|
|
|
@@ -65,20 +65,20 @@ class LocalizationImpl {
|
|
|
65
65
|
if (localeCode in this.loadedLocales) {
|
|
66
66
|
return true;
|
|
67
67
|
}
|
|
68
|
-
|
|
68
|
+
|
|
69
69
|
try {
|
|
70
70
|
// Check if we have a loader for this locale
|
|
71
71
|
if (!(localeCode in jsonLoaders)) {
|
|
72
72
|
console.warn(`Locale file not found for: ${localeCode}`);
|
|
73
73
|
return false;
|
|
74
74
|
}
|
|
75
|
-
|
|
75
|
+
|
|
76
76
|
const localeModule = await jsonLoaders[localeCode]();
|
|
77
77
|
const data = localeModule.default;
|
|
78
|
-
|
|
78
|
+
|
|
79
79
|
// Extract the accessibility.display-guide part
|
|
80
80
|
const accessibilityData = data?.publication?.metadata?.accessibility?.['display-guide'];
|
|
81
|
-
|
|
81
|
+
|
|
82
82
|
if (accessibilityData) {
|
|
83
83
|
this.loadedLocales[localeCode] = accessibilityData;
|
|
84
84
|
return true;
|
|
@@ -113,12 +113,12 @@ class LocalizationImpl {
|
|
|
113
113
|
if (!(localeCode in this.loadedLocales)) {
|
|
114
114
|
await this.loadLocale(localeCode);
|
|
115
115
|
}
|
|
116
|
-
|
|
116
|
+
|
|
117
117
|
if (!(localeCode in this.loadedLocales)) {
|
|
118
118
|
console.warn(`Locale '${localeCode}' is not available`);
|
|
119
119
|
return false;
|
|
120
120
|
}
|
|
121
|
-
|
|
121
|
+
|
|
122
122
|
this.locale = this.loadedLocales[localeCode];
|
|
123
123
|
this.currentLocaleCode = localeCode;
|
|
124
124
|
return true;
|
|
@@ -141,14 +141,14 @@ class LocalizationImpl {
|
|
|
141
141
|
private getNestedValue(obj: any, path: string): string | L10nString | undefined {
|
|
142
142
|
const parts = path.split('.');
|
|
143
143
|
let current = obj;
|
|
144
|
-
|
|
144
|
+
|
|
145
145
|
for (const part of parts) {
|
|
146
146
|
if (current === null || current === undefined) {
|
|
147
147
|
return undefined;
|
|
148
148
|
}
|
|
149
149
|
current = current[part];
|
|
150
150
|
}
|
|
151
|
-
|
|
151
|
+
|
|
152
152
|
return current;
|
|
153
153
|
}
|
|
154
154
|
|
|
@@ -160,19 +160,19 @@ class LocalizationImpl {
|
|
|
160
160
|
public getString(key: string): L10nString {
|
|
161
161
|
// First try the current locale
|
|
162
162
|
let value = this.getNestedValue(this.locale, key);
|
|
163
|
-
|
|
163
|
+
|
|
164
164
|
// If not found and current locale is not English, try falling back to English
|
|
165
165
|
if (value === undefined && this.currentLocaleCode !== 'en') {
|
|
166
166
|
value = this.getNestedValue(this.loadedLocales['en'], key);
|
|
167
167
|
}
|
|
168
|
-
|
|
168
|
+
|
|
169
169
|
// If we have a value, return it with proper formatting
|
|
170
170
|
if (value !== undefined) {
|
|
171
|
-
return typeof value === 'string'
|
|
172
|
-
? { compact: value, descriptive: value }
|
|
171
|
+
return typeof value === 'string'
|
|
172
|
+
? { compact: value, descriptive: value }
|
|
173
173
|
: value;
|
|
174
174
|
}
|
|
175
|
-
|
|
175
|
+
|
|
176
176
|
// If we get here, the key wasn't found in either locale
|
|
177
177
|
console.warn(`Missing localization for key: ${key}`);
|
|
178
178
|
return { compact: '', descriptive: '' };
|
|
@@ -182,4 +182,4 @@ class LocalizationImpl {
|
|
|
182
182
|
/**
|
|
183
183
|
* The singleton instance of the [Localization] class.
|
|
184
184
|
*/
|
|
185
|
-
export const Localization = LocalizationImpl.getInstance();
|
|
185
|
+
export const Localization = LocalizationImpl.getInstance();
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './Accessibility';
|
|
2
|
-
export * from './AccessibilityMetadataDisplayGuide';
|
|
3
|
-
export * from './Localization';
|
|
1
|
+
export * from './Accessibility.ts';
|
|
2
|
+
export * from './AccessibilityMetadataDisplayGuide.ts';
|
|
3
|
+
export * from './Localization.ts';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './Encryption';
|
|
2
|
-
export * from './Properties';
|
|
1
|
+
export * from './Encryption.ts';
|
|
2
|
+
export * from './Properties.ts';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Metadata } from "../Metadata";
|
|
2
|
-
import { MediaOverlay } from "./MediaOverlay";
|
|
1
|
+
import { Metadata } from "../Metadata.ts";
|
|
2
|
+
import { MediaOverlay } from "./MediaOverlay.ts";
|
|
3
3
|
|
|
4
4
|
declare module '../Metadata' {
|
|
5
5
|
export interface Metadata {
|
|
@@ -13,4 +13,4 @@ Metadata.prototype.getMediaOverlay = function(): MediaOverlay | undefined {
|
|
|
13
13
|
if (!mediaOverlay) return;
|
|
14
14
|
|
|
15
15
|
return MediaOverlay.deserialize(mediaOverlay);
|
|
16
|
-
};
|
|
16
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Links } from '../Link';
|
|
2
|
-
import { Publication } from '../Publication';
|
|
1
|
+
import { Links } from '../Link.ts';
|
|
2
|
+
import { Publication } from '../Publication.ts';
|
|
3
3
|
|
|
4
4
|
// EPUB extensions for [Publication].
|
|
5
5
|
// https://readium.org/webpub-manifest/schema/extensions/epub/subcollections.schema.json
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './MediaOverlay';
|
|
2
|
-
export * from './Metadata';
|
|
3
|
-
export * from './Properties';
|
|
4
|
-
export * from './Publication';
|
|
1
|
+
export * from './MediaOverlay.ts';
|
|
2
|
+
export * from './Metadata.ts';
|
|
3
|
+
export * from './Properties.ts';
|
|
4
|
+
export * from './Publication.ts';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* available in the LICENSE file present in the Github repository of the project.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { DomRangePoint } from './DomRangePoint';
|
|
6
|
+
import { DomRangePoint } from './DomRangePoint.ts';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* This construct enables a serializable representation of a DOM Range.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LocatorLocations } from '../Locator';
|
|
2
|
-
import { DomRange } from './DomRange';
|
|
1
|
+
import { LocatorLocations } from '../Locator.ts';
|
|
2
|
+
import { DomRange } from './DomRange.ts';
|
|
3
3
|
|
|
4
4
|
// HTML extensions for [Locations].
|
|
5
5
|
// https://github.com/readium/architecture/blob/master/models/locators/extensions/html.md
|
|
@@ -126,4 +126,4 @@ LocatorLocations.prototype.space = function(): [number, number, number, number]
|
|
|
126
126
|
if(xywh.length !== 4) return; // Must have four parts
|
|
127
127
|
if(xywh.some(isNaN)) return; // All parts must be numbers
|
|
128
128
|
return xywh as [number, number, number, number];
|
|
129
|
-
}
|
|
129
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './DomRange';
|
|
2
|
-
export * from './DomRangePoint';
|
|
3
|
-
export * from './Locations';
|
|
1
|
+
export * from './DomRange.ts';
|
|
2
|
+
export * from './DomRangePoint.ts';
|
|
3
|
+
export * from './Locations.ts';
|
package/src/publication/index.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
export * from './accessibility';
|
|
2
|
-
export * from './encryption';
|
|
3
|
-
export * from './epub';
|
|
4
|
-
export * from './html';
|
|
5
|
-
export * from './opds';
|
|
6
|
-
export * from './services';
|
|
7
|
-
export * from './AltIdentifier';
|
|
8
|
-
export * from './BelongsTo';
|
|
9
|
-
export * from './Contributor';
|
|
10
|
-
export * from './Link';
|
|
11
|
-
export * from './LocalizedString';
|
|
12
|
-
export * from './Locator';
|
|
13
|
-
export * from './LocatorCollection';
|
|
14
|
-
export * from './Manifest';
|
|
15
|
-
export * from './Metadata';
|
|
16
|
-
export * from './Profiles';
|
|
17
|
-
export * from './Properties';
|
|
18
|
-
export * from './Publication';
|
|
19
|
-
export * from './PublicationCollection';
|
|
20
|
-
export * from './Layout';
|
|
21
|
-
export * from './ReadingProgression';
|
|
22
|
-
export * from './Subject';
|
|
23
|
-
export * from './TDM';
|
|
24
|
-
export * from './GuidedNavigation';
|
|
1
|
+
export * from './accessibility/index.ts';
|
|
2
|
+
export * from './encryption/index.ts';
|
|
3
|
+
export * from './epub/index.ts';
|
|
4
|
+
export * from './html/index.ts';
|
|
5
|
+
export * from './opds/index.ts';
|
|
6
|
+
export * from './services/index.ts';
|
|
7
|
+
export * from './AltIdentifier.ts';
|
|
8
|
+
export * from './BelongsTo.ts';
|
|
9
|
+
export * from './Contributor.ts';
|
|
10
|
+
export * from './Link.ts';
|
|
11
|
+
export * from './LocalizedString.ts';
|
|
12
|
+
export * from './Locator.ts';
|
|
13
|
+
export * from './LocatorCollection.ts';
|
|
14
|
+
export * from './Manifest.ts';
|
|
15
|
+
export * from './Metadata.ts';
|
|
16
|
+
export * from './Profiles.ts';
|
|
17
|
+
export * from './Properties.ts';
|
|
18
|
+
export * from './Publication.ts';
|
|
19
|
+
export * from './PublicationCollection.ts';
|
|
20
|
+
export * from './Layout.ts';
|
|
21
|
+
export * from './ReadingProgression.ts';
|
|
22
|
+
export * from './Subject.ts';
|
|
23
|
+
export * from './TDM.ts';
|
|
24
|
+
export * from './GuidedNavigation.ts';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Copies, Acquisition, Holds, Price, Availability } from '../../opds';
|
|
2
|
-
import { positiveNumberfromJSON } from '../../util/JSONParse';
|
|
3
|
-
import { Link } from '../Link';
|
|
4
|
-
import { Properties } from '../Properties';
|
|
1
|
+
import { Copies, Acquisition, Holds, Price, Availability } from '../../opds/index.ts';
|
|
2
|
+
import { positiveNumberfromJSON } from '../../util/JSONParse.ts';
|
|
3
|
+
import { Link } from '../Link.ts';
|
|
4
|
+
import { Properties } from '../Properties.ts';
|
|
5
5
|
|
|
6
6
|
// OPDS extensions for link [Properties].
|
|
7
7
|
// https://drafts.opds.io/schema/properties.schema.json
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './Properties';
|
|
2
|
-
export * from './Publication';
|
|
1
|
+
export * from './Properties.ts';
|
|
2
|
+
export * from './Publication.ts';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Iterator } from "./Iterator";
|
|
2
|
-
import { ContentElement, TextualElement } from "./element";
|
|
1
|
+
import { Iterator } from "./Iterator.ts";
|
|
2
|
+
import { ContentElement, TextualElement } from "./element/index.ts";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Provides an iterable list of content [Element]s.
|
|
@@ -33,4 +33,4 @@ export abstract class Content {
|
|
|
33
33
|
}
|
|
34
34
|
return list;
|
|
35
35
|
}
|
|
36
|
-
}
|
|
36
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { DefaultTextContentTokenizer, Range, TextTokenizer, TextUnit, Tokenizer } from "../../../util";
|
|
2
|
-
import { Locator, LocatorText } from "../../Locator";
|
|
3
|
-
import { ContentElement, TextElement, TextSegment } from "./element";
|
|
1
|
+
import { DefaultTextContentTokenizer, Range, TextTokenizer, TextUnit, Tokenizer } from "../../../util/index.ts";
|
|
2
|
+
import { Locator, LocatorText } from "../../Locator.ts";
|
|
3
|
+
import { ContentElement, TextElement, TextSegment } from "./element/index.ts";
|
|
4
4
|
|
|
5
5
|
// A tokenizer splitting a [Content.Element] into smaller pieces.
|
|
6
6
|
export type ContentTokenizer = Tokenizer<ContentElement, ContentElement>;
|
|
7
7
|
|
|
8
8
|
export class TextContentTokenizer implements ContentTokenizer {
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
*
|
|
11
11
|
* @param defaultLanguage The default assumed language
|
|
12
12
|
* @param unit The unit of the produced [Locator]s.
|
|
13
13
|
* @param contextSnippetLength Length of `before` and `after` snippets in the produced [Locator]s.
|
|
@@ -27,7 +27,7 @@ export class TextContentTokenizer implements ContentTokenizer {
|
|
|
27
27
|
new TextElement(
|
|
28
28
|
data.locator,
|
|
29
29
|
data.role,
|
|
30
|
-
data.segments.map(s => this.tokenizeSegment(s)).flat(),
|
|
30
|
+
data.segments.map(s => this.tokenizeSegment(s)).flat(),
|
|
31
31
|
)
|
|
32
32
|
];
|
|
33
33
|
}
|
|
@@ -59,4 +59,4 @@ export class TextContentTokenizer implements ContentTokenizer {
|
|
|
59
59
|
highlight: str.substring(range[0], range[1]),
|
|
60
60
|
})
|
|
61
61
|
}
|
|
62
|
-
}
|
|
62
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ContentElement } from "./element";
|
|
1
|
+
import { ContentElement } from "./element/index.ts";
|
|
2
2
|
|
|
3
3
|
export class IllegalStateError extends Error {
|
|
4
4
|
constructor(message: string) {
|
|
@@ -43,4 +43,4 @@ export abstract class Iterator {
|
|
|
43
43
|
async previousOrNull(): Promise<ContentElement | null> {
|
|
44
44
|
return (await this.hasPrevious()) ? this.previous() : null;
|
|
45
45
|
}
|
|
46
|
-
}
|
|
46
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Language } from "../../../../util/Language";
|
|
1
|
+
import { Language } from "../../../../util/Language.ts";
|
|
2
2
|
|
|
3
3
|
export class Attribute<V> {
|
|
4
4
|
constructor(
|
|
@@ -41,4 +41,4 @@ export abstract class AttributesHolder {
|
|
|
41
41
|
attributes<V>(key: AttributeKeys | string): V[] {
|
|
42
42
|
return this._attributes.filter(attribute => attribute.key === key).map(attribute => attribute.value);
|
|
43
43
|
}
|
|
44
|
-
}
|
|
44
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Link } from "../../../Link";
|
|
2
|
-
import { Locator } from "../../../Locator";
|
|
3
|
-
import { AttributesHolder, Attribute } from "./attributes";
|
|
4
|
-
import { TextRole } from "./text_role";
|
|
1
|
+
import { Link } from "../../../Link.ts";
|
|
2
|
+
import { Locator } from "../../../Locator.ts";
|
|
3
|
+
import { AttributesHolder, Attribute } from "./attributes.ts";
|
|
4
|
+
import { TextRole } from "./text_role.ts";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Represents a single semantic content element part of a publication.
|
|
@@ -115,4 +115,4 @@ export class TextElement extends TextualElement {
|
|
|
115
115
|
get text(): string | undefined {
|
|
116
116
|
return this.segments.map(segment => segment.text).join("");
|
|
117
117
|
}
|
|
118
|
-
}
|
|
118
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './element';
|
|
2
|
-
export * from './attributes';
|
|
3
|
-
export * from './text_role';
|
|
1
|
+
export * from './element.ts';
|
|
2
|
+
export * from './attributes.ts';
|
|
3
|
+
export * from './text_role.ts';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './Content';
|
|
2
|
-
export * from './ContentTokenizer';
|
|
3
|
-
export * from './Iterator';
|
|
4
|
-
export * from './element';
|
|
5
|
-
export * from './iterators';
|
|
1
|
+
export * from './Content.ts';
|
|
2
|
+
export * from './ContentTokenizer.ts';
|
|
3
|
+
export * from './Iterator.ts';
|
|
4
|
+
export * from './element/index.ts';
|
|
5
|
+
export * from './iterators/index.ts';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Resource } from "../../../../fetcher/Resource";
|
|
2
|
-
import { Link, Links } from "../../../Link";
|
|
3
|
-
import { Locator, LocatorLocations } from "../../../Locator";
|
|
4
|
-
import { IllegalStateError, Iterator } from "../Iterator";
|
|
5
|
-
import { Attribute, AttributeKeys, AudioElement, Body, ContentElement, Footnote, Heading, ImageElement, TextElement, TextQuote, TextRole, TextSegment, VideoElement } from "../element";
|
|
6
|
-
import { appendNormalizedWhitespace, elementLanguage, isBlank, isInlineTag, srcRelativeToHref, trimUnicodeSpace, trimUnicodeSpaceEnd, trimUnicodeSpaceStart, trimmingTextLocator } from "./helpers";
|
|
1
|
+
import { Resource } from "../../../../fetcher/Resource.ts";
|
|
2
|
+
import { Link, Links } from "../../../Link.ts";
|
|
3
|
+
import { Locator, LocatorLocations } from "../../../Locator.ts";
|
|
4
|
+
import { IllegalStateError, Iterator } from "../Iterator.ts";
|
|
5
|
+
import { Attribute, AttributeKeys, AudioElement, Body, ContentElement, Footnote, Heading, ImageElement, TextElement, TextQuote, TextRole, TextSegment, VideoElement } from "../element/index.ts";
|
|
6
|
+
import { appendNormalizedWhitespace, elementLanguage, isBlank, isInlineTag, srcRelativeToHref, trimUnicodeSpace, trimUnicodeSpaceEnd, trimUnicodeSpaceStart, trimmingTextLocator } from "./helpers.ts";
|
|
7
7
|
import { getCssSelector } from "css-selector-generator";
|
|
8
8
|
|
|
9
9
|
interface ElementWithDelta {
|
|
@@ -297,7 +297,7 @@ class ContentParser implements NodeVisitor {
|
|
|
297
297
|
sr.attributes
|
|
298
298
|
);
|
|
299
299
|
});
|
|
300
|
-
|
|
300
|
+
|
|
301
301
|
return new TextElement(
|
|
302
302
|
new Locator({
|
|
303
303
|
href: this.baseLocator.href,
|
|
@@ -568,4 +568,4 @@ class ContentParser implements NodeVisitor {
|
|
|
568
568
|
this.rawTextAcc = "";
|
|
569
569
|
this.textAcc = "";
|
|
570
570
|
}
|
|
571
|
-
}
|
|
571
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Locator } from "../../../Locator";
|
|
2
|
-
import { Attribute, ContentElement } from "../element";
|
|
3
|
-
import { IllegalStateError, Iterator } from "../Iterator";
|
|
1
|
+
import { Locator } from "../../../Locator.ts";
|
|
2
|
+
import { Attribute, ContentElement } from "../element/index.ts";
|
|
3
|
+
import { IllegalStateError, Iterator } from "../Iterator.ts";
|
|
4
4
|
|
|
5
5
|
// Type TextItem represents a text item in a PDF page (extracted from pdf.js TextItem type).
|
|
6
6
|
type TextItem = {
|
|
@@ -47,7 +47,7 @@ class ElementInDirection {
|
|
|
47
47
|
) {}
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
/* An iterator which iterates through a whole PDF page provided,
|
|
50
|
+
/* An iterator which iterates through a whole PDF page provided,
|
|
51
51
|
and returns the elements based on a [PDFReadableElement] array. */
|
|
52
52
|
|
|
53
53
|
// TODO extend Iterator class!
|
|
@@ -65,7 +65,7 @@ export class PageContentIteratorPDF extends Iterator{
|
|
|
65
65
|
*/
|
|
66
66
|
private pageContent: Array<TextItem>,
|
|
67
67
|
private startLocator?: Locator | null | undefined
|
|
68
|
-
) {
|
|
68
|
+
) {
|
|
69
69
|
super();
|
|
70
70
|
const contentFiltered = this.pageContent.filter(
|
|
71
71
|
(item: TextItem) => item?.str !== " " && item?.str !== ""
|
|
@@ -95,7 +95,7 @@ export class PageContentIteratorPDF extends Iterator{
|
|
|
95
95
|
|
|
96
96
|
|
|
97
97
|
// Returns the current element to be read.
|
|
98
|
-
current(): ContentElement | null {
|
|
98
|
+
current(): ContentElement | null {
|
|
99
99
|
return this.currentElement ? this.currentElement.element : null;
|
|
100
100
|
}
|
|
101
101
|
|
|
@@ -105,9 +105,9 @@ export class PageContentIteratorPDF extends Iterator{
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
previous(): ContentElement {
|
|
108
|
-
|
|
108
|
+
|
|
109
109
|
if (!this.currentElement) throw new IllegalStateError("Called next() without a successful call to hasNext() first");
|
|
110
|
-
|
|
110
|
+
|
|
111
111
|
this.currentElement = this.nextIn(Direction.Backward);
|
|
112
112
|
|
|
113
113
|
if (this.currentElementIndex && this.currentElementIndex > 0) {
|
|
@@ -115,11 +115,11 @@ export class PageContentIteratorPDF extends Iterator{
|
|
|
115
115
|
this.currentProgression = newIndex / this.pageContentFiltered.length * 100;
|
|
116
116
|
this.currentElementIndex = newIndex;
|
|
117
117
|
}
|
|
118
|
-
|
|
119
|
-
return this.currentElement ?
|
|
120
|
-
this.currentElement.element :
|
|
118
|
+
|
|
119
|
+
return this.currentElement ?
|
|
120
|
+
this.currentElement.element :
|
|
121
121
|
new PDFContentElement(new Locator( { href : "", type: "" }), { index: -1, text: "" });
|
|
122
|
-
|
|
122
|
+
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
async hasNext(): Promise<boolean> {
|
|
@@ -128,21 +128,21 @@ export class PageContentIteratorPDF extends Iterator{
|
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
next(): ContentElement {
|
|
131
|
-
|
|
131
|
+
|
|
132
132
|
this.currentElement = this.nextIn(Direction.Forward);
|
|
133
133
|
const currentIndex = this.currentElementIndex;
|
|
134
134
|
if (currentIndex !== null &&
|
|
135
|
-
currentIndex >= 0 &&
|
|
135
|
+
currentIndex >= 0 &&
|
|
136
136
|
currentIndex < this.pageContentFiltered.length - 1) {
|
|
137
137
|
const newIndex = currentIndex + 1;
|
|
138
138
|
this.currentProgression = newIndex / (this.pageContentFiltered.length) * 100;
|
|
139
139
|
this.currentElementIndex = newIndex;
|
|
140
140
|
}
|
|
141
|
-
|
|
142
|
-
return this.currentElement ?
|
|
143
|
-
this.currentElement.element :
|
|
141
|
+
|
|
142
|
+
return this.currentElement ?
|
|
143
|
+
this.currentElement.element :
|
|
144
144
|
new PDFContentElement(new Locator( { href : "", type: "" }), { index: -1, text: "" });
|
|
145
|
-
|
|
145
|
+
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
private nextIn(direction: Direction): ElementInDirection | null {
|
|
@@ -173,12 +173,12 @@ export class PageContentIteratorPDF extends Iterator{
|
|
|
173
173
|
*/
|
|
174
174
|
private updateElementIndex(): number | null {
|
|
175
175
|
if (this.currentProgression === 0) return 0;
|
|
176
|
-
|
|
176
|
+
|
|
177
177
|
// return null if the current progression is out of bounds
|
|
178
178
|
if (this.currentProgression < 0 || this.currentProgression >= 100) return null;
|
|
179
|
-
|
|
179
|
+
|
|
180
180
|
// Convert the progression percentage to an index in the pageContentFiltered array
|
|
181
181
|
return Math.floor(this.currentProgression * this.pageContentFiltered.length / 100);
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
}
|
|
184
|
+
}
|