New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

manifesto.js

Package Overview
Dependencies
Maintainers
1
Versions
131
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

manifesto.js - npm Package Compare versions

Comparing version

to
4.2.3

15

dist-commonjs/Canvas.d.ts

@@ -16,2 +16,17 @@ import { ViewingHint } from "@iiif/vocabulary/dist-commonjs";

getViewingHint(): ViewingHint | null;
readonly imageResources: any;
readonly resourceAnnotations: any;
/**
* Returns a given resource Annotation, based on a contained resource or body
* id
*/
resourceAnnotation(id: any): any;
/**
* Returns the fragment placement values if a resourceAnnotation is placed on
* a canvas somewhere besides the full extent
*/
onFragment(id: any): any;
readonly iiifImageResources: any;
readonly imageServiceIds: any;
readonly aspectRatio: number;
}

@@ -16,3 +16,6 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var dist_commonjs_1 = require("@iiif/vocabulary/dist-commonjs");
var internal_1 = require("./internal");
var flatten_1 = require("lodash/flatten");
var flattenDeep_1 = require("lodash/flattenDeep");
var Canvas = /** @class */ (function (_super) {

@@ -216,2 +219,84 @@ __extends(Canvas, _super);

};
Object.defineProperty(Canvas.prototype, "imageResources", {
get: function () {
var _this = this;
var resources = flattenDeep_1.default([
this.getImages().map(function (i) { return i.getResource(); }),
this.getContent().map(function (i) { return i.getBody(); })
]);
return flatten_1.default(resources.map(function (resource) {
switch (resource.getProperty("type").toLowerCase()) {
case dist_commonjs_1.ExternalResourceType.CHOICE:
case dist_commonjs_1.ExternalResourceType.OA_CHOICE:
return new Canvas({
images: flatten_1.default([
resource.getProperty("default"),
resource.getProperty("item")
]).map(function (r) { return ({ resource: r }); })
}, _this.options)
.getImages()
.map(function (i) { return i.getResource(); });
default:
return resource;
}
}));
},
enumerable: true,
configurable: true
});
Object.defineProperty(Canvas.prototype, "resourceAnnotations", {
get: function () {
return flattenDeep_1.default([this.getImages(), this.getContent()]);
},
enumerable: true,
configurable: true
});
/**
* Returns a given resource Annotation, based on a contained resource or body
* id
*/
Canvas.prototype.resourceAnnotation = function (id) {
return this.resourceAnnotations.find(function (anno) {
return anno.getResource().id === id ||
flatten_1.default(new Array(anno.getBody())).some(function (body) { return body.id === id; });
});
};
/**
* Returns the fragment placement values if a resourceAnnotation is placed on
* a canvas somewhere besides the full extent
*/
Canvas.prototype.onFragment = function (id) {
var resourceAnnotation = this.resourceAnnotation(id);
if (!resourceAnnotation)
return undefined;
// IIIF v2
var on = resourceAnnotation.getProperty("on");
// IIIF v3
var target = resourceAnnotation.getProperty("target");
var fragmentMatch = (on || target).match(/xywh=(.*)$/);
if (!fragmentMatch)
return undefined;
return fragmentMatch[1].split(",").map(function (str) { return parseInt(str, 10); });
};
Object.defineProperty(Canvas.prototype, "iiifImageResources", {
get: function () {
return this.imageResources.filter(function (r) { return r && r.getServices()[0] && r.getServices()[0].id; });
},
enumerable: true,
configurable: true
});
Object.defineProperty(Canvas.prototype, "imageServiceIds", {
get: function () {
return this.iiifImageResources.map(function (r) { return r.getServices()[0].id; });
},
enumerable: true,
configurable: true
});
Object.defineProperty(Canvas.prototype, "aspectRatio", {
get: function () {
return this.getWidth() / this.getHeight();
},
enumerable: true,
configurable: true
});
return Canvas;

@@ -218,0 +303,0 @@ }(internal_1.Resource));

@@ -16,2 +16,17 @@ import { ViewingHint } from "@iiif/vocabulary/dist-commonjs";

getViewingHint(): ViewingHint | null;
readonly imageResources: any;
readonly resourceAnnotations: any;
/**
* Returns a given resource Annotation, based on a contained resource or body
* id
*/
resourceAnnotation(id: any): any;
/**
* Returns the fragment placement values if a resourceAnnotation is placed on
* a canvas somewhere besides the full extent
*/
onFragment(id: any): any;
readonly iiifImageResources: any;
readonly imageServiceIds: any;
readonly aspectRatio: number;
}

@@ -14,3 +14,6 @@ var __extends = (this && this.__extends) || (function () {

})();
import { ExternalResourceType } from "@iiif/vocabulary/dist-commonjs";
import { Annotation, AnnotationList, AnnotationPage, Resource, Size, Utils } from "./internal";
import flatten from "lodash/flatten";
import flattenDeep from "lodash/flattenDeep";
var Canvas = /** @class */ (function (_super) {

@@ -214,2 +217,84 @@ __extends(Canvas, _super);

};
Object.defineProperty(Canvas.prototype, "imageResources", {
get: function () {
var _this = this;
var resources = flattenDeep([
this.getImages().map(function (i) { return i.getResource(); }),
this.getContent().map(function (i) { return i.getBody(); })
]);
return flatten(resources.map(function (resource) {
switch (resource.getProperty("type").toLowerCase()) {
case ExternalResourceType.CHOICE:
case ExternalResourceType.OA_CHOICE:
return new Canvas({
images: flatten([
resource.getProperty("default"),
resource.getProperty("item")
]).map(function (r) { return ({ resource: r }); })
}, _this.options)
.getImages()
.map(function (i) { return i.getResource(); });
default:
return resource;
}
}));
},
enumerable: true,
configurable: true
});
Object.defineProperty(Canvas.prototype, "resourceAnnotations", {
get: function () {
return flattenDeep([this.getImages(), this.getContent()]);
},
enumerable: true,
configurable: true
});
/**
* Returns a given resource Annotation, based on a contained resource or body
* id
*/
Canvas.prototype.resourceAnnotation = function (id) {
return this.resourceAnnotations.find(function (anno) {
return anno.getResource().id === id ||
flatten(new Array(anno.getBody())).some(function (body) { return body.id === id; });
});
};
/**
* Returns the fragment placement values if a resourceAnnotation is placed on
* a canvas somewhere besides the full extent
*/
Canvas.prototype.onFragment = function (id) {
var resourceAnnotation = this.resourceAnnotation(id);
if (!resourceAnnotation)
return undefined;
// IIIF v2
var on = resourceAnnotation.getProperty("on");
// IIIF v3
var target = resourceAnnotation.getProperty("target");
var fragmentMatch = (on || target).match(/xywh=(.*)$/);
if (!fragmentMatch)
return undefined;
return fragmentMatch[1].split(",").map(function (str) { return parseInt(str, 10); });
};
Object.defineProperty(Canvas.prototype, "iiifImageResources", {
get: function () {
return this.imageResources.filter(function (r) { return r && r.getServices()[0] && r.getServices()[0].id; });
},
enumerable: true,
configurable: true
});
Object.defineProperty(Canvas.prototype, "imageServiceIds", {
get: function () {
return this.iiifImageResources.map(function (r) { return r.getServices()[0].id; });
},
enumerable: true,
configurable: true
});
Object.defineProperty(Canvas.prototype, "aspectRatio", {
get: function () {
return this.getWidth() / this.getHeight();
},
enumerable: true,
configurable: true
});
return Canvas;

@@ -216,0 +301,0 @@ }(Resource));

7

package.json
{
"name": "manifesto.js",
"version": "4.2.2",
"version": "4.2.3",
"description": "IIIF Presentation API utility library for client and server",

@@ -63,4 +63,5 @@ "main": "./dist-commonjs/index.js",

"@edsilv/http-status-codes": "^1.0.3",
"@iiif/vocabulary": "^1.0.11",
"isomorphic-unfetch": "^3.0.0"
"@iiif/vocabulary": "^1.0.20",
"isomorphic-unfetch": "^3.0.0",
"lodash": "^4.17.21"
},

@@ -67,0 +68,0 @@ "directories": {

@@ -111,2 +111,17 @@ /// <reference types="node" />

getViewingHint(): ViewingHint | null;
readonly imageResources: any;
readonly resourceAnnotations: any;
/**
* Returns a given resource Annotation, based on a contained resource or body
* id
*/
resourceAnnotation(id: any): any;
/**
* Returns the fragment placement values if a resourceAnnotation is placed on
* a canvas somewhere besides the full extent
*/
onFragment(id: any): any;
readonly iiifImageResources: any;
readonly imageServiceIds: any;
readonly aspectRatio: number;
}

@@ -113,0 +128,0 @@ export declare class Collection extends IIIFResource {

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