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

biiif

Package Overview
Dependencies
Maintainers
1
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

biiif - npm Package Compare versions

Comparing version 0.1.13 to 0.1.14

Motivations.js

73

Canvas.js

@@ -12,2 +12,3 @@ "use strict";

const Utils_1 = require("./Utils");
const Motivations_1 = require("./Motivations");
class Canvas {

@@ -26,3 +27,3 @@ constructor(filePath, url) {

// if there are, loop through them creating the custom annotations.
// if none of them were painting.yml, loop through all paintable file types adding to canvas.
// if none of them has a motivation of 'painting', loop through all paintable file types adding them to the canvas.
const customAnnotationFiles = glob.sync(this.filePath + '/*.yml', {

@@ -44,3 +45,3 @@ ignore: [

// assume painting
motivation = 'painting';
motivation = Motivations_1.Motivations.PAINTING;
console.warn(chalk.yellow('motivation property missing in ' + file + ', guessed ' + motivation));

@@ -51,3 +52,4 @@ }

let id;
if (motivation.toLowerCase() === 'painting' && yml.value) {
// if the motivation is painting, or isn't recognised, set the id to the path of the yml value
if ((motivation.toLowerCase() === Motivations_1.Motivations.PAINTING || !config.annotation.motivations[motivation]) && yml.value && extname(yml.value)) {
hasPaintingAnnotation = true;

@@ -65,53 +67,54 @@ id = urljoin(this.url.href, directoryName, yml.value);

// guess the type from the extension
const guess = config.annotation.extensions[extname(yml.value)];
if (guess && guess.length) {
const type = guess[0].type;
const type = Utils_1.Utils.getTypeByExtension(motivation, extname(yml.value));
if (type) {
annotationJson.body.type = type;
console.warn(chalk.yellow('type property missing in ' + file + ', guessed ' + type));
}
else {
console.warn(chalk.yellow('unable to determine type of ' + file));
}
}
else {
// guess the type from the motivation
const guess = config.annotation.motivations[motivation];
if (guess && guess.length) {
const type = guess[0].type;
else if (yml.format) {
// guess the type from the format
const type = Utils_1.Utils.getTypeByFormat(motivation, yml.format);
if (type) {
annotationJson.body.type = type;
console.warn(chalk.yellow('type property missing in ' + file + ', guessed ' + type));
}
else {
console.warn(chalk.yellow('unable to determine type of ' + file));
}
}
if (!annotationJson.body.type) {
delete annotationJson.body.type;
console.warn(chalk.yellow('unable to determine type of ' + file));
}
if (yml.format) {
annotationJson.body.format = yml.format;
}
else if (yml.value && extname(yml.value) && yml.type) {
// guess the format from the extension and type
const format = Utils_1.Utils.getFormatByExtensionAndType(motivation, extname(yml.value), yml.type);
if (format) {
annotationJson.body.format = format;
console.warn(chalk.yellow('format property missing in ' + file + ', guessed ' + format));
}
}
else if (yml.value && extname(yml.value)) {
// guess the format from the extension
const guess = config.annotation.extensions[extname(yml.value)];
if (guess && guess.length) {
const format = guess[0].format;
const format = Utils_1.Utils.getFormatByExtension(motivation, extname(yml.value));
if (format) {
annotationJson.body.format = format;
console.warn(chalk.yellow('format property missing in ' + file + ', guessed ' + format));
}
else {
console.warn(chalk.yellow('unable to determine format of ' + file));
}
}
else {
// guess the format from the motivation
const guess = config.annotation.motivations[motivation];
if (guess && guess.length) {
const format = guess[0].format;
else if (yml.type) {
// can only guess the format from the type if there is one typeformat for this motivation.
const format = Utils_1.Utils.getFormatByType(motivation, yml.type);
if (format) {
annotationJson.body.format = format;
console.warn(chalk.yellow('format property missing in ' + file + ', guessed ' + format));
}
else {
console.warn(chalk.yellow('unable to determine format of ' + file));
}
}
if (!annotationJson.body.format) {
delete annotationJson.body.format;
console.warn(chalk.yellow('unable to determine format of ' + file));
}
annotationJson.body.label = Utils_1.Utils.getLabel(this.infoYml.label);
if (yml.value) {
// if there's a value, and we're using a recognised motivation (except painting)
if (yml.value && config.annotation.motivations[motivation] && motivation !== Motivations_1.Motivations.PAINTING) {
annotationJson.body.value = yml.value;

@@ -138,4 +141,4 @@ }

const extName = extname(file);
// if config.annotation.extensions has a matching extension
let defaultPaintingExtension = config.annotation.extensions[extName];
// if config.annotation has a matching extension
let defaultPaintingExtension = config.annotation.motivations.painting[extName];
let directoryName = dirname(file);

@@ -149,3 +152,3 @@ directoryName = directoryName.substr(directoryName.lastIndexOf('/'));

annotationJson.id = urljoin(canvasJson.id, 'annotation', canvasJson.items[0].items.length);
annotationJson.motivation = "painting";
annotationJson.motivation = Motivations_1.Motivations.PAINTING;
annotationJson.target = canvasJson.id;

@@ -152,0 +155,0 @@ annotationJson.body.id = id;

{
"annotation": {
"motivations": {
"commenting": [
{
"type": "TextualBody",
"format": "text/plain"
}
]
},
"extensions": {
".crt": [
{
"type": "PhysicalObject",
"format": "application/corto"
}
],
".drc": [
{
"type": "PhysicalObject",
"format": "application/draco"
}
],
".gltf": [
{
"type": "PhysicalObject",
"format": "model/gltf+json"
}
],
".jpg": [
{
"type": "Image",
"format": "image/jpeg"
}
],
".json": [
{
"type": "PhysicalObject",
"format": "application/vnd.threejs+json"
}
],
".mp4": [
{
"type": "Video",
"format": "video/mp4"
}
],
".obj": [
{
"type": "PhysicalObject",
"format": "text/plain"
}
],
".pdf": [
{
"type": "PDF",
"format": "application/pdf"
}
],
".ply": [
{
"type": "PhysicalObject",
"format": "application/ply"
}
],
".png": [
{
"type": "Image",
"format": "image/png"
}
]
"painting": {
".crt": [
{
"type": "PhysicalObject",
"format": "application/corto"
}
],
".drc": [
{
"type": "PhysicalObject",
"format": "application/draco"
}
],
".gltf": [
{
"type": "PhysicalObject",
"format": "model/gltf+json"
}
],
".jpg": [
{
"type": "Image",
"format": "image/jpeg"
}
],
".json": [
{
"type": "Text",
"format": "application/json"
},
{
"type": "PhysicalObject",
"format": "application/vnd.threejs+json"
}
],
".mp4": [
{
"type": "Video",
"format": "video/mp4"
}
],
".obj": [
{
"type": "PhysicalObject",
"format": "text/plain"
}
],
".pdf": [
{
"type": "PDF",
"format": "application/pdf"
}
],
".ply": [
{
"type": "PhysicalObject",
"format": "application/ply"
}
],
".png": [
{
"type": "Image",
"format": "image/png"
}
]
},
"commenting": {
".txt": [
{
"type": "TextualBody",
"format": "text/plain"
}
]
}
}
}
}
{
"name": "biiif",
"version": "0.1.13",
"version": "0.1.14",
"description": "A CLI to build IIIF collections",

@@ -5,0 +5,0 @@ "main": "index.js",

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

const { join } = require('path');
const config = require('./config');
const labelBoilerplate = require('./boilerplate/label');

@@ -11,2 +12,64 @@ const thumbnailBoilerplate = require('./boilerplate/thumbnail');

class Utils {
static getTypeByExtension(motivation, extension) {
const m = config.annotation.motivations[motivation];
if (m) {
if (m[extension] && m[extension].length) {
return m[extension][0].type;
}
}
return undefined;
}
static getFormatByExtension(motivation, extension) {
const m = config.annotation.motivations[motivation];
if (m) {
if (m[extension] && m[extension].length) {
return m[extension][0].format;
}
}
return undefined;
}
static getFormatByExtensionAndType(motivation, extension, type) {
const m = config.annotation.motivations[motivation];
if (m) {
if (m[extension] && m[extension].length) {
const typeformats = m[extension];
for (let i = 0; i < typeformats.length; i++) {
const typeformat = typeformats[i];
if (typeformat.type === type) {
return typeformat.format;
}
}
}
}
return undefined;
}
static getTypeByFormat(motivation, format) {
const m = config.annotation.motivations[motivation];
if (m) {
for (const extension in m) {
const typeformats = m[extension];
for (let i = 0; i < typeformats.length; i++) {
const typeformat = typeformats[i];
if (typeformat.format === format) {
return typeformat.type;
}
}
}
}
return undefined;
}
static getFormatByType(motivation, type) {
const m = config.annotation.motivations[motivation];
// only able to categorically say there's a matching format
// if there's a single extension with a single type
if (m) {
if (Object.keys(m).length === 1) {
const typeformats = m[Object.keys(m)[0]];
if (typeformats.length === 1) {
return typeformats[0].format;
}
}
}
return undefined;
}
static timeout(ms) {

@@ -13,0 +76,0 @@ return new Promise(resolve => setTimeout(resolve, ms));

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc