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

@annotation-studio/plugin-core

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@annotation-studio/plugin-core - npm Package Compare versions

Comparing version 1.0.0-pr.73cfbc15 to 1.0.0-pr.7943fd1a

@@ -11,3 +11,3 @@ var _class, _temp2;

import { connector } from '@annotation-studio/redux';
import { changeFingerprintSource, changeFingerprintIdentity, changeFingerPrintCreator } from '@annotation-studio/redux/es/actions/drafts';
import { isSavedDraft, changeFingerprintSource, changeFingerprintIdentity, changeFingerPrintCreator } from '@annotation-studio/redux/es/actions/drafts';
import { getAllAnnotationsFromCollection } from '@annotation-studio/redux/es/lib/elucidate/index';

@@ -39,3 +39,5 @@ import { asyncForEach } from './core.utils';

}, _this.warnUser = function (event) {
var drafts = _this.props.drafts;
var _this$props = _this.props,
drafts = _this$props.drafts,
disableCloseWarning = _this$props.disableCloseWarning;

@@ -45,4 +47,12 @@ var changes = drafts ? Object.values(drafts).filter(function (draft) {

}) : [];
if (changes.length) {
var message = 'You have ' + changes + ' unsaved annotation' + (changes.length > 1 ? 's' : null) + ', if you leave the page they will be lost.';;
var changedValues = Object.values(drafts).map(function (draft) {
return Object.values(draft.input).filter(function (e) {
return e;
});
}).filter(function (e) {
return e.length;
});
if (changes.length && changedValues.length && disableCloseWarning === false) {
var message = 'You have ' + changes + ' unsaved annotation' + (changes.length > 1 ? 's' : null) + ', if you leave the page they will be lost.';
event.preventDefault();

@@ -61,2 +71,3 @@ event.returnValue = message;

manifest = _props.manifest,
manifestJson = _props.manifestJson,
createCollection = _props.createCollection,

@@ -75,20 +86,21 @@ addElucidateAnnotation = _props.addElucidateAnnotation,

if (!elucidateServer) {
return;
}
if (canvasId) {
fetch(manifest, {
var manifestPromise = manifestJson ? Promise.resolve(manifestJson) : fetch(manifest, {
cache: process.env.NODE_ENV === 'production' ? 'default' : 'force-cache'
}).then(function (response) {
return response.json();
}).then(function (response) {
});
manifestPromise.then(function (response) {
return addManifest(manifest, response);
}).then(function (response) {
}).then(function () {
return selectManifest(manifest);
}).then(function (response) {
}).then(function () {
return canvasId ? selectCanvas(canvasId) : null;
});
}
// Set the server.
setServer(elucidateServer, subject);
if (elucidateServer) {
// Set the server.
setServer(elucidateServer, subject);
}
// Set the resource.

@@ -103,3 +115,5 @@ if (subject) {

this.setState({ onlineStatus: navigator.onLine ? Core.ONLINE : Core.OFFLINE });
this.setState({
onlineStatus: navigator.onLine ? Core.ONLINE : Core.OFFLINE
});

@@ -115,28 +129,24 @@ // Import local storage saved items

var isSavedDraft = function isSavedDraft(annotation) {
if (annotation.motivation !== 'http://www.digirati.com/ns/crowds#drafting') {
return false;
}
if (Array.isArray(annotation.body)) {
return false;
}
return annotation.body.purpose === 'editing';
};
// Set collection.
createCollection(subject, subject).then(function (c) {
return getAllAnnotationsFromCollection(c);
}).then(function (iterable) {
return asyncForEach(iterable, function (i) {
if (isSavedDraft(i)) {
var draft = JSON.parse(i.body.value);
var identity = i.id.substr(i.id.length - 1) === '/' ? i.id.substr(0, i.id.length - 1).split('/').pop() : i.id.split('/').pop();
if (draft) {
importDraft(draft.id, changeFingerPrintCreator(changeFingerprintIdentity(draft, identity), i.creator && i.creator.name ? i.creator.name : 'unknown'));
if (elucidateServer) {
// Set collection.
createCollection(subject, subject).then(function (c) {
return getAllAnnotationsFromCollection(c);
}).then(function (iterable) {
return asyncForEach(iterable, function (i) {
if (isSavedDraft(i)) {
var draft = JSON.parse(i.body.value);
var identity = i.id.substr(i.id.length - 1) === '/' ? i.id.substr(0, i.id.length - 1).split('/').pop() : i.id.split('/').pop();
if (draft) {
importDraft(draft.id, changeFingerPrintCreator(changeFingerprintIdentity(draft, identity), i.creator && i.creator.name ? i.creator.name : 'unknown'));
}
} else {
addElucidateAnnotation(i);
}
} else {
addElucidateAnnotation(i);
}
});
});
});
}
if (this.props.onReady) {
this.props.onReady();
}
};

@@ -158,3 +168,4 @@

null,
'If you leave this page you may lose your progress on ',
'If you leave this page you may lose your progress on',
' ',
changes.length,

@@ -176,2 +187,3 @@ ' annotation',

Core.prototype.render = function render() {
var innerContent = this.props.innerContent;
var onlineStatus = this.state.onlineStatus;

@@ -190,3 +202,4 @@

React.version
)
),
innerContent ? innerContent : null
);

@@ -193,0 +206,0 @@ };

@@ -5,10 +5,5 @@ function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }

import { render } from 'react-dom';
import { createStore, reducers } from '@annotation-studio/redux';
import { unknownPropertyWarning } from './core.utils';
import CoreProvider from './core.provider';
import localstorage from 'store';
import moment from 'moment';
var DEFAULT_LOCALE = 'en';
export default function CorePlugin($el, _ref) {

@@ -18,22 +13,23 @@ var manifest = _ref.manifest,

elucidateServer = _ref.elucidateServer,
disableCloseWarning = _ref.disableCloseWarning,
locale = _ref.locale,
unknownProps = _objectWithoutProperties(_ref, ['manifest', 'canvas', 'elucidateServer', 'locale']);
unknownProps = _objectWithoutProperties(_ref, ['manifest', 'canvas', 'elucidateServer', 'disableCloseWarning', 'locale']);
unknownPropertyWarning(unknownProps);
locale = locale || DEFAULT_LOCALE;
moment.locale(locale);
var disableCloseWarningBoolean = disableCloseWarning ? disableCloseWarning === 'true' : false;
var url = window.location.href;
var savedDraftList = localstorage.get('annotation-studio/' + url) || {};
var store = createStore(reducers, [], locale);
render(React.createElement(CoreProvider, {
store: store,
manifest: manifest,
savedDraftList: savedDraftList,
elucidateServer: elucidateServer,
canvas: canvas
}), $el);
return Promise.resolve(store);
return new Promise(function (resolve, err) {
try {
render(React.createElement(CoreProvider, {
locale: locale,
manifest: manifest,
disableCloseWarning: disableCloseWarningBoolean,
elucidateServer: elucidateServer,
canvas: canvas,
onLoadStore: resolve
}), $el);
} catch (e) {
err(e);
}
});
}

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

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }

@@ -10,5 +12,11 @@

import React, { PureComponent } from 'react';
import { Provider } from 'react-redux';
import { pluginKit } from '@annotation-studio/components';
import { createStore, reducers } from '@annotation-studio/redux';
import merge from 'lodash.merge';
import localstorage from 'store';
import Core from './core';
import moment from 'moment/moment';
export var DEFAULT_LOCALE = 'en';
var CoreProvider = function (_PureComponent) {

@@ -18,16 +26,89 @@ _inherits(CoreProvider, _PureComponent);

function CoreProvider() {
var _temp, _this, _ret;
_classCallCheck(this, CoreProvider);
return _possibleConstructorReturn(this, _PureComponent.apply(this, arguments));
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _PureComponent.call.apply(_PureComponent, [this].concat(args))), _this), _this.state = {
savedDraftList: {},
storeReady: false
}, _this.store = null, _this.onReady = function () {
var onLoadStore = _this.props.onLoadStore;
if (onLoadStore) {
_this.setState(function () {
onLoadStore(_this.store);
return { storeReady: true };
});
}
}, _this.getStore = function () {
return _this.store;
}, _temp), _possibleConstructorReturn(_this, _ret);
}
CoreProvider.prototype.render = function render() {
CoreProvider.prototype.componentWillMount = function componentWillMount() {
var _props = this.props,
store = _props.store,
props = _objectWithoutProperties(_props, ['store']);
locale = _props.locale,
_props$loadSavedDraft = _props.loadSavedDrafts,
loadSavedDrafts = _props$loadSavedDraft === undefined ? true : _props$loadSavedDraft,
savedDraftsId = _props.savedDraftsId,
savedDraftList = _props.savedDraftList,
customCreateStore = _props.customCreateStore,
onLoadStore = _props.onLoadStore;
var selectedLocale = locale || DEFAULT_LOCALE;
moment.locale(selectedLocale);
this.setState({ locale: selectedLocale });
if (loadSavedDrafts) {
var url = savedDraftsId || window.location.href;
var savedDraftListFromLS = localstorage.get('annotation-studio/' + url) || {};
this.setState({
savedDraftList: merge(savedDraftList || {}, savedDraftListFromLS)
});
} else if (savedDraftList) {
this.setState({ savedDraftList: savedDraftList });
}
this.store = customCreateStore ? customCreateStore({ createStore: createStore, reducers: reducers, locale: this.state.locale }) : createStore(reducers, [], selectedLocale);
};
CoreProvider.prototype.render = function render() {
var _state = this.state,
storeReady = _state.storeReady,
savedDraftList = _state.savedDraftList,
locale = _state.locale;
var _props2 = this.props,
plugins = _props2.plugins,
behaviours = _props2.behaviours,
children = _props2.children,
props = _objectWithoutProperties(_props2, ['plugins', 'behaviours', 'children']);
return React.createElement(
Provider,
{ store: store },
React.createElement(Core, props)
pluginKit.Provider,
{
store: this.store,
plugins: plugins,
behaviours: behaviours
},
React.createElement(Core, _extends({}, props, {
onReady: this.onReady,
savedDraftList: savedDraftList,
innerContent: storeReady && children ? children(_extends({}, props, {
store: this.store,
savedDraftList: savedDraftList,
plugins: plugins,
behaviours: behaviours,
locale: locale
})) : null,
locale: locale
}))
);

@@ -34,0 +115,0 @@ };

import _regeneratorRuntime from 'babel-runtime/regenerator';
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }

@@ -9,3 +11,64 @@

import moment from 'moment';
import { generateDraftId } from '@annotation-studio/redux/es/actions/drafts';
export function draftCreationHelper(_ref) {
var _captureModel, _ref2;
var realId = _ref.id,
input = _ref.input,
selector = _ref.selector,
captureModel = _ref.captureModel,
tree = _ref.tree,
path = _ref.path,
motivation = _ref.motivation,
_ref$isPreviewing = _ref.isPreviewing,
isPreviewing = _ref$isPreviewing === undefined ? false : _ref$isPreviewing,
created = _ref.created;
var id = realId || generateDraftId();
return _ref2 = {}, _ref2[captureModel] = (_captureModel = {}, _captureModel[id] = {
id: id,
input: input,
selectors: Object.keys(input).reduce(function (acc, key) {
acc[key] = {};
return acc;
}, {}),
template: captureModel,
motivation: motivation ? motivation : {
id: 'http://www.w3.org/ns/oa#tagging',
label: 'oa:tagging',
instance: 'tagging'
},
isPublishing: false,
isPreviewing: isPreviewing,
selector: selector ? _extends({
type: 'madoc:boxdraw',
source: {
name: null,
template: captureModel,
scope: tree ? tree : captureModel,
draft: id
}
}, selector) : {
type: 'wholecanvasselector',
source: {
name: null,
template: captureModel,
scope: tree ? tree : captureModel,
draft: id
},
name: null
},
fingerprint: {
scope: tree ? tree : captureModel,
path: path ? path : tree && tree !== captureModel ? [captureModel] : [],
created: created ? created : new Date(),
lifecycle: 'DRAFT_LIFECYCLE_NEW',
source: 'localStorage',
creator: 'you',
partOf: null
}
}, _captureModel), _ref2;
}
export function getAttributes($el) {

@@ -23,3 +86,3 @@ var attributes = {};

export var fetchResourceTemplate = function () {
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(resource) {
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(resource) {
var headers, locale;

@@ -35,3 +98,3 @@ return _regeneratorRuntime.wrap(function _callee$(_context) {

if (locale && process.env.NODE_ENV === 'production') {
headers.set("X-Annotation-Studio-Locale", locale);
headers.set('X-Annotation-Studio-Locale', locale);
}

@@ -54,3 +117,3 @@

console.warn('Can\'t send credentials, not same origin. Falling back.', _context.t0);
console.warn("Can't send credentials, not same origin. Falling back.");
_context.prev = 12;

@@ -70,6 +133,5 @@ _context.next = 15;

console.warn('Unable to send locale, likely CORS not available. falling back.', _context.t1);
console.warn('Unable to send locale, likely CORS not available. falling back.');
_context.next = 23;
return fetch('' + resource, {
cache: process.env.NODE_ENV === 'production' ? 'default' : 'force-cache'

@@ -90,3 +152,3 @@ });

return function fetchResourceTemplate(_x) {
return _ref.apply(this, arguments);
return _ref3.apply(this, arguments);
};

@@ -104,5 +166,5 @@ }();

export function unknownPropertyWarning(unknownProps) {
delete unknownProps['class'];
delete unknownProps['behaviour'];
delete unknownProps['style'];
delete unknownProps.class;
delete unknownProps.behaviour;
delete unknownProps.style;
if (Object.keys(unknownProps).length) {

@@ -109,0 +171,0 @@ console.warn('Found unknown properties passed to component', unknownProps);

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

}, _this.warnUser = function (event) {
var drafts = _this.props.drafts;
var _this$props = _this.props,
drafts = _this$props.drafts,
disableCloseWarning = _this$props.disableCloseWarning;

@@ -57,4 +59,12 @@ var changes = drafts ? Object.values(drafts).filter(function (draft) {

}) : [];
if (changes.length) {
var message = 'You have ' + changes + ' unsaved annotation' + (changes.length > 1 ? 's' : null) + ', if you leave the page they will be lost.';;
var changedValues = Object.values(drafts).map(function (draft) {
return Object.values(draft.input).filter(function (e) {
return e;
});
}).filter(function (e) {
return e.length;
});
if (changes.length && changedValues.length && disableCloseWarning === false) {
var message = 'You have ' + changes + ' unsaved annotation' + (changes.length > 1 ? 's' : null) + ', if you leave the page they will be lost.';
event.preventDefault();

@@ -73,2 +83,3 @@ event.returnValue = message;

manifest = _props.manifest,
manifestJson = _props.manifestJson,
createCollection = _props.createCollection,

@@ -87,20 +98,21 @@ addElucidateAnnotation = _props.addElucidateAnnotation,

if (!elucidateServer) {
return;
}
if (canvasId) {
fetch(manifest, {
var manifestPromise = manifestJson ? Promise.resolve(manifestJson) : fetch(manifest, {
cache: process.env.NODE_ENV === 'production' ? 'default' : 'force-cache'
}).then(function (response) {
return response.json();
}).then(function (response) {
});
manifestPromise.then(function (response) {
return addManifest(manifest, response);
}).then(function (response) {
}).then(function () {
return selectManifest(manifest);
}).then(function (response) {
}).then(function () {
return canvasId ? selectCanvas(canvasId) : null;
});
}
// Set the server.
setServer(elucidateServer, subject);
if (elucidateServer) {
// Set the server.
setServer(elucidateServer, subject);
}
// Set the resource.

@@ -115,3 +127,5 @@ if (subject) {

this.setState({ onlineStatus: navigator.onLine ? Core.ONLINE : Core.OFFLINE });
this.setState({
onlineStatus: navigator.onLine ? Core.ONLINE : Core.OFFLINE
});

@@ -127,28 +141,24 @@ // Import local storage saved items

var isSavedDraft = function isSavedDraft(annotation) {
if (annotation.motivation !== 'http://www.digirati.com/ns/crowds#drafting') {
return false;
}
if (Array.isArray(annotation.body)) {
return false;
}
return annotation.body.purpose === 'editing';
};
// Set collection.
createCollection(subject, subject).then(function (c) {
return (0, _index.getAllAnnotationsFromCollection)(c);
}).then(function (iterable) {
return (0, _core.asyncForEach)(iterable, function (i) {
if (isSavedDraft(i)) {
var draft = JSON.parse(i.body.value);
var identity = i.id.substr(i.id.length - 1) === '/' ? i.id.substr(0, i.id.length - 1).split('/').pop() : i.id.split('/').pop();
if (draft) {
importDraft(draft.id, (0, _drafts.changeFingerPrintCreator)((0, _drafts.changeFingerprintIdentity)(draft, identity), i.creator && i.creator.name ? i.creator.name : 'unknown'));
if (elucidateServer) {
// Set collection.
createCollection(subject, subject).then(function (c) {
return (0, _index.getAllAnnotationsFromCollection)(c);
}).then(function (iterable) {
return (0, _core.asyncForEach)(iterable, function (i) {
if ((0, _drafts.isSavedDraft)(i)) {
var draft = JSON.parse(i.body.value);
var identity = i.id.substr(i.id.length - 1) === '/' ? i.id.substr(0, i.id.length - 1).split('/').pop() : i.id.split('/').pop();
if (draft) {
importDraft(draft.id, (0, _drafts.changeFingerPrintCreator)((0, _drafts.changeFingerprintIdentity)(draft, identity), i.creator && i.creator.name ? i.creator.name : 'unknown'));
}
} else {
addElucidateAnnotation(i);
}
} else {
addElucidateAnnotation(i);
}
});
});
});
}
if (this.props.onReady) {
this.props.onReady();
}
};

@@ -170,3 +180,4 @@

null,
'If you leave this page you may lose your progress on ',
'If you leave this page you may lose your progress on',
' ',
changes.length,

@@ -188,2 +199,3 @@ ' annotation',

Core.prototype.render = function render() {
var innerContent = this.props.innerContent;
var onlineStatus = this.state.onlineStatus;

@@ -202,3 +214,4 @@

_react2.default.version
)
),
innerContent ? innerContent : null
);

@@ -205,0 +218,0 @@ };

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

var _redux = require('@annotation-studio/redux');
var _core = require('./core.utils');

@@ -21,10 +19,2 @@

var _store = require('store');
var _store2 = _interopRequireDefault(_store);
var _moment = require('moment');
var _moment2 = _interopRequireDefault(_moment);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -34,4 +24,2 @@

var DEFAULT_LOCALE = 'en';
function CorePlugin($el, _ref) {

@@ -41,23 +29,24 @@ var manifest = _ref.manifest,

elucidateServer = _ref.elucidateServer,
disableCloseWarning = _ref.disableCloseWarning,
locale = _ref.locale,
unknownProps = _objectWithoutProperties(_ref, ['manifest', 'canvas', 'elucidateServer', 'locale']);
unknownProps = _objectWithoutProperties(_ref, ['manifest', 'canvas', 'elucidateServer', 'disableCloseWarning', 'locale']);
(0, _core.unknownPropertyWarning)(unknownProps);
locale = locale || DEFAULT_LOCALE;
_moment2.default.locale(locale);
var disableCloseWarningBoolean = disableCloseWarning ? disableCloseWarning === 'true' : false;
var url = window.location.href;
var savedDraftList = _store2.default.get('annotation-studio/' + url) || {};
var store = (0, _redux.createStore)(_redux.reducers, [], locale);
(0, _reactDom.render)(_react2.default.createElement(_core3.default, {
store: store,
manifest: manifest,
savedDraftList: savedDraftList,
elucidateServer: elucidateServer,
canvas: canvas
}), $el);
return Promise.resolve(store);
return new Promise(function (resolve, err) {
try {
(0, _reactDom.render)(_react2.default.createElement(_core3.default, {
locale: locale,
manifest: manifest,
disableCloseWarning: disableCloseWarningBoolean,
elucidateServer: elucidateServer,
canvas: canvas,
onLoadStore: resolve
}), $el);
} catch (e) {
err(e);
}
});
}
module.exports = exports['default'];
'use strict';
exports.__esModule = true;
exports.DEFAULT_LOCALE = undefined;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _react = require('react');

@@ -9,4 +12,14 @@

var _reactRedux = require('react-redux');
var _components = require('@annotation-studio/components');
var _redux = require('@annotation-studio/redux');
var _lodash = require('lodash.merge');
var _lodash2 = _interopRequireDefault(_lodash);
var _store = require('store');
var _store2 = _interopRequireDefault(_store);
var _core = require('./core');

@@ -16,2 +29,6 @@

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

@@ -27,2 +44,4 @@

var DEFAULT_LOCALE = exports.DEFAULT_LOCALE = 'en';
var CoreProvider = function (_PureComponent) {

@@ -32,16 +51,89 @@ _inherits(CoreProvider, _PureComponent);

function CoreProvider() {
var _temp, _this, _ret;
_classCallCheck(this, CoreProvider);
return _possibleConstructorReturn(this, _PureComponent.apply(this, arguments));
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _PureComponent.call.apply(_PureComponent, [this].concat(args))), _this), _this.state = {
savedDraftList: {},
storeReady: false
}, _this.store = null, _this.onReady = function () {
var onLoadStore = _this.props.onLoadStore;
if (onLoadStore) {
_this.setState(function () {
onLoadStore(_this.store);
return { storeReady: true };
});
}
}, _this.getStore = function () {
return _this.store;
}, _temp), _possibleConstructorReturn(_this, _ret);
}
CoreProvider.prototype.render = function render() {
CoreProvider.prototype.componentWillMount = function componentWillMount() {
var _props = this.props,
store = _props.store,
props = _objectWithoutProperties(_props, ['store']);
locale = _props.locale,
_props$loadSavedDraft = _props.loadSavedDrafts,
loadSavedDrafts = _props$loadSavedDraft === undefined ? true : _props$loadSavedDraft,
savedDraftsId = _props.savedDraftsId,
savedDraftList = _props.savedDraftList,
customCreateStore = _props.customCreateStore,
onLoadStore = _props.onLoadStore;
var selectedLocale = locale || DEFAULT_LOCALE;
_moment2.default.locale(selectedLocale);
this.setState({ locale: selectedLocale });
if (loadSavedDrafts) {
var url = savedDraftsId || window.location.href;
var savedDraftListFromLS = _store2.default.get('annotation-studio/' + url) || {};
this.setState({
savedDraftList: (0, _lodash2.default)(savedDraftList || {}, savedDraftListFromLS)
});
} else if (savedDraftList) {
this.setState({ savedDraftList: savedDraftList });
}
this.store = customCreateStore ? customCreateStore({ createStore: _redux.createStore, reducers: _redux.reducers, locale: this.state.locale }) : (0, _redux.createStore)(_redux.reducers, [], selectedLocale);
};
CoreProvider.prototype.render = function render() {
var _state = this.state,
storeReady = _state.storeReady,
savedDraftList = _state.savedDraftList,
locale = _state.locale;
var _props2 = this.props,
plugins = _props2.plugins,
behaviours = _props2.behaviours,
children = _props2.children,
props = _objectWithoutProperties(_props2, ['plugins', 'behaviours', 'children']);
return _react2.default.createElement(
_reactRedux.Provider,
{ store: store },
_react2.default.createElement(_core2.default, props)
_components.pluginKit.Provider,
{
store: this.store,
plugins: plugins,
behaviours: behaviours
},
_react2.default.createElement(_core2.default, _extends({}, props, {
onReady: this.onReady,
savedDraftList: savedDraftList,
innerContent: storeReady && children ? children(_extends({}, props, {
store: this.store,
savedDraftList: savedDraftList,
plugins: plugins,
behaviours: behaviours,
locale: locale
})) : null,
locale: locale
}))
);

@@ -53,3 +145,2 @@ };

exports.default = CoreProvider;
module.exports = exports['default'];
exports.default = CoreProvider;

@@ -10,4 +10,6 @@ 'use strict';

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var fetchResourceTemplate = exports.fetchResourceTemplate = function () {
var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee(resource) {
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee(resource) {
var headers, locale;

@@ -23,3 +25,3 @@ return _regenerator2.default.wrap(function _callee$(_context) {

if (locale && process.env.NODE_ENV === 'production') {
headers.set("X-Annotation-Studio-Locale", locale);
headers.set('X-Annotation-Studio-Locale', locale);
}

@@ -42,3 +44,3 @@

console.warn('Can\'t send credentials, not same origin. Falling back.', _context.t0);
console.warn("Can't send credentials, not same origin. Falling back.");
_context.prev = 12;

@@ -58,6 +60,5 @@ _context.next = 15;

console.warn('Unable to send locale, likely CORS not available. falling back.', _context.t1);
console.warn('Unable to send locale, likely CORS not available. falling back.');
_context.next = 23;
return fetch('' + resource, {
cache: process.env.NODE_ENV === 'production' ? 'default' : 'force-cache'

@@ -78,6 +79,7 @@ });

return function fetchResourceTemplate(_x) {
return _ref.apply(this, arguments);
return _ref3.apply(this, arguments);
};
}();
exports.draftCreationHelper = draftCreationHelper;
exports.getAttributes = getAttributes;

@@ -103,2 +105,4 @@ exports.deferred = deferred;

var _drafts = require('@annotation-studio/redux/es/actions/drafts');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -108,2 +112,62 @@

function draftCreationHelper(_ref) {
var _captureModel, _ref2;
var realId = _ref.id,
input = _ref.input,
selector = _ref.selector,
captureModel = _ref.captureModel,
tree = _ref.tree,
path = _ref.path,
motivation = _ref.motivation,
_ref$isPreviewing = _ref.isPreviewing,
isPreviewing = _ref$isPreviewing === undefined ? false : _ref$isPreviewing,
created = _ref.created;
var id = realId || (0, _drafts.generateDraftId)();
return _ref2 = {}, _ref2[captureModel] = (_captureModel = {}, _captureModel[id] = {
id: id,
input: input,
selectors: Object.keys(input).reduce(function (acc, key) {
acc[key] = {};
return acc;
}, {}),
template: captureModel,
motivation: motivation ? motivation : {
id: 'http://www.w3.org/ns/oa#tagging',
label: 'oa:tagging',
instance: 'tagging'
},
isPublishing: false,
isPreviewing: isPreviewing,
selector: selector ? _extends({
type: 'madoc:boxdraw',
source: {
name: null,
template: captureModel,
scope: tree ? tree : captureModel,
draft: id
}
}, selector) : {
type: 'wholecanvasselector',
source: {
name: null,
template: captureModel,
scope: tree ? tree : captureModel,
draft: id
},
name: null
},
fingerprint: {
scope: tree ? tree : captureModel,
path: path ? path : tree && tree !== captureModel ? [captureModel] : [],
created: created ? created : new Date(),
lifecycle: 'DRAFT_LIFECYCLE_NEW',
source: 'localStorage',
creator: 'you',
partOf: null
}
}, _captureModel), _ref2;
}
function getAttributes($el) {

@@ -129,5 +193,5 @@ var attributes = {};

function unknownPropertyWarning(unknownProps) {
delete unknownProps['class'];
delete unknownProps['behaviour'];
delete unknownProps['style'];
delete unknownProps.class;
delete unknownProps.behaviour;
delete unknownProps.style;
if (Object.keys(unknownProps).length) {

@@ -134,0 +198,0 @@ console.warn('Found unknown properties passed to component', unknownProps);

{
"name": "@annotation-studio/plugin-core",
"version": "1.0.0-pr.73cfbc15",
"version": "1.0.0-pr.7943fd1a",
"description": "Annotation studio core plugin",

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

"scripts": {
"watch": "./bin/watch",
"watch": "nwb-watch-module",
"build": "nwb build-web-module --copy-files",

@@ -20,15 +20,16 @@ "clean": "nwb clean-module",

"test:watch": "echo \"No tests in this package\"",
"prepublish": "npm run build"
"prepublish": "NODE_ENV=production npm run build"
},
"dependencies": {
"@annotation-studio/bridge": "^1.0.0-pr.73cfbc15",
"@annotation-studio/redux": "^1.0.0-pr.73cfbc15"
},
"peerDependencies": {
"moment": "*",
"react": "*",
"react-dom": "*",
"@annotation-studio/bridge": "1.0.0-rc.20",
"@annotation-studio/components": "1.0.0-rc.20",
"@annotation-studio/redux": "1.0.0-rc.20",
"moment": "^2.20.1",
"react": "^16.5.0",
"react-dom": "^16.5.0",
"react-redux": "*"
},
"devDependencies": {
"@annotation-studio/bridge": "1.0.0-pr.7943fd1a",
"@annotation-studio/redux": "1.0.0-pr.7943fd1a",
"babel-cli": "^6.24.1",

@@ -40,6 +41,8 @@ "babel-plugin-transform-flow-strip-types": "^6.22.0",

"extract-text-webpack-plugin": "^2.1.0",
"lodash.merge": "4.6.1",
"moment": "^2.20.1",
"nwb": "^0.21.5",
"react": "*",
"react-dom": "*",
"nwb-watch": "1.0.0-pr.7943fd1a",
"react": "^16.5.0",
"react-dom": "^16.5.0",
"react-redux": "*"

@@ -53,3 +56,6 @@ },

"license": "MIT",
"repository": ""
"repository": "",
"dependencies": {
"create-react-context": "^0.2.2"
}
}