manifesto.js 4.2.19 → 4.2.20

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 (226) hide show
  1. package/dist-commonjs/Annotation.d.ts +10 -0
  2. package/dist-commonjs/Annotation.js +75 -0
  3. package/dist-commonjs/Annotation.js.map +1 -0
  4. package/dist-commonjs/AnnotationBody.d.ts +9 -0
  5. package/dist-commonjs/AnnotationBody.js +45 -0
  6. package/dist-commonjs/AnnotationBody.js.map +1 -0
  7. package/dist-commonjs/AnnotationList.d.ts +12 -0
  8. package/dist-commonjs/AnnotationList.js +62 -0
  9. package/dist-commonjs/AnnotationList.js.map +1 -0
  10. package/dist-commonjs/AnnotationPage.d.ts +5 -0
  11. package/dist-commonjs/AnnotationPage.js +28 -0
  12. package/dist-commonjs/AnnotationPage.js.map +1 -0
  13. package/dist-commonjs/Canvas.d.ts +31 -0
  14. package/dist-commonjs/Canvas.js +346 -0
  15. package/dist-commonjs/Canvas.js.map +1 -0
  16. package/dist-commonjs/Collection.d.ts +28 -0
  17. package/dist-commonjs/Collection.js +157 -0
  18. package/dist-commonjs/Collection.js.map +1 -0
  19. package/dist-commonjs/Duration.d.ts +6 -0
  20. package/dist-commonjs/Duration.js +14 -0
  21. package/dist-commonjs/Duration.js.map +1 -0
  22. package/dist-commonjs/IAccessToken.d.ts +7 -0
  23. package/dist-commonjs/IAccessToken.js +3 -0
  24. package/dist-commonjs/IAccessToken.js.map +1 -0
  25. package/dist-commonjs/IExternalImageResourceData.d.ts +5 -0
  26. package/dist-commonjs/IExternalImageResourceData.js +3 -0
  27. package/dist-commonjs/IExternalImageResourceData.js.map +1 -0
  28. package/dist-commonjs/IExternalResource.d.ts +24 -0
  29. package/dist-commonjs/IExternalResource.js +3 -0
  30. package/dist-commonjs/IExternalResource.js.map +1 -0
  31. package/dist-commonjs/IExternalResourceData.d.ts +7 -0
  32. package/dist-commonjs/IExternalResourceData.js +3 -0
  33. package/dist-commonjs/IExternalResourceData.js.map +1 -0
  34. package/dist-commonjs/IExternalResourceOptions.d.ts +3 -0
  35. package/dist-commonjs/IExternalResourceOptions.js +3 -0
  36. package/dist-commonjs/IExternalResourceOptions.js.map +1 -0
  37. package/dist-commonjs/IIIFResource.d.ts +29 -0
  38. package/dist-commonjs/IIIFResource.js +181 -0
  39. package/dist-commonjs/IIIFResource.js.map +1 -0
  40. package/dist-commonjs/IManifestoOptions.d.ts +9 -0
  41. package/dist-commonjs/IManifestoOptions.js +3 -0
  42. package/dist-commonjs/IManifestoOptions.js.map +1 -0
  43. package/dist-commonjs/JSONLDResource.d.ts +7 -0
  44. package/dist-commonjs/JSONLDResource.js +23 -0
  45. package/dist-commonjs/JSONLDResource.js.map +1 -0
  46. package/dist-commonjs/LabelValuePair.d.ts +14 -0
  47. package/dist-commonjs/LabelValuePair.js +57 -0
  48. package/dist-commonjs/LabelValuePair.js.map +1 -0
  49. package/dist-commonjs/Language.d.ts +5 -0
  50. package/dist-commonjs/Language.js +3 -0
  51. package/dist-commonjs/Language.js.map +1 -0
  52. package/dist-commonjs/LanguageMap.d.ts +8 -0
  53. package/dist-commonjs/LanguageMap.js +33 -0
  54. package/dist-commonjs/LanguageMap.js.map +1 -0
  55. package/dist-commonjs/Manifest.d.ts +29 -0
  56. package/dist-commonjs/Manifest.js +260 -0
  57. package/dist-commonjs/Manifest.js.map +1 -0
  58. package/dist-commonjs/ManifestResource.d.ts +23 -0
  59. package/dist-commonjs/ManifestResource.js +130 -0
  60. package/dist-commonjs/ManifestResource.js.map +1 -0
  61. package/dist-commonjs/ManifestType.d.ts +5 -0
  62. package/dist-commonjs/ManifestType.js +9 -0
  63. package/dist-commonjs/ManifestType.js.map +1 -0
  64. package/dist-commonjs/PropertyValue.d.ts +58 -0
  65. package/dist-commonjs/PropertyValue.js +291 -0
  66. package/dist-commonjs/PropertyValue.js.map +1 -0
  67. package/dist-commonjs/Range.d.ts +20 -0
  68. package/dist-commonjs/Range.js +198 -0
  69. package/dist-commonjs/Range.js.map +1 -0
  70. package/dist-commonjs/Rendering.d.ts +6 -0
  71. package/dist-commonjs/Rendering.js +28 -0
  72. package/dist-commonjs/Rendering.js.map +1 -0
  73. package/dist-commonjs/Resource.d.ts +13 -0
  74. package/dist-commonjs/Resource.js +68 -0
  75. package/dist-commonjs/Resource.js.map +1 -0
  76. package/dist-commonjs/Sequence.d.ts +30 -0
  77. package/dist-commonjs/Sequence.js +267 -0
  78. package/dist-commonjs/Sequence.js.map +1 -0
  79. package/dist-commonjs/Serialisation.d.ts +11 -0
  80. package/dist-commonjs/Serialisation.js +156 -0
  81. package/dist-commonjs/Serialisation.js.map +1 -0
  82. package/dist-commonjs/Service.d.ts +13 -0
  83. package/dist-commonjs/Service.js +61 -0
  84. package/dist-commonjs/Service.js.map +1 -0
  85. package/dist-commonjs/Size.d.ts +5 -0
  86. package/dist-commonjs/Size.js +11 -0
  87. package/dist-commonjs/Size.js.map +1 -0
  88. package/dist-commonjs/StatusCode.d.ts +6 -0
  89. package/dist-commonjs/StatusCode.js +10 -0
  90. package/dist-commonjs/StatusCode.js.map +1 -0
  91. package/dist-commonjs/Thumb.d.ts +13 -0
  92. package/dist-commonjs/Thumb.js +24 -0
  93. package/dist-commonjs/Thumb.js.map +1 -0
  94. package/dist-commonjs/Thumbnail.d.ts +4 -0
  95. package/dist-commonjs/Thumbnail.js +25 -0
  96. package/dist-commonjs/Thumbnail.js.map +1 -0
  97. package/dist-commonjs/TreeNode.d.ts +15 -0
  98. package/dist-commonjs/TreeNode.js +26 -0
  99. package/dist-commonjs/TreeNode.js.map +1 -0
  100. package/dist-commonjs/TreeNodeType.d.ts +5 -0
  101. package/dist-commonjs/TreeNodeType.js +9 -0
  102. package/dist-commonjs/TreeNodeType.js.map +1 -0
  103. package/dist-commonjs/Utils.d.ts +47 -0
  104. package/dist-commonjs/Utils.js +748 -0
  105. package/dist-commonjs/Utils.js.map +1 -0
  106. package/dist-commonjs/index.d.ts +5 -0
  107. package/dist-commonjs/index.js +14 -0
  108. package/dist-commonjs/index.js.map +1 -0
  109. package/dist-commonjs/internal.d.ts +35 -0
  110. package/dist-commonjs/internal.js +34 -0
  111. package/dist-commonjs/internal.js.map +1 -0
  112. package/dist-esmodule/Annotation.d.ts +10 -0
  113. package/dist-esmodule/Annotation.js +73 -0
  114. package/dist-esmodule/Annotation.js.map +1 -0
  115. package/dist-esmodule/AnnotationBody.d.ts +9 -0
  116. package/dist-esmodule/AnnotationBody.js +43 -0
  117. package/dist-esmodule/AnnotationBody.js.map +1 -0
  118. package/dist-esmodule/AnnotationList.d.ts +12 -0
  119. package/dist-esmodule/AnnotationList.js +60 -0
  120. package/dist-esmodule/AnnotationList.js.map +1 -0
  121. package/dist-esmodule/AnnotationPage.d.ts +5 -0
  122. package/dist-esmodule/AnnotationPage.js +26 -0
  123. package/dist-esmodule/AnnotationPage.js.map +1 -0
  124. package/dist-esmodule/Canvas.d.ts +31 -0
  125. package/dist-esmodule/Canvas.js +341 -0
  126. package/dist-esmodule/Canvas.js.map +1 -0
  127. package/dist-esmodule/Collection.d.ts +28 -0
  128. package/dist-esmodule/Collection.js +155 -0
  129. package/dist-esmodule/Collection.js.map +1 -0
  130. package/dist-esmodule/Duration.d.ts +6 -0
  131. package/dist-esmodule/Duration.js +12 -0
  132. package/dist-esmodule/Duration.js.map +1 -0
  133. package/dist-esmodule/IAccessToken.d.ts +7 -0
  134. package/dist-esmodule/IAccessToken.js +1 -0
  135. package/dist-esmodule/IAccessToken.js.map +1 -0
  136. package/dist-esmodule/IExternalImageResourceData.d.ts +5 -0
  137. package/dist-esmodule/IExternalImageResourceData.js +1 -0
  138. package/dist-esmodule/IExternalImageResourceData.js.map +1 -0
  139. package/dist-esmodule/IExternalResource.d.ts +24 -0
  140. package/dist-esmodule/IExternalResource.js +1 -0
  141. package/dist-esmodule/IExternalResource.js.map +1 -0
  142. package/dist-esmodule/IExternalResourceData.d.ts +7 -0
  143. package/dist-esmodule/IExternalResourceData.js +1 -0
  144. package/dist-esmodule/IExternalResourceData.js.map +1 -0
  145. package/dist-esmodule/IExternalResourceOptions.d.ts +3 -0
  146. package/dist-esmodule/IExternalResourceOptions.js +1 -0
  147. package/dist-esmodule/IExternalResourceOptions.js.map +1 -0
  148. package/dist-esmodule/IIIFResource.d.ts +29 -0
  149. package/dist-esmodule/IIIFResource.js +179 -0
  150. package/dist-esmodule/IIIFResource.js.map +1 -0
  151. package/dist-esmodule/IManifestoOptions.d.ts +9 -0
  152. package/dist-esmodule/IManifestoOptions.js +1 -0
  153. package/dist-esmodule/IManifestoOptions.js.map +1 -0
  154. package/dist-esmodule/JSONLDResource.d.ts +7 -0
  155. package/dist-esmodule/JSONLDResource.js +21 -0
  156. package/dist-esmodule/JSONLDResource.js.map +1 -0
  157. package/dist-esmodule/LabelValuePair.d.ts +14 -0
  158. package/dist-esmodule/LabelValuePair.js +55 -0
  159. package/dist-esmodule/LabelValuePair.js.map +1 -0
  160. package/dist-esmodule/Language.d.ts +5 -0
  161. package/dist-esmodule/Language.js +1 -0
  162. package/dist-esmodule/Language.js.map +1 -0
  163. package/dist-esmodule/LanguageMap.d.ts +8 -0
  164. package/dist-esmodule/LanguageMap.js +31 -0
  165. package/dist-esmodule/LanguageMap.js.map +1 -0
  166. package/dist-esmodule/Manifest.d.ts +29 -0
  167. package/dist-esmodule/Manifest.js +258 -0
  168. package/dist-esmodule/Manifest.js.map +1 -0
  169. package/dist-esmodule/ManifestResource.d.ts +23 -0
  170. package/dist-esmodule/ManifestResource.js +128 -0
  171. package/dist-esmodule/ManifestResource.js.map +1 -0
  172. package/dist-esmodule/ManifestType.d.ts +5 -0
  173. package/dist-esmodule/ManifestType.js +7 -0
  174. package/dist-esmodule/ManifestType.js.map +1 -0
  175. package/dist-esmodule/PropertyValue.d.ts +58 -0
  176. package/dist-esmodule/PropertyValue.js +289 -0
  177. package/dist-esmodule/PropertyValue.js.map +1 -0
  178. package/dist-esmodule/Range.d.ts +20 -0
  179. package/dist-esmodule/Range.js +196 -0
  180. package/dist-esmodule/Range.js.map +1 -0
  181. package/dist-esmodule/Rendering.d.ts +6 -0
  182. package/dist-esmodule/Rendering.js +26 -0
  183. package/dist-esmodule/Rendering.js.map +1 -0
  184. package/dist-esmodule/Resource.d.ts +13 -0
  185. package/dist-esmodule/Resource.js +66 -0
  186. package/dist-esmodule/Resource.js.map +1 -0
  187. package/dist-esmodule/Sequence.d.ts +30 -0
  188. package/dist-esmodule/Sequence.js +265 -0
  189. package/dist-esmodule/Sequence.js.map +1 -0
  190. package/dist-esmodule/Serialisation.d.ts +11 -0
  191. package/dist-esmodule/Serialisation.js +154 -0
  192. package/dist-esmodule/Serialisation.js.map +1 -0
  193. package/dist-esmodule/Service.d.ts +13 -0
  194. package/dist-esmodule/Service.js +59 -0
  195. package/dist-esmodule/Service.js.map +1 -0
  196. package/dist-esmodule/Size.d.ts +5 -0
  197. package/dist-esmodule/Size.js +9 -0
  198. package/dist-esmodule/Size.js.map +1 -0
  199. package/dist-esmodule/StatusCode.d.ts +6 -0
  200. package/dist-esmodule/StatusCode.js +8 -0
  201. package/dist-esmodule/StatusCode.js.map +1 -0
  202. package/dist-esmodule/Thumb.d.ts +13 -0
  203. package/dist-esmodule/Thumb.js +22 -0
  204. package/dist-esmodule/Thumb.js.map +1 -0
  205. package/dist-esmodule/Thumbnail.d.ts +4 -0
  206. package/dist-esmodule/Thumbnail.js +23 -0
  207. package/dist-esmodule/Thumbnail.js.map +1 -0
  208. package/dist-esmodule/TreeNode.d.ts +15 -0
  209. package/dist-esmodule/TreeNode.js +24 -0
  210. package/dist-esmodule/TreeNode.js.map +1 -0
  211. package/dist-esmodule/TreeNodeType.d.ts +5 -0
  212. package/dist-esmodule/TreeNodeType.js +7 -0
  213. package/dist-esmodule/TreeNodeType.js.map +1 -0
  214. package/dist-esmodule/Utils.d.ts +47 -0
  215. package/dist-esmodule/Utils.js +746 -0
  216. package/dist-esmodule/Utils.js.map +1 -0
  217. package/dist-esmodule/index.d.ts +5 -0
  218. package/dist-esmodule/index.js +9 -0
  219. package/dist-esmodule/index.js.map +1 -0
  220. package/dist-esmodule/internal.d.ts +35 -0
  221. package/dist-esmodule/internal.js +29 -0
  222. package/dist-esmodule/internal.js.map +1 -0
  223. package/dist-umd/manifesto.js +1 -0
  224. package/dist-var/manifesto.js +1 -0
  225. package/package.json +1 -1
  226. package/types/index.d.ts +496 -0
@@ -0,0 +1,10 @@
1
+ import { AnnotationMotivation } from "@iiif/vocabulary/dist-commonjs";
2
+ import { AnnotationBody, IManifestoOptions, ManifestResource, Resource } from "./internal";
3
+ export declare class Annotation extends ManifestResource {
4
+ constructor(jsonld: any, options: IManifestoOptions);
5
+ getBody(): AnnotationBody[];
6
+ getMotivation(): AnnotationMotivation | null;
7
+ getOn(): string;
8
+ getTarget(): string | null;
9
+ getResource(): Resource;
10
+ }
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ extendStatics(d, b);
11
+ function __() { this.constructor = d; }
12
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
+ };
14
+ })();
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ var internal_1 = require("./internal");
17
+ var Annotation = /** @class */ (function (_super) {
18
+ __extends(Annotation, _super);
19
+ function Annotation(jsonld, options) {
20
+ return _super.call(this, jsonld, options) || this;
21
+ }
22
+ Annotation.prototype.getBody = function () {
23
+ var bodies = [];
24
+ var body = this.getProperty("body");
25
+ // todo: make this a generic "property that can be an object or array enumerator" util
26
+ if (body) {
27
+ if (Array.isArray(body)) {
28
+ for (var i = 0; i < body.length; i++) {
29
+ var b = body[i];
30
+ if (b.items) {
31
+ for (var i_1 = 0; i_1 < b.items.length; i_1++) {
32
+ // todo: don't ignore that it's a choice. maybe add isChoice() to IAnnotationBody?
33
+ var c = b.items[i_1];
34
+ bodies.push(new internal_1.AnnotationBody(c, this.options));
35
+ }
36
+ }
37
+ else {
38
+ bodies.push(new internal_1.AnnotationBody(b, this.options));
39
+ }
40
+ }
41
+ }
42
+ else if (body.items) {
43
+ for (var i = 0; i < body.items.length; i++) {
44
+ var b = body.items[i];
45
+ bodies.push(new internal_1.AnnotationBody(b, this.options));
46
+ }
47
+ }
48
+ else {
49
+ bodies.push(new internal_1.AnnotationBody(body, this.options));
50
+ }
51
+ }
52
+ return bodies;
53
+ };
54
+ Annotation.prototype.getMotivation = function () {
55
+ var motivation = this.getProperty("motivation");
56
+ if (motivation) {
57
+ //const key: string | undefined = Object.keys(AnnotationMotivationEnum).find(k => AnnotationMotivationEnum[k] === motivation);
58
+ return motivation;
59
+ }
60
+ return null;
61
+ };
62
+ // open annotation
63
+ Annotation.prototype.getOn = function () {
64
+ return this.getProperty("on");
65
+ };
66
+ Annotation.prototype.getTarget = function () {
67
+ return this.getProperty("target");
68
+ };
69
+ Annotation.prototype.getResource = function () {
70
+ return new internal_1.Resource(this.getProperty("resource"), this.options);
71
+ };
72
+ return Annotation;
73
+ }(internal_1.ManifestResource));
74
+ exports.Annotation = Annotation;
75
+ //# sourceMappingURL=Annotation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Annotation.js","sourceRoot":"","sources":["../src/Annotation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,uCAKoB;AAEpB;IAAgC,8BAAgB;IAC9C,oBAAY,MAAW,EAAE,OAA0B;eACjD,kBAAM,MAAM,EAAE,OAAO,CAAC;IACxB,CAAC;IAED,4BAAO,GAAP;QACE,IAAM,MAAM,GAAqB,EAAE,CAAC;QACpC,IAAM,IAAI,GAAQ,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAE3C,sFAAsF;QACtF,IAAI,IAAI,EAAE;YACR,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACvB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;oBACpC,IAAM,CAAC,GAAQ,IAAI,CAAC,CAAC,CAAC,CAAC;oBACvB,IAAI,CAAC,CAAC,KAAK,EAAE;wBACX,KAAK,IAAI,GAAC,GAAG,CAAC,EAAE,GAAC,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,GAAC,EAAE,EAAE;4BACvC,kFAAkF;4BAClF,IAAM,CAAC,GAAQ,CAAC,CAAC,KAAK,CAAC,GAAC,CAAC,CAAC;4BAC1B,MAAM,CAAC,IAAI,CAAC,IAAI,yBAAc,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;yBAClD;qBACF;yBAAM;wBACL,MAAM,CAAC,IAAI,CAAC,IAAI,yBAAc,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;qBAClD;iBACF;aACF;iBAAM,IAAI,IAAI,CAAC,KAAK,EAAE;gBACrB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;oBAC1C,IAAM,CAAC,GAAQ,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;oBAC7B,MAAM,CAAC,IAAI,CAAC,IAAI,yBAAc,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;iBAClD;aACF;iBAAM;gBACL,MAAM,CAAC,IAAI,CAAC,IAAI,yBAAc,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;aACrD;SACF;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,kCAAa,GAAb;QACE,IAAM,UAAU,GAAW,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;QAE1D,IAAI,UAAU,EAAE;YACd,8HAA8H;YAC9H,OAAO,UAAkC,CAAC;SAC3C;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,kBAAkB;IAClB,0BAAK,GAAL;QACE,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAED,8BAAS,GAAT;QACE,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC;IAED,gCAAW,GAAX;QACE,OAAO,IAAI,mBAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAClE,CAAC;IACH,iBAAC;AAAD,CAAC,AA5DD,CAAgC,2BAAgB,GA4D/C;AA5DY,gCAAU"}
@@ -0,0 +1,9 @@
1
+ import { ExternalResourceType, MediaType } from "@iiif/vocabulary/dist-commonjs";
2
+ import { IManifestoOptions, ManifestResource } from "./internal";
3
+ export declare class AnnotationBody extends ManifestResource {
4
+ constructor(jsonld?: any, options?: IManifestoOptions);
5
+ getFormat(): MediaType | null;
6
+ getType(): ExternalResourceType | null;
7
+ getWidth(): number;
8
+ getHeight(): number;
9
+ }
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ extendStatics(d, b);
11
+ function __() { this.constructor = d; }
12
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
+ };
14
+ })();
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ var internal_1 = require("./internal");
17
+ var AnnotationBody = /** @class */ (function (_super) {
18
+ __extends(AnnotationBody, _super);
19
+ function AnnotationBody(jsonld, options) {
20
+ return _super.call(this, jsonld, options) || this;
21
+ }
22
+ AnnotationBody.prototype.getFormat = function () {
23
+ var format = this.getProperty("format");
24
+ if (format) {
25
+ return internal_1.Utils.getMediaType(format);
26
+ }
27
+ return null;
28
+ };
29
+ AnnotationBody.prototype.getType = function () {
30
+ var type = this.getProperty("type");
31
+ if (type) {
32
+ return (internal_1.Utils.normaliseType(this.getProperty("type")));
33
+ }
34
+ return null;
35
+ };
36
+ AnnotationBody.prototype.getWidth = function () {
37
+ return this.getProperty("width");
38
+ };
39
+ AnnotationBody.prototype.getHeight = function () {
40
+ return this.getProperty("height");
41
+ };
42
+ return AnnotationBody;
43
+ }(internal_1.ManifestResource));
44
+ exports.AnnotationBody = AnnotationBody;
45
+ //# sourceMappingURL=AnnotationBody.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnnotationBody.js","sourceRoot":"","sources":["../src/AnnotationBody.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAIA,uCAAwE;AAExE;IAAoC,kCAAgB;IAClD,wBAAY,MAAY,EAAE,OAA2B;eACnD,kBAAM,MAAM,EAAE,OAAO,CAAC;IACxB,CAAC;IAED,kCAAS,GAAT;QACE,IAAM,MAAM,GAAW,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAElD,IAAI,MAAM,EAAE;YACV,OAAO,gBAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;SACnC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,gCAAO,GAAP;QACE,IAAM,IAAI,GAAW,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAE9C,IAAI,IAAI,EAAE;YACR,OAA6B,CAC3B,gBAAK,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAC9C,CAAC;SACH;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,iCAAQ,GAAR;QACE,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IAED,kCAAS,GAAT;QACE,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC;IACH,qBAAC;AAAD,CAAC,AAlCD,CAAoC,2BAAgB,GAkCnD;AAlCY,wCAAc"}
@@ -0,0 +1,12 @@
1
+ import { IIIFResourceType } from "@iiif/vocabulary/dist-commonjs";
2
+ import { Annotation, IManifestoOptions, JSONLDResource } from "./internal";
3
+ export declare class AnnotationList extends JSONLDResource {
4
+ options: IManifestoOptions;
5
+ label: string;
6
+ isLoaded: boolean;
7
+ constructor(label: any, jsonld?: any, options?: IManifestoOptions);
8
+ getIIIFResourceType(): IIIFResourceType;
9
+ getLabel(): string;
10
+ getResources(): Annotation[];
11
+ load(): Promise<AnnotationList>;
12
+ }
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ extendStatics(d, b);
11
+ function __() { this.constructor = d; }
12
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
+ };
14
+ })();
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ var internal_1 = require("./internal");
17
+ var AnnotationList = /** @class */ (function (_super) {
18
+ __extends(AnnotationList, _super);
19
+ function AnnotationList(label, jsonld, options) {
20
+ var _this = _super.call(this, jsonld) || this;
21
+ _this.label = label;
22
+ _this.options = options;
23
+ return _this;
24
+ }
25
+ AnnotationList.prototype.getIIIFResourceType = function () {
26
+ return internal_1.Utils.normaliseType(this.getProperty("type"));
27
+ };
28
+ AnnotationList.prototype.getLabel = function () {
29
+ return this.label;
30
+ };
31
+ AnnotationList.prototype.getResources = function () {
32
+ var _this = this;
33
+ var resources = this.getProperty("resources");
34
+ return resources.map(function (resource) { return new internal_1.Annotation(resource, _this.options); });
35
+ };
36
+ AnnotationList.prototype.load = function () {
37
+ var _this = this;
38
+ return new Promise(function (resolve, reject) {
39
+ if (_this.isLoaded) {
40
+ resolve(_this);
41
+ }
42
+ else {
43
+ var id = _this.__jsonld.id;
44
+ if (!id) {
45
+ id = _this.__jsonld["@id"];
46
+ }
47
+ internal_1.Utils.loadManifest(id)
48
+ .then(function (data) {
49
+ _this.__jsonld = data;
50
+ _this.context = _this.getProperty("context");
51
+ _this.id = _this.getProperty("id");
52
+ _this.isLoaded = true;
53
+ resolve(_this);
54
+ })
55
+ .catch(reject);
56
+ }
57
+ });
58
+ };
59
+ return AnnotationList;
60
+ }(internal_1.JSONLDResource));
61
+ exports.AnnotationList = AnnotationList;
62
+ //# sourceMappingURL=AnnotationList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnnotationList.js","sourceRoot":"","sources":["../src/AnnotationList.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,uCAKoB;AAEpB;IAAoC,kCAAc;IAKhD,wBAAY,KAAK,EAAE,MAAY,EAAE,OAA2B;QAA5D,YACE,kBAAM,MAAM,CAAC,SAGd;QAFC,KAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,KAAI,CAAC,OAAO,GAAsB,OAAO,CAAC;;IAC5C,CAAC;IAED,4CAAmB,GAAnB;QACE,OAAyB,gBAAK,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;IACzE,CAAC;IAED,iCAAQ,GAAR;QACE,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,qCAAY,GAAZ;QAAA,iBAGC;QAFC,IAAM,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;QAChD,OAAO,SAAS,CAAC,GAAG,CAAC,UAAA,QAAQ,IAAI,OAAA,IAAI,qBAAU,CAAC,QAAQ,EAAE,KAAI,CAAC,OAAO,CAAC,EAAtC,CAAsC,CAAC,CAAC;IAC3E,CAAC;IAED,6BAAI,GAAJ;QAAA,iBAsBC;QArBC,OAAO,IAAI,OAAO,CAAiB,UAAC,OAAO,EAAE,MAAM;YACjD,IAAI,KAAI,CAAC,QAAQ,EAAE;gBACjB,OAAO,CAAC,KAAI,CAAC,CAAC;aACf;iBAAM;gBACL,IAAI,EAAE,GAAW,KAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAElC,IAAI,CAAC,EAAE,EAAE;oBACP,EAAE,GAAG,KAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;iBAC3B;gBAED,gBAAK,CAAC,YAAY,CAAC,EAAE,CAAC;qBACnB,IAAI,CAAC,UAAA,IAAI;oBACR,KAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;oBACrB,KAAI,CAAC,OAAO,GAAG,KAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;oBAC3C,KAAI,CAAC,EAAE,GAAG,KAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;oBACjC,KAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;oBACrB,OAAO,CAAC,KAAI,CAAC,CAAC;gBAChB,CAAC,CAAC;qBACD,KAAK,CAAC,MAAM,CAAC,CAAC;aAClB;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IACH,qBAAC;AAAD,CAAC,AA/CD,CAAoC,yBAAc,GA+CjD;AA/CY,wCAAc"}
@@ -0,0 +1,5 @@
1
+ import { Annotation, IManifestoOptions, ManifestResource } from "./internal";
2
+ export declare class AnnotationPage extends ManifestResource {
3
+ constructor(jsonld: any, options: IManifestoOptions);
4
+ getItems(): Annotation[];
5
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ extendStatics(d, b);
11
+ function __() { this.constructor = d; }
12
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
+ };
14
+ })();
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ var internal_1 = require("./internal");
17
+ var AnnotationPage = /** @class */ (function (_super) {
18
+ __extends(AnnotationPage, _super);
19
+ function AnnotationPage(jsonld, options) {
20
+ return _super.call(this, jsonld, options) || this;
21
+ }
22
+ AnnotationPage.prototype.getItems = function () {
23
+ return this.getProperty("items");
24
+ };
25
+ return AnnotationPage;
26
+ }(internal_1.ManifestResource));
27
+ exports.AnnotationPage = AnnotationPage;
28
+ //# sourceMappingURL=AnnotationPage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnnotationPage.js","sourceRoot":"","sources":["../src/AnnotationPage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAA6E;AAE7E;IAAoC,kCAAgB;IAClD,wBAAY,MAAW,EAAE,OAA0B;eACjD,kBAAM,MAAM,EAAE,OAAO,CAAC;IACxB,CAAC;IAED,iCAAQ,GAAR;QACE,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IACH,qBAAC;AAAD,CAAC,AARD,CAAoC,2BAAgB,GAQnD;AARY,wCAAc"}
@@ -0,0 +1,31 @@
1
+ import { ViewingHint } from "@iiif/vocabulary/dist-commonjs";
2
+ import { Annotation, AnnotationList, IManifestoOptions, Range, Resource, Size } from "./internal";
3
+ export declare class Canvas extends Resource {
4
+ ranges: Range[];
5
+ constructor(jsonld?: any, options?: IManifestoOptions);
6
+ getCanonicalImageUri(w?: number): string;
7
+ getMaxDimensions(): Size | null;
8
+ getContent(): Annotation[];
9
+ getDuration(): number | null;
10
+ getImages(): Annotation[];
11
+ getIndex(): number;
12
+ getOtherContent(): Promise<AnnotationList[]>;
13
+ getWidth(): number;
14
+ getHeight(): number;
15
+ getViewingHint(): ViewingHint | null;
16
+ readonly imageResources: any;
17
+ readonly resourceAnnotations: any;
18
+ /**
19
+ * Returns a given resource Annotation, based on a contained resource or body
20
+ * id
21
+ */
22
+ resourceAnnotation(id: any): any;
23
+ /**
24
+ * Returns the fragment placement values if a resourceAnnotation is placed on
25
+ * a canvas somewhere besides the full extent
26
+ */
27
+ onFragment(id: any): any;
28
+ readonly iiifImageResources: any;
29
+ readonly imageServiceIds: any;
30
+ readonly aspectRatio: number;
31
+ }
@@ -0,0 +1,346 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ extendStatics(d, b);
11
+ function __() { this.constructor = d; }
12
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
+ };
14
+ })();
15
+ var __importDefault = (this && this.__importDefault) || function (mod) {
16
+ return (mod && mod.__esModule) ? mod : { "default": mod };
17
+ };
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ var dist_commonjs_1 = require("@iiif/vocabulary/dist-commonjs");
20
+ var internal_1 = require("./internal");
21
+ // @ts-ignore
22
+ var flatten_1 = __importDefault(require("lodash/flatten"));
23
+ // @ts-ignore
24
+ var flattenDeep_1 = __importDefault(require("lodash/flattenDeep"));
25
+ var Canvas = /** @class */ (function (_super) {
26
+ __extends(Canvas, _super);
27
+ function Canvas(jsonld, options) {
28
+ return _super.call(this, jsonld, options) || this;
29
+ }
30
+ // http://iiif.io/api/image/2.1/#canonical-uri-syntax
31
+ Canvas.prototype.getCanonicalImageUri = function (w) {
32
+ var id = null;
33
+ var region = "full";
34
+ var rotation = 0;
35
+ var quality = "default";
36
+ var width = w;
37
+ var size;
38
+ // if an info.json has been loaded
39
+ if (this.externalResource &&
40
+ this.externalResource.data &&
41
+ this.externalResource.data["@id"]) {
42
+ id = this.externalResource.data["@id"];
43
+ if (!width) {
44
+ width = this.externalResource.data.width;
45
+ }
46
+ if (this.externalResource.data["@context"]) {
47
+ if (this.externalResource.data["@context"].indexOf("/1.0/context.json") >
48
+ -1 ||
49
+ this.externalResource.data["@context"].indexOf("/1.1/context.json") >
50
+ -1 ||
51
+ this.externalResource.data["@context"].indexOf("/1/context.json") > -1) {
52
+ quality = "native";
53
+ }
54
+ }
55
+ }
56
+ else {
57
+ // info.json hasn't been loaded yet
58
+ var images = void 0;
59
+ // presentation 2.0
60
+ images = this.getImages();
61
+ if (images && images.length) {
62
+ var firstImage = images[0];
63
+ var resource = firstImage.getResource();
64
+ var services = resource.getServices();
65
+ if (!width) {
66
+ width = resource.getWidth();
67
+ }
68
+ var service = services
69
+ ? services.find(function (service) {
70
+ return (internal_1.Utils.isImageProfile(service.getProfile()) ||
71
+ internal_1.Utils.isImageServiceType(service.getIIIFResourceType()));
72
+ })
73
+ : null;
74
+ if (service) {
75
+ id = service.id;
76
+ quality = internal_1.Utils.getImageQuality(service.getProfile());
77
+ }
78
+ else if (width === resource.getWidth()) {
79
+ // if the passed width is the same as the resource width
80
+ // i.e. not looking for a thumbnail
81
+ // return the full size image.
82
+ // used for download options when loading static images.
83
+ return resource.id;
84
+ }
85
+ }
86
+ // presentation 3.0
87
+ images = this.getContent();
88
+ if (images && images.length) {
89
+ var firstImage = images[0];
90
+ var body = firstImage.getBody();
91
+ var anno = body[0];
92
+ var services = anno.getServices();
93
+ if (!width) {
94
+ width = anno.getWidth();
95
+ }
96
+ var service = services
97
+ ? services.find(function (service) {
98
+ return internal_1.Utils.isImageServiceType(service.getIIIFResourceType());
99
+ })
100
+ : null;
101
+ if (service) {
102
+ id = service.id;
103
+ quality = internal_1.Utils.getImageQuality(service.getProfile());
104
+ }
105
+ else if (width === anno.getWidth()) {
106
+ // if the passed width is the same as the resource width
107
+ // i.e. not looking for a thumbnail
108
+ // return the full size image.
109
+ // used for download options when loading static images.
110
+ return anno.id;
111
+ }
112
+ }
113
+ // todo: should this be moved to getThumbUri?
114
+ if (!id) {
115
+ var thumbnail = this.getProperty("thumbnail");
116
+ if (thumbnail) {
117
+ if (typeof thumbnail === "string") {
118
+ return thumbnail;
119
+ }
120
+ else {
121
+ if (thumbnail["@id"]) {
122
+ return thumbnail["@id"];
123
+ }
124
+ else if (thumbnail.length) {
125
+ return thumbnail[0].id;
126
+ }
127
+ }
128
+ }
129
+ }
130
+ }
131
+ size = width + ",";
132
+ // trim off trailing '/'
133
+ if (id && id.endsWith("/")) {
134
+ id = id.substr(0, id.length - 1);
135
+ }
136
+ var uri = [id, region, size, rotation, quality + ".jpg"].join("/");
137
+ return uri;
138
+ };
139
+ Canvas.prototype.getMaxDimensions = function () {
140
+ var maxDimensions = null;
141
+ var profile;
142
+ if (this.externalResource &&
143
+ this.externalResource.data &&
144
+ this.externalResource.data.profile) {
145
+ profile = this.externalResource.data.profile;
146
+ if (Array.isArray(profile)) {
147
+ profile = profile.filter(function (p) { return p["maxWidth" || "maxwidth"]; })[0];
148
+ if (profile) {
149
+ maxDimensions = new internal_1.Size(profile.maxWidth, profile.maxHeight ? profile.maxHeight : profile.maxWidth);
150
+ }
151
+ }
152
+ }
153
+ return maxDimensions;
154
+ };
155
+ // Presentation API 3.0
156
+ Canvas.prototype.getContent = function () {
157
+ var content = [];
158
+ var items = this.__jsonld.items || this.__jsonld.content;
159
+ if (!items)
160
+ return content;
161
+ // should be contained in an AnnotationPage
162
+ var annotationPage = null;
163
+ if (items.length) {
164
+ annotationPage = new internal_1.AnnotationPage(items[0], this.options);
165
+ }
166
+ if (!annotationPage) {
167
+ return content;
168
+ }
169
+ var annotations = annotationPage.getItems();
170
+ for (var i = 0; i < annotations.length; i++) {
171
+ var a = annotations[i];
172
+ var annotation = new internal_1.Annotation(a, this.options);
173
+ content.push(annotation);
174
+ }
175
+ return content;
176
+ };
177
+ Canvas.prototype.getDuration = function () {
178
+ return this.getProperty("duration");
179
+ };
180
+ // presentation 2.0
181
+ Canvas.prototype.getImages = function () {
182
+ var images = [];
183
+ if (!this.__jsonld.images)
184
+ return images;
185
+ for (var i = 0; i < this.__jsonld.images.length; i++) {
186
+ var a = this.__jsonld.images[i];
187
+ var annotation = new internal_1.Annotation(a, this.options);
188
+ images.push(annotation);
189
+ }
190
+ return images;
191
+ };
192
+ Canvas.prototype.getIndex = function () {
193
+ return this.getProperty("index");
194
+ };
195
+ Canvas.prototype.getOtherContent = function () {
196
+ var _this = this;
197
+ var otherContent = Array.isArray(this.getProperty("otherContent"))
198
+ ? this.getProperty("otherContent")
199
+ : [this.getProperty("otherContent")];
200
+ var canonicalComparison = function (typeA, typeB) {
201
+ if (typeof typeA !== "string" || typeof typeB !== "string") {
202
+ return false;
203
+ }
204
+ return typeA.toLowerCase() === typeA.toLowerCase();
205
+ };
206
+ var otherPromises = otherContent
207
+ .filter(function (otherContent) {
208
+ return otherContent &&
209
+ canonicalComparison(otherContent["@type"], "sc:AnnotationList");
210
+ })
211
+ .map(function (annotationList, i) {
212
+ return new internal_1.AnnotationList(annotationList["label"] || "Annotation list " + i, annotationList, _this.options);
213
+ })
214
+ .map(function (annotationList) { return annotationList.load(); });
215
+ return Promise.all(otherPromises);
216
+ };
217
+ // Prefer thumbnail service to image service if supplied and if
218
+ // the thumbnail service can provide a satisfactory size +/- x pixels.
219
+ // this is used to get thumb URIs *before* the info.json has been requested
220
+ // and populate thumbnails in a viewer.
221
+ // the publisher may also provide pre-computed fixed-size thumbs for better performance.
222
+ //getThumbUri(width: number): string {
223
+ //
224
+ // var uri;
225
+ // var images: IAnnotation[] = this.getImages();
226
+ //
227
+ // if (images && images.length) {
228
+ // var firstImage = images[0];
229
+ // var resource: IResource = firstImage.getResource();
230
+ // var services: IService[] = resource.getServices();
231
+ //
232
+ // for (let i = 0; i < services.length; i++) {
233
+ // var service: IService = services[i];
234
+ // var id = service.id;
235
+ //
236
+ // if (!_endsWith(id, '/')) {
237
+ // id += '/';
238
+ // }
239
+ //
240
+ // uri = id + 'full/' + width + ',/0/' + Utils.getImageQuality(service.getProfile()) + '.jpg';
241
+ // }
242
+ // }
243
+ //
244
+ // return uri;
245
+ //}
246
+ //getType(): CanvasType {
247
+ // return new CanvasType(this.getProperty('@type').toLowerCase());
248
+ //}
249
+ Canvas.prototype.getWidth = function () {
250
+ return this.getProperty("width");
251
+ };
252
+ Canvas.prototype.getHeight = function () {
253
+ return this.getProperty("height");
254
+ };
255
+ Canvas.prototype.getViewingHint = function () {
256
+ return this.getProperty("viewingHint");
257
+ };
258
+ Object.defineProperty(Canvas.prototype, "imageResources", {
259
+ get: function () {
260
+ var _this = this;
261
+ var resources = flattenDeep_1.default([
262
+ this.getImages().map(function (i) { return i.getResource(); }),
263
+ this.getContent().map(function (i) { return i.getBody(); })
264
+ ]);
265
+ return flatten_1.default(resources.map(function (resource) {
266
+ switch (resource.getProperty("type").toLowerCase()) {
267
+ case dist_commonjs_1.ExternalResourceType.CHOICE:
268
+ case dist_commonjs_1.ExternalResourceType.OA_CHOICE:
269
+ return new Canvas({
270
+ images: flatten_1.default([
271
+ resource.getProperty("default"),
272
+ resource.getProperty("item")
273
+ ]).map(function (r) { return ({ resource: r }); })
274
+ }, _this.options)
275
+ .getImages()
276
+ .map(function (i) { return i.getResource(); });
277
+ default:
278
+ return resource;
279
+ }
280
+ }));
281
+ },
282
+ enumerable: true,
283
+ configurable: true
284
+ });
285
+ Object.defineProperty(Canvas.prototype, "resourceAnnotations", {
286
+ get: function () {
287
+ return flattenDeep_1.default([this.getImages(), this.getContent()]);
288
+ },
289
+ enumerable: true,
290
+ configurable: true
291
+ });
292
+ /**
293
+ * Returns a given resource Annotation, based on a contained resource or body
294
+ * id
295
+ */
296
+ Canvas.prototype.resourceAnnotation = function (id) {
297
+ return this.resourceAnnotations.find(function (anno) {
298
+ return anno.getResource().id === id ||
299
+ flatten_1.default(new Array(anno.getBody())).some(function (body) { return body.id === id; });
300
+ });
301
+ };
302
+ /**
303
+ * Returns the fragment placement values if a resourceAnnotation is placed on
304
+ * a canvas somewhere besides the full extent
305
+ */
306
+ Canvas.prototype.onFragment = function (id) {
307
+ var resourceAnnotation = this.resourceAnnotation(id);
308
+ if (!resourceAnnotation)
309
+ return undefined;
310
+ // IIIF v2
311
+ var on = resourceAnnotation.getProperty("on");
312
+ // IIIF v3
313
+ var target = resourceAnnotation.getProperty("target");
314
+ if (!on || !target) {
315
+ return undefined;
316
+ }
317
+ var fragmentMatch = (on || target).match(/xywh=(.*)$/);
318
+ if (!fragmentMatch)
319
+ return undefined;
320
+ return fragmentMatch[1].split(",").map(function (str) { return parseInt(str, 10); });
321
+ };
322
+ Object.defineProperty(Canvas.prototype, "iiifImageResources", {
323
+ get: function () {
324
+ return this.imageResources.filter(function (r) { return r && r.getServices()[0] && r.getServices()[0].id; });
325
+ },
326
+ enumerable: true,
327
+ configurable: true
328
+ });
329
+ Object.defineProperty(Canvas.prototype, "imageServiceIds", {
330
+ get: function () {
331
+ return this.iiifImageResources.map(function (r) { return r.getServices()[0].id; });
332
+ },
333
+ enumerable: true,
334
+ configurable: true
335
+ });
336
+ Object.defineProperty(Canvas.prototype, "aspectRatio", {
337
+ get: function () {
338
+ return this.getWidth() / this.getHeight();
339
+ },
340
+ enumerable: true,
341
+ configurable: true
342
+ });
343
+ return Canvas;
344
+ }(internal_1.Resource));
345
+ exports.Canvas = Canvas;
346
+ //# sourceMappingURL=Canvas.js.map