Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@annotation-studio/redux

Package Overview
Dependencies
Maintainers
1
Versions
173
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@annotation-studio/redux - npm Package Compare versions

Comparing version 1.0.0-next.97499cf4 to 1.0.0-next.a5b2ef3f

5

es/actions/elucidate.js

@@ -39,2 +39,3 @@ import md5 from 'blueimp-md5';

var elucidateServer = getServer(state());
return createElucidateCollection(elucidateServer, label, md5(resourceId)).then(function (collection) {

@@ -82,4 +83,4 @@ dispatch(setCollection(resourceId, collection));

dispatch(addElucidateAnnotation(annotation));
return annotation;
dispatch(addElucidateAnnotation(postedAnnotation));
return postedAnnotation;
});

@@ -86,0 +87,0 @@ };

4

es/actions/manifest.js

@@ -12,5 +12,3 @@ export var MANIFEST_ADD = 'MANIFEST_ADD';

dispatch({ type: MANIFEST_REQUEST, payload: { url: url } });
return fetch(url, {
cache: process.env.NODE_ENV === 'production' ? 'default' : 'force-cache'
}).then(function (response) {
return fetch(url).then(function (response) {
return response.json();

@@ -17,0 +15,0 @@ }).then(function (body) {

@@ -156,4 +156,4 @@ import _extends from 'babel-runtime/helpers/extends';

}).reduce(function (state, field) {
if (field && field.omekaMetaData && field.omekaMetaData && field.omekaMetaData.bodyType.id && field.omekaMetaData.bodyType.id === 'oa:TextualBody' && field.inputType === 'madoc:textarea') {
var body = new AnnotationBody(null, draft.input[field.id], 'text/plain', 'TextualBody');
if (field && field.omekaMetaData && field.omekaMetaData && field.omekaMetaData.bodyType.id && field.omekaMetaData.bodyType.id === 'oa:TextualBody' && (field.inputType === 'madoc:textarea' || field.inputType === 'madoc:htmlfield')) {
var body = new AnnotationBody(null, draft.input[field.id], field.inputType === 'madoc:textarea' ? 'text/plain' : 'text/html', 'TextualBody');
body.purpose = field.omekaMetaData.purpose ? field.omekaMetaData.purpose.label : null;

@@ -201,3 +201,6 @@ state.push(body);

var captureModelField = captureModel.fields[field.id];
var captureModelField = Object.values(captureModel.fields).find(function (_ref2) {
var id = _ref2.id;
return id === field.id;
});
if (!(captureModelField && (captureModelField.metaData || captureModelField.omekaMeta))) {

@@ -289,8 +292,8 @@ console.warn('createMultipleAnnotations', 'Looks like you have set derivedAnnoCombine to "False" without selectors on the fields, are you sure this is correct?', captureModelField);

export function createAnnotationFromCaptureModelAndDraft(_ref2) {
var target = _ref2.target,
captureModel = _ref2.captureModel,
draft = _ref2.draft,
customDraftSelector = _ref2.customDraftSelector,
partOf = _ref2.partOf;
export function createAnnotationFromCaptureModelAndDraft(_ref3) {
var target = _ref3.target,
captureModel = _ref3.captureModel,
draft = _ref3.draft,
customDraftSelector = _ref3.customDraftSelector,
partOf = _ref3.partOf;

@@ -297,0 +300,0 @@ var bodies = [];

@@ -110,4 +110,3 @@ import _asyncIterator from 'babel-runtime/helpers/asyncIterator';

body: JSON.stringify(body),
credentials: withoutCredentials ? null : process.env.NODE_ENV === 'production' ? 'include' : null,
cache: process.env.NODE_ENV === 'production' ? 'default' : 'force-cache',
credentials: withoutCredentials ? 'omit' : process.env.NODE_ENV === 'production' ? 'include' : 'omit',
redirect: 'follow'

@@ -138,6 +137,8 @@ }).then(function (response) {

try {
return makeRequest('POST', uri, body);
return makeRequest('POST', uri, body, headers);
} catch (e) {
console.warn('Request failed, trying again without credentials', e);
return makeRequest('POST', uri, body, { withoutCredentials: true });
return makeRequest('POST', uri, body, headers, {
withoutCredentials: true
});
}

@@ -150,6 +151,6 @@ }

try {
return makeRequest('PUT', uri, body);
return makeRequest('PUT', uri, body, headers);
} catch (e) {
console.warn('Request failed, trying again without credentials', e);
return makeRequest('PUT', uri, body, { withoutCredentials: true });
return makeRequest('PUT', uri, body, headers, { withoutCredentials: true });
}

@@ -156,0 +157,0 @@ }

import _extends from 'babel-runtime/helpers/extends';
import { AnnotationSelector } from '../lib/elucidate/index';
import { isV3Manifest } from '../utility';
export function getServer(state) {

@@ -16,6 +17,18 @@ return state.elucidate.server;

export function getCanvasFromManifest(manifest, canvasId) {
if (!(manifest || manifest.sequences || manifest.sequences[0] || manifest.sequences[0].canvases)) {
if (!manifest) {
return null;
}
var canvases = manifest.sequences[0].canvases;
var canvases = null;
var idProperty = null;
try {
if (isV3Manifest(manifest)) {
canvases = manifest.items;
idProperty = 'id';
} else {
canvases = manifest.sequences[0].canvases;
idProperty = '@id';
}
} catch (ex) {
return null;
}
for (var _iterator = canvases, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {

@@ -35,3 +48,3 @@ var _ref;

if (canvas['@id'] === canvasId) {
if (canvas[idProperty] === canvasId) {
return canvas;

@@ -38,0 +51,0 @@ }

@@ -0,1 +1,3 @@

import { isV3Manifest } from '../utility';
export function currentManifest(state) {

@@ -6,13 +8,18 @@ return manifestById(state, state.manifest.current);

export function getImageServiceFromCanvas(canvas) {
if (canvas.images && canvas.images[0] && canvas.images[0].resource && canvas.images[0].resource.service && canvas.images[0].resource.service['@id']) {
return canvas.images[0].resource.service['@id'] + '/info.json';
}
if (canvas.hasOwnProperty('type') && canvas.type === 'Canvas') {
if (canvas.items && canvas.items[0] && canvas.items[0].items && canvas.items[0].items[0] && canvas.items[0].items[0].body && canvas.items[0].items[0].body.service && canvas.items[0].items[0].body.service[0] && canvas.items[0].items[0].body.service[0].id) {
return canvas.items[0].items[0].body.service[0].id + '/info.json';
}
} else {
if (canvas.images && canvas.images[0] && canvas.images[0].resource && canvas.images[0].resource.service && canvas.images[0].resource.service['@id']) {
return canvas.images[0].resource.service['@id'] + '/info.json';
}
if (canvas.thumbnail && canvas.thumbnail.service && canvas.thumbnail.service['@id']) {
return canvas.thumbnail.service['@id'] + '/info.json';
if (canvas.thumbnail && canvas.thumbnail.service && canvas.thumbnail.service['@id']) {
return canvas.thumbnail.service['@id'] + '/info.json';
}
if (canvas.thumbnail && canvas.thumbnail['@id']) {
return canvas.thumbnail['@id'];
}
}
if (canvas.thumbnail && canvas.thumbnail['@id']) {
return canvas.thumbnail['@id'];
}
return null;

@@ -33,6 +40,18 @@ }

var canvasId = state.manifest.currentCanvas;
if (!(manifest && canvasId && manifest.sequences && manifest.sequences[0] && manifest.sequences[0].canvases)) {
return null;
var canvases = null;
var idProperty = null;
if (isV3Manifest(manifest)) {
if (!manifest.hasOwnProperty('items')) {
return null;
}
canvases = manifest.items;
idProperty = 'id';
} else {
if (!(manifest && canvasId && manifest.sequences && manifest.sequences[0] && manifest.sequences[0].canvases)) {
return null;
}
canvases = manifest.sequences[0].canvases;
idProperty = '@id';
}
var canvases = manifest.sequences[0].canvases;
for (var _iterator = canvases, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {

@@ -52,3 +71,3 @@ var _ref;

if (canvas['@id'] === canvasId) {
if (canvas[idProperty] === canvasId) {
return canvas;

@@ -55,0 +74,0 @@ }

@@ -52,2 +52,22 @@ var SHOW_LOGS = false;

return item;
}
var CONTEXT_V3 = 'http://iiif.io/api/presentation/3/context.json';
export function isV3Manifest(manifest) {
if (!manifest) {
return false;
}
var context = manifest['@context'];
if (!context) {
return false;
}
switch (context.constructor) {
case Array:
return context.includes(CONTEXT_V3);
case String:
return context === CONTEXT_V3;
default:
return false;
}
}

@@ -65,2 +65,3 @@ 'use strict';

var elucidateServer = (0, _elucidateQuery.getServer)(state());
return (0, _elucidate.createElucidateCollection)(elucidateServer, label, (0, _blueimpMd2.default)(resourceId)).then(function (collection) {

@@ -108,4 +109,4 @@ dispatch(setCollection(resourceId, collection));

dispatch(addElucidateAnnotation(annotation));
return annotation;
dispatch(addElucidateAnnotation(postedAnnotation));
return postedAnnotation;
});

@@ -112,0 +113,0 @@ };

@@ -20,5 +20,3 @@ 'use strict';

dispatch({ type: MANIFEST_REQUEST, payload: { url: url } });
return fetch(url, {
cache: process.env.NODE_ENV === 'production' ? 'default' : 'force-cache'
}).then(function (response) {
return fetch(url).then(function (response) {
return response.json();

@@ -25,0 +23,0 @@ }).then(function (body) {

@@ -194,4 +194,4 @@ 'use strict';

}).reduce(function (state, field) {
if (field && field.omekaMetaData && field.omekaMetaData && field.omekaMetaData.bodyType.id && field.omekaMetaData.bodyType.id === 'oa:TextualBody' && field.inputType === 'madoc:textarea') {
var body = new _AnnotationBody2.default(null, draft.input[field.id], 'text/plain', 'TextualBody');
if (field && field.omekaMetaData && field.omekaMetaData && field.omekaMetaData.bodyType.id && field.omekaMetaData.bodyType.id === 'oa:TextualBody' && (field.inputType === 'madoc:textarea' || field.inputType === 'madoc:htmlfield')) {
var body = new _AnnotationBody2.default(null, draft.input[field.id], field.inputType === 'madoc:textarea' ? 'text/plain' : 'text/html', 'TextualBody');
body.purpose = field.omekaMetaData.purpose ? field.omekaMetaData.purpose.label : null;

@@ -239,3 +239,6 @@ state.push(body);

var captureModelField = captureModel.fields[field.id];
var captureModelField = Object.values(captureModel.fields).find(function (_ref2) {
var id = _ref2.id;
return id === field.id;
});
if (!(captureModelField && (captureModelField.metaData || captureModelField.omekaMeta))) {

@@ -327,8 +330,8 @@ console.warn('createMultipleAnnotations', 'Looks like you have set derivedAnnoCombine to "False" without selectors on the fields, are you sure this is correct?', captureModelField);

function createAnnotationFromCaptureModelAndDraft(_ref2) {
var target = _ref2.target,
captureModel = _ref2.captureModel,
draft = _ref2.draft,
customDraftSelector = _ref2.customDraftSelector,
partOf = _ref2.partOf;
function createAnnotationFromCaptureModelAndDraft(_ref3) {
var target = _ref3.target,
captureModel = _ref3.captureModel,
draft = _ref3.draft,
customDraftSelector = _ref3.customDraftSelector,
partOf = _ref3.partOf;

@@ -335,0 +338,0 @@ var bodies = [];

@@ -251,4 +251,3 @@ 'use strict';

body: JSON.stringify(body),
credentials: withoutCredentials ? null : process.env.NODE_ENV === 'production' ? 'include' : null,
cache: process.env.NODE_ENV === 'production' ? 'default' : 'force-cache',
credentials: withoutCredentials ? 'omit' : process.env.NODE_ENV === 'production' ? 'include' : 'omit',
redirect: 'follow'

@@ -279,6 +278,8 @@ }).then(function (response) {

try {
return makeRequest('POST', uri, body);
return makeRequest('POST', uri, body, headers);
} catch (e) {
console.warn('Request failed, trying again without credentials', e);
return makeRequest('POST', uri, body, { withoutCredentials: true });
return makeRequest('POST', uri, body, headers, {
withoutCredentials: true
});
}

@@ -291,6 +292,6 @@ }

try {
return makeRequest('PUT', uri, body);
return makeRequest('PUT', uri, body, headers);
} catch (e) {
console.warn('Request failed, trying again without credentials', e);
return makeRequest('PUT', uri, body, { withoutCredentials: true });
return makeRequest('PUT', uri, body, headers, { withoutCredentials: true });
}

@@ -297,0 +298,0 @@ }

@@ -19,2 +19,4 @@ 'use strict';

var _utility = require('../utility');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -35,6 +37,18 @@

function getCanvasFromManifest(manifest, canvasId) {
if (!(manifest || manifest.sequences || manifest.sequences[0] || manifest.sequences[0].canvases)) {
if (!manifest) {
return null;
}
var canvases = manifest.sequences[0].canvases;
var canvases = null;
var idProperty = null;
try {
if ((0, _utility.isV3Manifest)(manifest)) {
canvases = manifest.items;
idProperty = 'id';
} else {
canvases = manifest.sequences[0].canvases;
idProperty = '@id';
}
} catch (ex) {
return null;
}
for (var _iterator = canvases, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {

@@ -54,3 +68,3 @@ var _ref;

if (canvas['@id'] === canvasId) {
if (canvas[idProperty] === canvasId) {
return canvas;

@@ -57,0 +71,0 @@ }

@@ -10,2 +10,5 @@ 'use strict';

exports.allManifests = allManifests;
var _utility = require('../utility');
function currentManifest(state) {

@@ -16,13 +19,18 @@ return manifestById(state, state.manifest.current);

function getImageServiceFromCanvas(canvas) {
if (canvas.images && canvas.images[0] && canvas.images[0].resource && canvas.images[0].resource.service && canvas.images[0].resource.service['@id']) {
return canvas.images[0].resource.service['@id'] + '/info.json';
}
if (canvas.hasOwnProperty('type') && canvas.type === 'Canvas') {
if (canvas.items && canvas.items[0] && canvas.items[0].items && canvas.items[0].items[0] && canvas.items[0].items[0].body && canvas.items[0].items[0].body.service && canvas.items[0].items[0].body.service[0] && canvas.items[0].items[0].body.service[0].id) {
return canvas.items[0].items[0].body.service[0].id + '/info.json';
}
} else {
if (canvas.images && canvas.images[0] && canvas.images[0].resource && canvas.images[0].resource.service && canvas.images[0].resource.service['@id']) {
return canvas.images[0].resource.service['@id'] + '/info.json';
}
if (canvas.thumbnail && canvas.thumbnail.service && canvas.thumbnail.service['@id']) {
return canvas.thumbnail.service['@id'] + '/info.json';
if (canvas.thumbnail && canvas.thumbnail.service && canvas.thumbnail.service['@id']) {
return canvas.thumbnail.service['@id'] + '/info.json';
}
if (canvas.thumbnail && canvas.thumbnail['@id']) {
return canvas.thumbnail['@id'];
}
}
if (canvas.thumbnail && canvas.thumbnail['@id']) {
return canvas.thumbnail['@id'];
}
return null;

@@ -43,6 +51,18 @@ }

var canvasId = state.manifest.currentCanvas;
if (!(manifest && canvasId && manifest.sequences && manifest.sequences[0] && manifest.sequences[0].canvases)) {
return null;
var canvases = null;
var idProperty = null;
if ((0, _utility.isV3Manifest)(manifest)) {
if (!manifest.hasOwnProperty('items')) {
return null;
}
canvases = manifest.items;
idProperty = 'id';
} else {
if (!(manifest && canvasId && manifest.sequences && manifest.sequences[0] && manifest.sequences[0].canvases)) {
return null;
}
canvases = manifest.sequences[0].canvases;
idProperty = '@id';
}
var canvases = manifest.sequences[0].canvases;
for (var _iterator = canvases, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {

@@ -62,3 +82,3 @@ var _ref;

if (canvas['@id'] === canvasId) {
if (canvas[idProperty] === canvasId) {
return canvas;

@@ -65,0 +85,0 @@ }

@@ -5,2 +5,3 @@ 'use strict';

exports.selectorCompat = selectorCompat;
exports.isV3Manifest = isV3Manifest;
var SHOW_LOGS = false;

@@ -57,2 +58,22 @@ var SHOW_WARNINGS = false;

return item;
}
var CONTEXT_V3 = 'http://iiif.io/api/presentation/3/context.json';
function isV3Manifest(manifest) {
if (!manifest) {
return false;
}
var context = manifest['@context'];
if (!context) {
return false;
}
switch (context.constructor) {
case Array:
return context.includes(CONTEXT_V3);
case String:
return context === CONTEXT_V3;
default:
return false;
}
}
{
"name": "@annotation-studio/redux",
"version": "1.0.0-next.97499cf4",
"version": "1.0.0-next.a5b2ef3f",
"description": "Describe annotation-redux here",

@@ -38,3 +38,3 @@ "main": "lib/index.js",

"devDependencies": {
"@fesk/test-environment": "^1.0.0-next.97499cf4",
"@fesk/test-environment": "1.0.0-next.a5b2ef3f",
"babel-jest": "^20.0.3",

@@ -46,7 +46,9 @@ "babel-plugin-transform-async-to-generator": "^6.24.1",

"cross-spawn": "^6.0.5",
"jest": "^20.0.0",
"fetch-mock": "^6.5.1",
"jest": "^23.6.0",
"nwb": "^0.21.5",
"nwb-watch": "^1.0.0-next.97499cf4",
"nwb-watch": "1.0.0-next.a5b2ef3f",
"react-intl": "^2.2.2",
"react-intl-redux": "^0.7.0",
"redux-mock-store": "^1.5.3",
"webpack-cli": "^2.0.11"

@@ -53,0 +55,0 @@ },

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