@readium/shared 1.3.0 → 2.0.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.
Files changed (52) hide show
  1. package/dist/index.js +1253 -1149
  2. package/dist/index.umd.cjs +3 -3
  3. package/package.json +1 -1
  4. package/src/publication/AltIdentifier.ts +58 -0
  5. package/src/publication/Contributor.ts +15 -0
  6. package/src/publication/GuidedNavigation.ts +126 -15
  7. package/src/publication/Layout.ts +13 -0
  8. package/src/publication/Link.ts +7 -0
  9. package/src/publication/Metadata.ts +77 -8
  10. package/src/publication/Profiles.ts +15 -0
  11. package/src/publication/Properties.ts +10 -0
  12. package/src/publication/ReadingProgression.ts +2 -15
  13. package/src/publication/TDM.ts +56 -0
  14. package/src/publication/epub/MediaOverlay.ts +43 -0
  15. package/src/publication/epub/Metadata.ts +16 -0
  16. package/src/publication/epub/Properties.ts +0 -10
  17. package/src/publication/epub/index.ts +2 -2
  18. package/src/publication/index.ts +4 -1
  19. package/src/util/JSONParse.ts +3 -3
  20. package/types/src/publication/AltIdentifier.d.ts +23 -0
  21. package/types/src/publication/Contributor.d.ts +4 -0
  22. package/types/src/publication/GuidedNavigation.d.ts +62 -9
  23. package/types/src/publication/Layout.d.ts +8 -0
  24. package/types/src/publication/Link.d.ts +3 -0
  25. package/types/src/publication/Metadata.d.ts +25 -2
  26. package/types/src/publication/Profiles.d.ts +10 -0
  27. package/types/src/publication/Properties.d.ts +6 -0
  28. package/types/src/publication/ReadingProgression.d.ts +2 -5
  29. package/types/src/publication/TDM.d.ts +30 -0
  30. package/types/src/publication/accessibility/Accessibility.d.ts +16 -16
  31. package/types/src/publication/accessibility/AccessibilityMetadataDisplayGuide.d.ts +22 -25
  32. package/types/src/publication/accessibility/Localization.d.ts +37 -0
  33. package/types/src/publication/accessibility/index.d.ts +1 -0
  34. package/types/src/publication/epub/MediaOverlay.d.ts +19 -0
  35. package/types/src/publication/epub/Metadata.d.ts +6 -0
  36. package/types/src/publication/epub/Properties.d.ts +1 -5
  37. package/types/src/publication/epub/index.d.ts +2 -2
  38. package/types/src/publication/index.d.ts +4 -1
  39. package/types/src/util/JSONParse.d.ts +2 -2
  40. package/src/publication/epub/EPUBLayout.ts +0 -10
  41. package/src/publication/epub/Presentation.ts +0 -16
  42. package/src/publication/presentation/Metadata.ts +0 -19
  43. package/src/publication/presentation/Presentation.ts +0 -155
  44. package/src/publication/presentation/Properties.ts +0 -70
  45. package/src/publication/presentation/index.ts +0 -3
  46. package/types/src/publication/accessibility/AccessibilityDisplayString.d.ts +0 -56
  47. package/types/src/publication/epub/EPUBLayout.d.ts +0 -5
  48. package/types/src/publication/epub/Presentation.d.ts +0 -7
  49. package/types/src/publication/presentation/Metadata.d.ts +0 -6
  50. package/types/src/publication/presentation/Presentation.d.ts +0 -95
  51. package/types/src/publication/presentation/Properties.d.ts +0 -32
  52. package/types/src/publication/presentation/index.d.ts +0 -3
@@ -2,8 +2,8 @@ export * from './encryption';
2
2
  export * from './epub';
3
3
  export * from './html';
4
4
  export * from './opds';
5
- export * from './presentation';
6
5
  export * from './services';
6
+ export * from './AltIdentifier';
7
7
  export * from './BelongsTo';
8
8
  export * from './Contributor';
9
9
  export * from './Link';
@@ -12,9 +12,12 @@ export * from './Locator';
12
12
  export * from './LocatorCollection';
13
13
  export * from './Manifest';
14
14
  export * from './Metadata';
15
+ export * from './Profiles';
15
16
  export * from './Properties';
16
17
  export * from './Publication';
17
18
  export * from './PublicationCollection';
19
+ export * from './Layout';
18
20
  export * from './ReadingProgression';
19
21
  export * from './Subject';
22
+ export * from './TDM';
20
23
  export * from './GuidedNavigation';
@@ -7,5 +7,5 @@ export declare function datefromJSON(json: any): Date | undefined;
7
7
  export declare function numberfromJSON(json: any): number | undefined;
8
8
  /** Parses a numeric value, but returns undefined if it is not a positive number. */
9
9
  export declare function positiveNumberfromJSON(json: any): number | undefined;
10
- /** Converts a Set of a string to a string Array object */
11
- export declare function setToArray(obj: Set<string>): Array<string>;
10
+ /** Converts a Set to an Array object */
11
+ export declare function setToArray(obj: Set<any>): Array<any>;
@@ -1,10 +0,0 @@
1
- /* Copyright 2021 Readium Foundation. All rights reserved.
2
- * Use of this source code is governed by a BSD-style license,
3
- * available in the LICENSE file present in the Github repository of the project.
4
- */
5
-
6
- /** Hint about the nature of the layout for the linked resources. */
7
- export enum EPUBLayout {
8
- fixed = 'fixed',
9
- reflowable = 'reflowable',
10
- }
@@ -1,16 +0,0 @@
1
- import { Link } from '../Link';
2
- import { Presentation } from '../presentation/Presentation';
3
- import { EPUBLayout } from './EPUBLayout';
4
-
5
- declare module '../presentation/Presentation' {
6
- export interface Presentation {
7
- layoutOf(link: Link): EPUBLayout;
8
- }
9
- }
10
-
11
- /** Determines the layout of the given resource in this publication.
12
- * Default layout is reflowable.
13
- */
14
- Presentation.prototype.layoutOf = function(link: Link): EPUBLayout {
15
- return link.properties?.getLayout() || this.layout || EPUBLayout.reflowable;
16
- };
@@ -1,19 +0,0 @@
1
- import { Metadata } from '../Metadata';
2
- import { Presentation } from './Presentation';
3
-
4
- // Presentation extensions for [Metadata]
5
-
6
- declare module '../Metadata' {
7
- export interface Metadata {
8
- getPresentation(): Presentation | undefined;
9
- }
10
- }
11
-
12
- Metadata.prototype.getPresentation = function(): Presentation | undefined {
13
- const presentation =
14
- this.otherMetadata?.['presentation'] || this.otherMetadata?.['rendition'];
15
-
16
- if (!presentation) return;
17
-
18
- return Presentation.deserialize(presentation);
19
- };
@@ -1,155 +0,0 @@
1
- /* Copyright 2021 Readium Foundation. All rights reserved.
2
- * Use of this source code is governed by a BSD-style license,
3
- * available in the LICENSE file present in the Github repository of the project.
4
- */
5
-
6
- import { EPUBLayout } from '../epub/EPUBLayout';
7
-
8
- /**
9
- * Suggested orientation for the device when displaying the linked resource.
10
- */
11
- export enum Orientation {
12
- auto = 'auto',
13
- landscape = 'landscape',
14
- portrait = 'portrait',
15
- }
16
-
17
- /**
18
- * Suggested method for handling overflow while displaying the linked resource.
19
- */
20
- export enum Overflow {
21
- auto = 'auto',
22
- clipped = 'clipped',
23
- paginated = 'paginated',
24
- scrolled = 'scrolled',
25
- }
26
-
27
- /**
28
- * Indicates how the linked resource should be displayed in a reading environment that displays
29
- * synthetic spreads.
30
- */
31
- export enum Page {
32
- left = 'left',
33
- right = 'right',
34
- center = 'center',
35
- }
36
-
37
- /**
38
- * Indicates the condition to be met for the linked resource to be rendered within a synthetic
39
- * spread.
40
- */
41
- export enum Spread {
42
- auto = 'auto',
43
- both = 'both',
44
- none = 'none',
45
- landscape = 'landscape',
46
- }
47
-
48
- /**
49
- * Suggested method for constraining a resource inside the viewport.
50
- */
51
- export enum Fit {
52
- contain = 'contain',
53
- cover = 'cover',
54
- width = 'width',
55
- height = 'height',
56
- }
57
-
58
- // export interface IPresentationMetadata {
59
- // clipped?: boolean;
60
- // continuous?: boolean;
61
- // fit?: Fit;
62
- // orientation?: Orientation;
63
- // overflow?: Overflow;
64
- // spread?: Spread;
65
- // layout?: EpubLayout;
66
- // }
67
-
68
- /** The Presentation Hints extension defines a number of hints for User Agents about the way content
69
- * should be presented to the user.
70
- *
71
- * https://readium.org/webpub-manifest/extensions/presentation.html
72
- * https://readium.org/webpub-manifest/schema/extensions/presentation/metadata.schema.json
73
- *
74
- * These properties can be undefined to avoid having default values when it doesn't make sense for a
75
- * given `Publication`. If a navigator needs a default value when not specified,
76
- * `Presentation.defaultX` and `Presentation.X.default` can be used.
77
- */
78
- export class Presentation {
79
- /** Specifies whether or not the parts of a linked resource that flow out of the viewport are clipped */
80
- public clipped?: boolean;
81
-
82
- /** Suggested method for constraining a resource inside the viewport. */
83
- public fit?: Fit;
84
-
85
- /** Suggested orientation for the device when displaying the linked resource. */
86
- public orientation?: Orientation;
87
-
88
- /** Indicates the condition to be met for the linked resource to be rendered
89
- * within a synthetic spread
90
- */
91
- public spread?: Spread;
92
-
93
- /** Hint about the nature of the layout for the linked resources (EPUB extension). */
94
- public layout?: EPUBLayout;
95
-
96
- /** Indicates how the progression between resources from the [readingOrder] should be handled */
97
- public continuous?: boolean;
98
-
99
- /** Indicates if the overflow of linked resources from the `readingOrder` or `resources` should
100
- * be handled using dynamic pagination or scrolling.
101
- */
102
- public overflow?: Overflow;
103
-
104
- /** Creates a [Presentation]. */
105
- constructor(values: {
106
- clipped?: boolean;
107
- continuous?: boolean;
108
- fit?: Fit;
109
- orientation?: Orientation;
110
- overflow?: Overflow;
111
- spread?: Spread;
112
- layout?: EPUBLayout;
113
- }) {
114
- this.clipped = values.clipped;
115
- this.fit = values.fit;
116
- this.orientation = values.orientation;
117
- this.spread = values.spread;
118
- this.layout = values.layout;
119
- this.continuous = values.continuous;
120
- this.overflow = values.overflow;
121
- }
122
-
123
- /**
124
- * Parses a [Presentation] from its RWPM JSON representation.
125
- *
126
- */
127
- public static deserialize(json: any): Presentation | undefined {
128
- if (!json) return;
129
-
130
- return new Presentation({
131
- clipped: json.clipped,
132
- continuous: json.continuous,
133
- fit: json.fit,
134
- orientation: json.orientation,
135
- overflow: json.overflow,
136
- spread: json.spread,
137
- layout: json.layout,
138
- });
139
- }
140
-
141
- /**
142
- * Serializes a [Presentation] to its RWPM JSON representation.
143
- */
144
- public serialize(): any {
145
- const json: any = {};
146
- if (this.clipped !== undefined) json.clipped = this.clipped;
147
- if (this.continuous !== undefined) json.continuous = this.continuous;
148
- if (this.fit !== undefined) json.fit = this.fit;
149
- if (this.orientation !== undefined) json.orientation = this.orientation;
150
- if (this.overflow !== undefined) json.overflow = this.overflow;
151
- if (this.spread !== undefined) json.spread = this.spread;
152
- if (this.layout !== undefined) json.layout = this.layout;
153
- return json;
154
- }
155
- }
@@ -1,70 +0,0 @@
1
- /* Copyright 2021 Readium Foundation. All rights reserved.
2
- * Use of this source code is governed by a BSD-style license,
3
- * available in the LICENSE file present in the Github repository of the project.
4
- */
5
-
6
- // Presentation extensions for link [Properties]
7
-
8
- import { Properties } from '../Properties';
9
- import { Fit, Orientation, Overflow, Page, Spread } from './Presentation';
10
-
11
- declare module '../Properties' {
12
- export interface Properties {
13
- /**
14
- * Specifies whether or not the parts of a linked resource that flow out of the viewport are
15
- * clipped.
16
- */
17
- getClipped(): boolean | undefined;
18
-
19
- /**
20
- * Suggested method for constraining a resource inside the viewport.
21
- */
22
- getFit(): Fit | undefined;
23
-
24
- /**
25
- * Suggested orientation for the device when displaying the linked resource.
26
- */
27
- getOrientation(): Orientation | undefined;
28
-
29
- /**
30
- * Suggested method for handling overflow while displaying the linked resource.
31
- */
32
- getOverflow(): Overflow | undefined;
33
-
34
- /**
35
- * Indicates how the linked resource should be displayed in a reading environment that displays
36
- * synthetic spreads.
37
- */
38
- getPage(): Page | undefined;
39
-
40
- /**
41
- * Indicates the condition to be met for the linked resource to be rendered within a synthetic
42
- * spread.
43
- */
44
- getSpread(): Spread | undefined;
45
- }
46
- }
47
-
48
- Properties.prototype.getClipped = function(): boolean | undefined {
49
- return this.otherProperties['clipped'];
50
- };
51
-
52
- Properties.prototype.getFit = function(): Fit | undefined {
53
- return this.otherProperties['fit'];
54
- };
55
-
56
- Properties.prototype.getOrientation = function(): Orientation | undefined {
57
- return this.otherProperties['orientation'];
58
- };
59
-
60
- Properties.prototype.getOverflow = function(): Overflow | undefined {
61
- return this.otherProperties['overflow'];
62
- };
63
-
64
- Properties.prototype.getPage = function(): Page | undefined {
65
- return this.otherProperties['page'] || undefined;
66
- };
67
-
68
- Properties.prototype.getSpread = function(): Spread | undefined {
69
- return this.otherProperties['spread'] || undefined;
70
- };
@@ -1,3 +0,0 @@
1
- export * from './Presentation';
2
- export * from './Metadata';
3
- export * from './Properties';
@@ -1,56 +0,0 @@
1
- export declare enum AccessibilityDisplayString {
2
- WaysOfReadingTitle = "ways_of_reading_title",
3
- WaysOfReadingVisualAdjustmentsModifiable = "ways_of_reading_visual_adjustments_modifiable",
4
- WaysOfReadingVisualAdjustmentsUnmodifiable = "ways_of_reading_visual_adjustments_unmodifiable",
5
- WaysOfReadingNonvisualReading = "ways_of_reading_nonvisual_reading",
6
- WaysOfReadingNonvisualReadingAltText = "ways_of_reading_nonvisual_reading_alt_text",
7
- WaysOfReadingPrerecordedAudio = "ways_of_reading_prerecorded_audio",
8
- NavigationTitle = "navigation_title",
9
- NavigationToc = "navigation_toc",
10
- NavigationIndex = "navigation_index",
11
- NavigationStructural = "navigation_structural",
12
- NavigationPageNavigation = "navigation_page_navigation",
13
- NavigationNoMetadata = "navigation_no_metadata",
14
- AdditionalInformationTitle = "additional_information_title",
15
- AdditionalInformationPageBreaks = "additional_information_page_breaks",
16
- AdditionalInformationAria = "additional_information_aria",
17
- AdditionalInformationAudioDescriptions = "additional_information_audio_descriptions",
18
- AdditionalInformationBraille = "additional_information_braille",
19
- AdditionalInformationRubyAnnotations = "additional_information_ruby_annotations",
20
- AdditionalInformationFullRubyAnnotations = "additional_information_full_ruby_annotations",
21
- AdditionalInformationHighContrastBetweenForegroundAndBackgroundAudio = "additional_information_high_contrast_between_foreground_and_background_audio",
22
- AdditionalInformationHighContrastBetweenTextAndBackground = "additional_information_high_contrast_between_text_and_background",
23
- AdditionalInformationLargePrint = "additional_information_large_print",
24
- AdditionalInformationSignLanguage = "additional_information_sign_language",
25
- AdditionalInformationTactileGraphics = "additional_information_tactile_graphics",
26
- AdditionalInformationTactileObjects = "additional_information_tactile_objects",
27
- AdditionalInformationTextToSpeechHinting = "additional_information_text_to_speech_hinting",
28
- RichContentTitle = "rich_content_title",
29
- RichContentExtended = "rich_content_extended",
30
- RichContentAccessibleMathDescribed = "rich_content_accessible_math_described",
31
- RichContentAccessibleMathAsMathml = "rich_content_accessible_math_as_mathml",
32
- RichContentAccessibleMathAsLatex = "rich_content_accessible_math_as_latex",
33
- RichContentAccessibleChemistryAsMathml = "rich_content_accessible_chemistry_as_mathml",
34
- RichContentAccessibleChemistryAsLatex = "rich_content_accessible_chemistry_as_latex",
35
- RichContentClosedCaptions = "rich_content_closed_captions",
36
- RichContentOpenCaptions = "rich_content_open_captions",
37
- RichContentTranscript = "rich_content_transcript",
38
- RichContentUnknown = "rich_content_unknown",
39
- HazardsTitle = "hazards_title",
40
- HazardsMotion = "hazards_motion",
41
- HazardsSound = "hazards_sound",
42
- HazardsFlashing = "hazards_flashing",
43
- ConformanceTitle = "conformance_title",
44
- ConformanceNo = "conformance_no",
45
- ConformanceA = "conformance_a",
46
- ConformanceAa = "conformance_aa",
47
- ConformanceAaa = "conformance_aaa",
48
- ConformanceUnknownStandard = "conformance_unknown_standard",
49
- ConformanceWCAG = "conformance_wcag",
50
- ConformanceEPUB = "conformance_epub",
51
- LegalTitle = "legal_title",
52
- LegalExemption = "legal_exemption",
53
- LegalNoMetadata = "legal_no_metadata",
54
- AccessibilitySummaryTitle = "accessibility_summary_title",
55
- AccessibilitySummary = "accessibility_summary"
56
- }
@@ -1,5 +0,0 @@
1
- /** Hint about the nature of the layout for the linked resources. */
2
- export declare enum EPUBLayout {
3
- fixed = "fixed",
4
- reflowable = "reflowable"
5
- }
@@ -1,7 +0,0 @@
1
- import { Link } from '../Link';
2
- import { EPUBLayout } from './EPUBLayout';
3
- declare module '../presentation/Presentation' {
4
- interface Presentation {
5
- layoutOf(link: Link): EPUBLayout;
6
- }
7
- }
@@ -1,6 +0,0 @@
1
- import { Presentation } from './Presentation';
2
- declare module '../Metadata' {
3
- interface Metadata {
4
- getPresentation(): Presentation | undefined;
5
- }
6
- }
@@ -1,95 +0,0 @@
1
- import { EPUBLayout } from '../epub/EPUBLayout';
2
- /**
3
- * Suggested orientation for the device when displaying the linked resource.
4
- */
5
- export declare enum Orientation {
6
- auto = "auto",
7
- landscape = "landscape",
8
- portrait = "portrait"
9
- }
10
- /**
11
- * Suggested method for handling overflow while displaying the linked resource.
12
- */
13
- export declare enum Overflow {
14
- auto = "auto",
15
- clipped = "clipped",
16
- paginated = "paginated",
17
- scrolled = "scrolled"
18
- }
19
- /**
20
- * Indicates how the linked resource should be displayed in a reading environment that displays
21
- * synthetic spreads.
22
- */
23
- export declare enum Page {
24
- left = "left",
25
- right = "right",
26
- center = "center"
27
- }
28
- /**
29
- * Indicates the condition to be met for the linked resource to be rendered within a synthetic
30
- * spread.
31
- */
32
- export declare enum Spread {
33
- auto = "auto",
34
- both = "both",
35
- none = "none",
36
- landscape = "landscape"
37
- }
38
- /**
39
- * Suggested method for constraining a resource inside the viewport.
40
- */
41
- export declare enum Fit {
42
- contain = "contain",
43
- cover = "cover",
44
- width = "width",
45
- height = "height"
46
- }
47
- /** The Presentation Hints extension defines a number of hints for User Agents about the way content
48
- * should be presented to the user.
49
- *
50
- * https://readium.org/webpub-manifest/extensions/presentation.html
51
- * https://readium.org/webpub-manifest/schema/extensions/presentation/metadata.schema.json
52
- *
53
- * These properties can be undefined to avoid having default values when it doesn't make sense for a
54
- * given `Publication`. If a navigator needs a default value when not specified,
55
- * `Presentation.defaultX` and `Presentation.X.default` can be used.
56
- */
57
- export declare class Presentation {
58
- /** Specifies whether or not the parts of a linked resource that flow out of the viewport are clipped */
59
- clipped?: boolean;
60
- /** Suggested method for constraining a resource inside the viewport. */
61
- fit?: Fit;
62
- /** Suggested orientation for the device when displaying the linked resource. */
63
- orientation?: Orientation;
64
- /** Indicates the condition to be met for the linked resource to be rendered
65
- * within a synthetic spread
66
- */
67
- spread?: Spread;
68
- /** Hint about the nature of the layout for the linked resources (EPUB extension). */
69
- layout?: EPUBLayout;
70
- /** Indicates how the progression between resources from the [readingOrder] should be handled */
71
- continuous?: boolean;
72
- /** Indicates if the overflow of linked resources from the `readingOrder` or `resources` should
73
- * be handled using dynamic pagination or scrolling.
74
- */
75
- overflow?: Overflow;
76
- /** Creates a [Presentation]. */
77
- constructor(values: {
78
- clipped?: boolean;
79
- continuous?: boolean;
80
- fit?: Fit;
81
- orientation?: Orientation;
82
- overflow?: Overflow;
83
- spread?: Spread;
84
- layout?: EPUBLayout;
85
- });
86
- /**
87
- * Parses a [Presentation] from its RWPM JSON representation.
88
- *
89
- */
90
- static deserialize(json: any): Presentation | undefined;
91
- /**
92
- * Serializes a [Presentation] to its RWPM JSON representation.
93
- */
94
- serialize(): any;
95
- }
@@ -1,32 +0,0 @@
1
- import { Fit, Orientation, Overflow, Page, Spread } from './Presentation';
2
- declare module '../Properties' {
3
- interface Properties {
4
- /**
5
- * Specifies whether or not the parts of a linked resource that flow out of the viewport are
6
- * clipped.
7
- */
8
- getClipped(): boolean | undefined;
9
- /**
10
- * Suggested method for constraining a resource inside the viewport.
11
- */
12
- getFit(): Fit | undefined;
13
- /**
14
- * Suggested orientation for the device when displaying the linked resource.
15
- */
16
- getOrientation(): Orientation | undefined;
17
- /**
18
- * Suggested method for handling overflow while displaying the linked resource.
19
- */
20
- getOverflow(): Overflow | undefined;
21
- /**
22
- * Indicates how the linked resource should be displayed in a reading environment that displays
23
- * synthetic spreads.
24
- */
25
- getPage(): Page | undefined;
26
- /**
27
- * Indicates the condition to be met for the linked resource to be rendered within a synthetic
28
- * spread.
29
- */
30
- getSpread(): Spread | undefined;
31
- }
32
- }
@@ -1,3 +0,0 @@
1
- export * from './Presentation';
2
- export * from './Metadata';
3
- export * from './Properties';