digirati-annotation-redux
Advanced tools
Comparing version 0.2.15-alpha.971fcd47 to 0.2.15-alpha.be61f365
import _regeneratorRuntime from 'babel-runtime/regenerator'; | ||
import _asyncGenerator from 'babel-runtime/helpers/asyncGenerator'; | ||
import _extends from 'babel-runtime/helpers/extends'; | ||
import _classCallCheck from 'babel-runtime/helpers/classCallCheck'; | ||
var _class, _temp; | ||
var fetchPageCollection = function () { | ||
@@ -120,3 +117,3 @@ var _ref3 = _asyncGenerator.wrap(_regeneratorRuntime.mark(function _callee2(resource) { | ||
return function fetchPageCollection(_x5) { | ||
return function fetchPageCollection(_x4) { | ||
return _ref3.apply(this, arguments); | ||
@@ -133,71 +130,6 @@ }; | ||
export { AnnotationSelector } from './AnnotationSelector'; | ||
var CONTEXT = 'http://www.w3.org/ns/anno.jsonld'; | ||
export var AnnotationSelector = (_temp = _class = function () { | ||
AnnotationSelector.fromArray = function fromArray(multipleSelectors) { | ||
return multipleSelectors.map(function (annotation) { | ||
return AnnotationSelector.parse(annotation); | ||
}); | ||
}; | ||
AnnotationSelector.parse = function parse(text) { | ||
if (!text) { | ||
return null; | ||
} | ||
if (text.id) { | ||
return new AnnotationSelector(text.id, text.format, text.language, text.processingLanguage, text.textDirection); | ||
} | ||
console.info('--->', text); | ||
// @todo check for is text or is object and construct accordingly. | ||
return new AnnotationSelector(text); | ||
}; | ||
function AnnotationSelector(id, format, language, processingLanguage, textDirection) { | ||
_classCallCheck(this, AnnotationSelector); | ||
if (!id) { | ||
throw new Error('ID is required in selector'); | ||
} | ||
if (textDirection && textDirection !== AnnotationSelector.DIRECTION_AUTO && textDirection !== AnnotationSelector.DIRECTION_LTR && textDirection !== AnnotationSelector.DIRECTION_RTL) { | ||
throw new Error('textDirection must be ONE of [ltr, rtl, auto]'); | ||
} | ||
this.id = id; | ||
this.format = format; | ||
this.language = language; | ||
this.processingLanguage = processingLanguage; | ||
this.textDirection = textDirection; | ||
this.target = AnnotationSelector.parseTarget(id); | ||
} | ||
AnnotationSelector.parseTarget = function parseTarget(source) { | ||
var scale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; | ||
var match = AnnotationSelector.W3C_SELECTOR.exec(source); | ||
if (match) { | ||
return { | ||
unit: match[1] === 'percent:' ? 'percent' : 'pixel', | ||
scale: scale, | ||
expanded: true, | ||
x: parseInt(match[2], 10) * scale, | ||
y: parseInt(match[3], 10) * scale, | ||
width: parseInt(match[4], 10) * scale, | ||
height: parseInt(match[5], 10) * scale, | ||
toString: function toString() { | ||
// @todo maybe something else? | ||
return source.split('#')[0]; | ||
} | ||
}; | ||
} | ||
return source; | ||
}; | ||
AnnotationSelector.prototype.toString = function toString() { | ||
return this.id; | ||
}; | ||
return AnnotationSelector; | ||
}(), _class.DIRECTION_LTR = 'ltr', _class.DIRECTION_RTL = 'rtl', _class.DIRECTION_AUTO = 'auto', _class.W3C_SELECTOR = /[#&\?]xywh\=(pixel\:|percent\:)?(\d+),(\d+),(\d+),(\d+)/, _temp); | ||
export function makeRequest(method, uri, body) { | ||
@@ -336,3 +268,3 @@ var headers = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : []; | ||
return function getAllAnnotationsFromCollection(_x4) { | ||
return function getAllAnnotationsFromCollection(_x3) { | ||
return _ref.apply(this, arguments); | ||
@@ -339,0 +271,0 @@ }; |
@@ -18,8 +18,2 @@ 'use strict'; | ||
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); | ||
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); | ||
var _class, _temp; | ||
var getAllAnnotationsFromCollection = exports.getAllAnnotationsFromCollection = function () { | ||
@@ -125,3 +119,3 @@ var _ref = _asyncGenerator3.default.wrap(_regenerator2.default.mark(function _callee(collectionResource) { | ||
return function getAllAnnotationsFromCollection(_x4) { | ||
return function getAllAnnotationsFromCollection(_x3) { | ||
return _ref.apply(this, arguments); | ||
@@ -243,3 +237,3 @@ }; | ||
return function fetchPageCollection(_x5) { | ||
return function fetchPageCollection(_x4) { | ||
return _ref3.apply(this, arguments); | ||
@@ -249,2 +243,10 @@ }; | ||
var _AnnotationSelector = require('./AnnotationSelector'); | ||
Object.defineProperty(exports, 'AnnotationSelector', { | ||
enumerable: true, | ||
get: function get() { | ||
return _AnnotationSelector.AnnotationSelector; | ||
} | ||
}); | ||
exports.makeRequest = makeRequest; | ||
@@ -268,68 +270,2 @@ exports.get = get; | ||
var AnnotationSelector = exports.AnnotationSelector = (_temp = _class = function () { | ||
AnnotationSelector.fromArray = function fromArray(multipleSelectors) { | ||
return multipleSelectors.map(function (annotation) { | ||
return AnnotationSelector.parse(annotation); | ||
}); | ||
}; | ||
AnnotationSelector.parse = function parse(text) { | ||
if (!text) { | ||
return null; | ||
} | ||
if (text.id) { | ||
return new AnnotationSelector(text.id, text.format, text.language, text.processingLanguage, text.textDirection); | ||
} | ||
console.info('--->', text); | ||
// @todo check for is text or is object and construct accordingly. | ||
return new AnnotationSelector(text); | ||
}; | ||
function AnnotationSelector(id, format, language, processingLanguage, textDirection) { | ||
(0, _classCallCheck3.default)(this, AnnotationSelector); | ||
if (!id) { | ||
throw new Error('ID is required in selector'); | ||
} | ||
if (textDirection && textDirection !== AnnotationSelector.DIRECTION_AUTO && textDirection !== AnnotationSelector.DIRECTION_LTR && textDirection !== AnnotationSelector.DIRECTION_RTL) { | ||
throw new Error('textDirection must be ONE of [ltr, rtl, auto]'); | ||
} | ||
this.id = id; | ||
this.format = format; | ||
this.language = language; | ||
this.processingLanguage = processingLanguage; | ||
this.textDirection = textDirection; | ||
this.target = AnnotationSelector.parseTarget(id); | ||
} | ||
AnnotationSelector.parseTarget = function parseTarget(source) { | ||
var scale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; | ||
var match = AnnotationSelector.W3C_SELECTOR.exec(source); | ||
if (match) { | ||
return { | ||
unit: match[1] === 'percent:' ? 'percent' : 'pixel', | ||
scale: scale, | ||
expanded: true, | ||
x: parseInt(match[2], 10) * scale, | ||
y: parseInt(match[3], 10) * scale, | ||
width: parseInt(match[4], 10) * scale, | ||
height: parseInt(match[5], 10) * scale, | ||
toString: function toString() { | ||
// @todo maybe something else? | ||
return source.split('#')[0]; | ||
} | ||
}; | ||
} | ||
return source; | ||
}; | ||
AnnotationSelector.prototype.toString = function toString() { | ||
return this.id; | ||
}; | ||
return AnnotationSelector; | ||
}(), _class.DIRECTION_LTR = 'ltr', _class.DIRECTION_RTL = 'rtl', _class.DIRECTION_AUTO = 'auto', _class.W3C_SELECTOR = /[#&\?]xywh\=(pixel\:|percent\:)?(\d+),(\d+),(\d+),(\d+)/, _temp); | ||
function makeRequest(method, uri, body) { | ||
@@ -336,0 +272,0 @@ var headers = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : []; |
{ | ||
"name": "digirati-annotation-redux", | ||
"version": "0.2.15-alpha.971fcd47", | ||
"version": "0.2.15-alpha.be61f365", | ||
"description": "Describe annotation-redux here", | ||
@@ -5,0 +5,0 @@ "main": "es/index.js", |
92655
11
56
2414