manifesto.js
Advanced tools
Comparing version
@@ -21,3 +21,5 @@ "use strict"; | ||
var internal_1 = require("./internal"); | ||
// @ts-ignore | ||
var flatten_1 = __importDefault(require("lodash/flatten")); | ||
// @ts-ignore | ||
var flattenDeep_1 = __importDefault(require("lodash/flattenDeep")); | ||
@@ -57,3 +59,5 @@ var Canvas = /** @class */ (function (_super) { | ||
// info.json hasn't been loaded yet | ||
var images = this.getImages(); | ||
var images = void 0; | ||
// presentation 2.0 | ||
images = this.getImages(); | ||
if (images && images.length) { | ||
@@ -67,3 +71,6 @@ var firstImage = images[0]; | ||
var service = services | ||
? services.find(function (service) { return internal_1.Utils.isImageProfile(service.getProfile()); }) | ||
? services.find(function (service) { | ||
return (internal_1.Utils.isImageProfile(service.getProfile()) || | ||
internal_1.Utils.isImageServiceType(service.getIIIFResourceType())); | ||
}) | ||
: null; | ||
@@ -82,2 +89,29 @@ if (service) { | ||
} | ||
// presentation 3.0 | ||
images = this.getContent(); | ||
if (images && images.length) { | ||
var firstImage = images[0]; | ||
var body = firstImage.getBody(); | ||
var anno = body[0]; | ||
var services = anno.getServices(); | ||
if (!width) { | ||
width = anno.getWidth(); | ||
} | ||
var service = services | ||
? services.find(function (service) { | ||
return internal_1.Utils.isImageServiceType(service.getIIIFResourceType()); | ||
}) | ||
: null; | ||
if (service) { | ||
id = service.id; | ||
quality = internal_1.Utils.getImageQuality(service.getProfile()); | ||
} | ||
else if (width === anno.getWidth()) { | ||
// if the passed width is the same as the resource width | ||
// i.e. not looking for a thumbnail | ||
// return the full size image. | ||
// used for download options when loading static images. | ||
return anno.id; | ||
} | ||
} | ||
// todo: should this be moved to getThumbUri? | ||
@@ -150,2 +184,3 @@ if (!id) { | ||
}; | ||
// presentation 2.0 | ||
Canvas.prototype.getImages = function () { | ||
@@ -152,0 +187,0 @@ var images = []; |
@@ -14,2 +14,3 @@ import { IAccessToken, IExternalResource, IIIFResource, IManifestoOptions, JSONLDResource, Service, StatusCode, TreeNode } from "./internal"; | ||
static isImageProfile(profile: ServiceProfile): boolean; | ||
static isImageServiceType(type: string | null): boolean; | ||
static isLevel0ImageProfile(profile: ServiceProfile): boolean; | ||
@@ -16,0 +17,0 @@ static isLevel1ImageProfile(profile: ServiceProfile): boolean; |
@@ -158,2 +158,7 @@ "use strict"; | ||
}; | ||
Utils.isImageServiceType = function (type) { | ||
return ((type !== null && | ||
type.toLowerCase() === dist_commonjs_1.ServiceType.IMAGE_SERVICE_2.toLowerCase()) || | ||
type === dist_commonjs_1.ServiceType.IMAGE_SERVICE_3.toLowerCase()); | ||
}; | ||
Utils.isLevel0ImageProfile = function (profile) { | ||
@@ -160,0 +165,0 @@ if (Utils.normalisedUrlsMatch(profile, dist_commonjs_1.ServiceProfile.IMAGE_0_COMPLIANCE_LEVEL_0) || |
@@ -16,3 +16,5 @@ var __extends = (this && this.__extends) || (function () { | ||
import { Annotation, AnnotationList, AnnotationPage, Resource, Size, Utils } from "./internal"; | ||
// @ts-ignore | ||
import flatten from "lodash/flatten"; | ||
// @ts-ignore | ||
import flattenDeep from "lodash/flattenDeep"; | ||
@@ -52,3 +54,5 @@ var Canvas = /** @class */ (function (_super) { | ||
// info.json hasn't been loaded yet | ||
var images = this.getImages(); | ||
var images = void 0; | ||
// presentation 2.0 | ||
images = this.getImages(); | ||
if (images && images.length) { | ||
@@ -62,3 +66,6 @@ var firstImage = images[0]; | ||
var service = services | ||
? services.find(function (service) { return Utils.isImageProfile(service.getProfile()); }) | ||
? services.find(function (service) { | ||
return (Utils.isImageProfile(service.getProfile()) || | ||
Utils.isImageServiceType(service.getIIIFResourceType())); | ||
}) | ||
: null; | ||
@@ -77,2 +84,29 @@ if (service) { | ||
} | ||
// presentation 3.0 | ||
images = this.getContent(); | ||
if (images && images.length) { | ||
var firstImage = images[0]; | ||
var body = firstImage.getBody(); | ||
var anno = body[0]; | ||
var services = anno.getServices(); | ||
if (!width) { | ||
width = anno.getWidth(); | ||
} | ||
var service = services | ||
? services.find(function (service) { | ||
return Utils.isImageServiceType(service.getIIIFResourceType()); | ||
}) | ||
: null; | ||
if (service) { | ||
id = service.id; | ||
quality = Utils.getImageQuality(service.getProfile()); | ||
} | ||
else if (width === anno.getWidth()) { | ||
// if the passed width is the same as the resource width | ||
// i.e. not looking for a thumbnail | ||
// return the full size image. | ||
// used for download options when loading static images. | ||
return anno.id; | ||
} | ||
} | ||
// todo: should this be moved to getThumbUri? | ||
@@ -145,2 +179,3 @@ if (!id) { | ||
}; | ||
// presentation 2.0 | ||
Canvas.prototype.getImages = function () { | ||
@@ -147,0 +182,0 @@ var images = []; |
@@ -14,2 +14,3 @@ import { IAccessToken, IExternalResource, IIIFResource, IManifestoOptions, JSONLDResource, Service, StatusCode, TreeNode } from "./internal"; | ||
static isImageProfile(profile: ServiceProfile): boolean; | ||
static isImageServiceType(type: string | null): boolean; | ||
static isLevel0ImageProfile(profile: ServiceProfile): boolean; | ||
@@ -16,0 +17,0 @@ static isLevel1ImageProfile(profile: ServiceProfile): boolean; |
@@ -38,3 +38,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
import { Deserialiser, Service, StatusCode } from "./internal"; | ||
import { ServiceProfile } from "@iiif/vocabulary/dist-commonjs"; | ||
import { ServiceProfile, ServiceType } from "@iiif/vocabulary/dist-commonjs"; | ||
import { OK, MOVED_TEMPORARILY, UNAUTHORIZED } from "@edsilv/http-status-codes/dist-commonjs"; | ||
@@ -157,2 +157,7 @@ import "isomorphic-unfetch"; | ||
}; | ||
Utils.isImageServiceType = function (type) { | ||
return ((type !== null && | ||
type.toLowerCase() === ServiceType.IMAGE_SERVICE_2.toLowerCase()) || | ||
type === ServiceType.IMAGE_SERVICE_3.toLowerCase()); | ||
}; | ||
Utils.isLevel0ImageProfile = function (profile) { | ||
@@ -159,0 +164,0 @@ if (Utils.normalisedUrlsMatch(profile, ServiceProfile.IMAGE_0_COMPLIANCE_LEVEL_0) || |
{ | ||
"name": "manifesto.js", | ||
"version": "4.2.14", | ||
"version": "4.2.15", | ||
"description": "IIIF Presentation API utility library for client and server", | ||
@@ -21,3 +21,4 @@ "main": "./dist-commonjs/index.js", | ||
"prepublishOnly": "npm run build && npm run test", | ||
"test": "mocha" | ||
"test": "mocha", | ||
"watch": "npm run build:esmodule -- --watch" | ||
}, | ||
@@ -64,3 +65,3 @@ "engines": { | ||
"@edsilv/http-status-codes": "^1.0.3", | ||
"@iiif/vocabulary": "^1.0.20", | ||
"@iiif/vocabulary": "^1.0.26", | ||
"isomorphic-unfetch": "^3.0.0", | ||
@@ -67,0 +68,0 @@ "lodash": "^4.17.21" |
@@ -60,3 +60,4 @@ module.exports = { | ||
"deephierarchytop": "http://localhost:3001/deephierarchytop.json", | ||
"sctagracilis": "http://localhost:3001/sctagracilis.json" | ||
"sctagracilis": "http://localhost:3001/sctagracilis.json", | ||
"riksmuseumimageapiv3thumbnails": "http://localhost:3001/riksmuseum-image-api-v3-thumbnails.json", | ||
//"query-bodleian": "http://iiif.bodleian.ox.ac.uk/iiif/manifest/f22e9dae-c070-48eb-be0b-aa6c5bc195a6.json", | ||
@@ -63,0 +64,0 @@ //"query-gams": "http://gams.uni-graz.at/cocoon/mets2json?source=http%3A%2F%2Fgams.uni-graz.at%2Farchive%2Fget%2Fo%3Asrbas.1535%2FMETS_SOURCE" |
@@ -14,7 +14,7 @@ const finalhandler = require('finalhandler'); | ||
before(function(done) { | ||
before(function (done) { | ||
const serve = serveStatic('test/fixtures', {'index': ['index.html', 'index.htm']}); | ||
const serve = serveStatic('test/fixtures', { 'index': ['index.html', 'index.htm'] }); | ||
server = http.createServer(function(req, res){ | ||
server = http.createServer(function (req, res) { | ||
const final = finalhandler(req, res); | ||
@@ -29,68 +29,69 @@ serve(req, res, final) | ||
after(function() { | ||
after(function () { | ||
server.close(); | ||
}); | ||
importTest('aarau', './tests/aarau'); | ||
importTest('annotation-dimensions', './tests/annotation-dimensions'); | ||
importTest('annotation-list', './tests/annotation-list'); | ||
importTest('anzacbulletin', './tests/anzacbulletin'); | ||
importTest('audio', './tests/audio'); | ||
importTest('bad-manifest-url', './tests/bad-manifest-url'); | ||
importTest('biocrats', './tests/biocrats'); | ||
importTest('book-of-remembrance', './tests/book-of-remembrance'); | ||
importTest('canvas-metadata', './tests/canvas-metadata'); | ||
importTest('cardiganshire', './tests/cardiganshire'); | ||
importTest('collection-with-thumbnail', './tests/collection-with-thumbnail'); | ||
importTest('correspondance', './tests/correspondance'); | ||
importTest('deep-hierarchy', './tests/deep-hierarchy'); | ||
importTest('default-label', './tests/default-label'); | ||
importTest('get-manifest-behavior', './tests/get-manifest-behavior'); | ||
importTest('get-range-by-path', './tests/get-range-by-path'); | ||
importTest('get-range-by-id', './tests/get-range-by-id'); | ||
importTest('get-resource', './tests/get-resource'); | ||
importTest('herbal', './tests/herbal'); | ||
importTest('horriblemurders', './tests/horriblemurders'); | ||
importTest('https', './tests/https'); | ||
importTest('illustrationsofchina', './tests/illustrationsofchina'); | ||
importTest('items-not-sequence', './tests/items-not-sequence'); | ||
importTest('LabelValuePair', './tests/LabelValuePair.test'); | ||
importTest('LanguageMap', './tests/LanguageMap.test'); | ||
importTest('logo', './tests/logo'); | ||
importTest('lunchroommanners', './tests/lunchroommanners'); | ||
importTest('manifest-with-thumbnail', './tests/manifest-with-thumbnail'); | ||
importTest('members-collection', './tests/members-collection'); | ||
importTest('members-ranges', './tests/members-ranges'); | ||
importTest('members', './tests/members'); | ||
importTest('multi-value-range-metadata', './tests/multi-value-range-metadata'); | ||
importTest('nested', './tests/nested'); | ||
importTest('nga-highlights', './tests/nga-highlights'); | ||
importTest('no-nav-ranges', './tests/no-nav-ranges'); | ||
importTest('plato', './tests/plato'); | ||
importTest('poster-canvas', './tests/poster-canvas'); | ||
importTest('potterselectric', './tests/potterselectric'); | ||
importTest('pres3-3d', './tests/pres3-3d'); | ||
importTest('pres3-av-basic', './tests/pres3-av-basic'); | ||
importTest('pres3-collection', './tests/pres3-collection'); | ||
importTest('pres3-collection2', './tests/pres3-collection2'); | ||
importTest('pres3-collection3', './tests/pres3-collection3'); | ||
importTest('pres3-collection4', './tests/pres3-collection4'); | ||
importTest('pres3-pdf', './tests/pres3-pdf'); | ||
importTest('pres3', './tests/pres3'); | ||
importTest('presentation2-paging', './tests/presentation2-paging'); | ||
importTest('presentation3-paging', './tests/presentation3-paging'); | ||
importTest('PropertyValue', './tests/PropertyValue.test') | ||
importTest('pseudoalbert', './tests/pseudoalbert'); | ||
importTest('qatarrighttoleft', './tests/qatarrighttoleft'); | ||
importTest('querystring', './tests/querystring'); | ||
importTest('required-statement', './tests/required-statement'); | ||
// importTest('rhul', './tests/rhul'); | ||
importTest('riksarkivetlarge', './tests/riksarkivetlarge'); | ||
importTest('scroll', './tests/scroll'); | ||
importTest('static-thumbs', './tests/static-thumbs'); | ||
importTest('storyofwellcome', './tests/storyofwellcome'); | ||
importTest('string', './tests/string'); | ||
importTest('tankeryshouse', './tests/tankeryshouse'); | ||
importTest('translations', './tests/translations'); | ||
importTest('witnesstopeter', './tests/witnesstopeter'); | ||
importTest('Utils', './tests/Utils.test'); | ||
importTest('rijksmuseum-image-api-v3-thumbnails', './tests/rijksmuseum-image-api-v3-thumbnails'); | ||
// importTest('aarau', './tests/aarau'); | ||
// importTest('annotation-dimensions', './tests/annotation-dimensions'); | ||
// importTest('annotation-list', './tests/annotation-list'); | ||
// importTest('anzacbulletin', './tests/anzacbulletin'); | ||
// importTest('audio', './tests/audio'); | ||
// importTest('bad-manifest-url', './tests/bad-manifest-url'); | ||
// importTest('biocrats', './tests/biocrats'); | ||
// importTest('book-of-remembrance', './tests/book-of-remembrance'); | ||
// importTest('canvas-metadata', './tests/canvas-metadata'); | ||
// importTest('cardiganshire', './tests/cardiganshire'); | ||
// importTest('collection-with-thumbnail', './tests/collection-with-thumbnail'); | ||
// importTest('correspondance', './tests/correspondance'); | ||
// importTest('deep-hierarchy', './tests/deep-hierarchy'); | ||
// importTest('default-label', './tests/default-label'); | ||
// importTest('get-manifest-behavior', './tests/get-manifest-behavior'); | ||
// importTest('get-range-by-path', './tests/get-range-by-path'); | ||
// importTest('get-range-by-id', './tests/get-range-by-id'); | ||
// importTest('get-resource', './tests/get-resource'); | ||
// importTest('herbal', './tests/herbal'); | ||
// importTest('horriblemurders', './tests/horriblemurders'); | ||
// importTest('https', './tests/https'); | ||
// importTest('illustrationsofchina', './tests/illustrationsofchina'); | ||
// importTest('items-not-sequence', './tests/items-not-sequence'); | ||
// importTest('LabelValuePair', './tests/LabelValuePair.test'); | ||
// importTest('LanguageMap', './tests/LanguageMap.test'); | ||
// importTest('logo', './tests/logo'); | ||
// importTest('lunchroommanners', './tests/lunchroommanners'); | ||
// importTest('manifest-with-thumbnail', './tests/manifest-with-thumbnail'); | ||
// importTest('members-collection', './tests/members-collection'); | ||
// importTest('members-ranges', './tests/members-ranges'); | ||
// importTest('members', './tests/members'); | ||
// importTest('multi-value-range-metadata', './tests/multi-value-range-metadata'); | ||
// importTest('nested', './tests/nested'); | ||
// importTest('nga-highlights', './tests/nga-highlights'); | ||
// importTest('no-nav-ranges', './tests/no-nav-ranges'); | ||
// importTest('plato', './tests/plato'); | ||
// importTest('poster-canvas', './tests/poster-canvas'); | ||
// importTest('potterselectric', './tests/potterselectric'); | ||
// importTest('pres3-3d', './tests/pres3-3d'); | ||
// importTest('pres3-av-basic', './tests/pres3-av-basic'); | ||
// importTest('pres3-collection', './tests/pres3-collection'); | ||
// importTest('pres3-collection2', './tests/pres3-collection2'); | ||
// importTest('pres3-collection3', './tests/pres3-collection3'); | ||
// importTest('pres3-collection4', './tests/pres3-collection4'); | ||
// importTest('pres3-pdf', './tests/pres3-pdf'); | ||
// importTest('pres3', './tests/pres3'); | ||
// importTest('presentation2-paging', './tests/presentation2-paging'); | ||
// importTest('presentation3-paging', './tests/presentation3-paging'); | ||
// importTest('PropertyValue', './tests/PropertyValue.test') | ||
// importTest('pseudoalbert', './tests/pseudoalbert'); | ||
// importTest('qatarrighttoleft', './tests/qatarrighttoleft'); | ||
// importTest('querystring', './tests/querystring'); | ||
// importTest('required-statement', './tests/required-statement'); | ||
// // importTest('rhul', './tests/rhul'); | ||
// importTest('riksarkivetlarge', './tests/riksarkivetlarge'); | ||
// importTest('scroll', './tests/scroll'); | ||
// importTest('static-thumbs', './tests/static-thumbs'); | ||
// importTest('storyofwellcome', './tests/storyofwellcome'); | ||
// importTest('string', './tests/string'); | ||
// importTest('tankeryshouse', './tests/tankeryshouse'); | ||
// importTest('translations', './tests/translations'); | ||
// importTest('witnesstopeter', './tests/witnesstopeter'); | ||
// importTest('Utils', './tests/Utils.test'); |
@@ -451,2 +451,3 @@ /// <reference types="node" /> | ||
static isImageProfile(profile: ServiceProfile): boolean; | ||
static isImageServiceType(type: string | null): boolean; | ||
static isLevel0ImageProfile(profile: ServiceProfile): boolean; | ||
@@ -453,0 +454,0 @@ static isLevel1ImageProfile(profile: ServiceProfile): boolean; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
37956651
3.56%459
0.44%310724
11.8%Updated