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

digirati-annotation-redux

Package Overview
Dependencies
Maintainers
3
Versions
147
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

digirati-annotation-redux - npm Package Compare versions

Comparing version 0.2.20 to 0.3.0-alpha.902c3bec

es/query/selectorQuery.js

10

es/actions/drafts.js

@@ -8,2 +8,3 @@ import uuid from 'uuid/v4';

export var DRAFT_UPDATE_SELECTOR = 'DRAFT_UPDATE_SELECTOR';
export var DRAFT_UPDATE_FIELD_SELECTOR = 'DRAFT_UPDATE_FIELD_SELECTOR';
export var DRAFT_UPDATE_INPUT = 'DRAFT_UPDATE_INPUT';

@@ -19,6 +20,7 @@ export var DRAFT_SELECT = 'DRAFT_SELECT';

var motivation = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'tagging';
var selectors = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
return function (dispatch, state) {
var id = uuid();
dispatch({ type: DRAFT_CREATE, payload: { id: id, input: input, template: template, motivation: motivation } });
dispatch({ type: DRAFT_CREATE, payload: { id: id, input: input, template: template, selectors: selectors ? selectors : input, motivation: motivation } });
dispatch(selectDraft(id));

@@ -43,2 +45,8 @@ var currentTemplate = getCurrentResourceTemplate(state());

export function addSelectorToDraftField(id, selector, fieldId) {
var _selectors;
return { type: DRAFT_UPDATE_FIELD_SELECTOR, payload: { id: id, selectors: (_selectors = {}, _selectors[fieldId] = selector, _selectors) } };
}
export function addSelectorToDraft(id, selector) {

@@ -45,0 +53,0 @@ return { type: DRAFT_UPDATE_SELECTOR, payload: { id: id, selector: selector } };

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

import { addSelectorToDraft } from './drafts';
import _extends from 'babel-runtime/helpers/extends';
import { addSelectorToDraft, addSelectorToDraftField } from './drafts';

@@ -7,2 +8,3 @@ export var SELECTOR_SET_AVAILABLE = 'SELECTOR_SET_AVAILABLE';

export var SELECTOR_COMMIT_TO_DRAFT = 'SELECTOR_COMMIT_TO_DRAFT';
export var SELECTOR_COMMIT_TO_DRAFT_FIELD = 'SELECTOR_COMMIT_TO_DRAFT_FIELD';

@@ -17,2 +19,6 @@ export function setAvailableSelectors(selectors) {

export function chooseSecondarySelector(type, defaults) {
return { type: SELECTOR_CHOOSE, payload: { type: type, defaults: _extends({}, defaults, { secondary: true }) } };
}
export function updateSelector(data) {

@@ -22,2 +28,9 @@ return { type: SELECTOR_UPDATE, payload: { data: data } };

export function commitToCurrentDraftField(fieldId) {
return function (dispatch, getState) {
dispatch(addSelectorToDraftField(getState().drafts.currentDraft, getState().selector.currentSelector, fieldId));
dispatch({ type: SELECTOR_COMMIT_TO_DRAFT_FIELD });
};
}
export function commitToCurrentDraft() {

@@ -24,0 +37,0 @@ return function (dispatch, getState) {

5

es/connector.js

@@ -11,3 +11,3 @@ import { connect } from 'react-redux';

import { setViewer, withViewer } from './actions/viewer';
import { isSelecting, currentSelectorIsSecondary } from './query/selectorQuery';
export default connect(function (state) {

@@ -18,2 +18,5 @@ var annotationList = richAnnotationList(state);

state: state,
isSelecting: isSelecting(state),
isSelectingPrimary: isSelecting(state) && currentSelectorIsSecondary(state) === false,
isSelectingSecondary: isSelecting(state) && currentSelectorIsSecondary(state) === true,
currentSelector: state.selector && state.selector.currentSelector ? state.selector.currentSelector : null,

@@ -20,0 +23,0 @@ currentDraft: getCurrentDraft(state),

import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
import { DRAFT_CREATE, DRAFT_PUBLISHED, DRAFT_PUBLISHING, DRAFT_SELECT, DRAFT_UPDATE_INPUT, DRAFT_UPDATE_SELECTOR, DRAFT_DESELECT, DRAFT_PREVIEW, DRAFT_UNPREVIEW } from '../actions/drafts';
import { DRAFT_CREATE, DRAFT_PUBLISHED, DRAFT_PUBLISHING, DRAFT_SELECT, DRAFT_UPDATE_INPUT, DRAFT_UPDATE_SELECTOR, DRAFT_DESELECT, DRAFT_PREVIEW, DRAFT_UNPREVIEW, DRAFT_UPDATE_FIELD_SELECTOR } from '../actions/drafts';
import update from 'immutability-helper';

@@ -10,4 +10,17 @@

function draftModel(draft) {
return {
id: draft.id,
input: draft.input || {},
selectors: draft.selectors || {},
template: draft.template,
motivation: draft.motivation,
isPublishing: draft.isPublishing || false,
isPreviewing: draft.isPreviewing || false,
selector: draft.selector || null
};
}
export default function draftReducer() {
var _list, _list2, _list3, _list4, _list5, _list6;
var _list, _list2, _list3, _list4, _list5, _list6, _list7;

@@ -21,28 +34,27 @@ var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultState;

list: (_list = {}, _list[action.payload.id] = {
$set: {
id: action.payload.id,
input: action.payload.input,
template: action.payload.template,
motivation: action.payload.motivation,
isPublishing: false,
isPreviewing: false,
selector: null
}
$set: draftModel(action.payload)
}, _list)
});
case DRAFT_UPDATE_INPUT:
case DRAFT_UPDATE_FIELD_SELECTOR:
return update(state, {
list: (_list2 = {}, _list2[action.payload.id] = {
input: { $merge: action.payload.fields }
selectors: { $merge: action.payload.selectors }
}, _list2)
});
case DRAFT_UPDATE_SELECTOR:
case DRAFT_UPDATE_INPUT:
return update(state, {
list: (_list3 = {}, _list3[action.payload.id] = {
selector: { $set: action.payload.selector ? action.payload.selector : state.list[action.payload.id].selector }
input: { $merge: action.payload.fields }
}, _list3)
});
case DRAFT_UPDATE_SELECTOR:
return update(state, {
list: (_list4 = {}, _list4[action.payload.id] = {
selector: { $set: action.payload.selector ? action.payload.selector : state.list[action.payload.id].selector }
}, _list4)
});
case DRAFT_SELECT:

@@ -60,5 +72,5 @@ return update(state, {

return update(state, {
list: (_list4 = {}, _list4[action.payload.id] = {
list: (_list5 = {}, _list5[action.payload.id] = {
isPublishing: { $set: true }
}, _list4)
}, _list5)
});

@@ -68,5 +80,5 @@

return update(state, {
list: (_list5 = {}, _list5[action.payload.id] = {
list: (_list6 = {}, _list6[action.payload.id] = {
isPreviewing: { $set: true }
}, _list5)
}, _list6)
});

@@ -76,5 +88,5 @@

return update(state, {
list: (_list6 = {}, _list6[action.payload.id] = {
list: (_list7 = {}, _list7[action.payload.id] = {
isPreviewing: { $set: false }
}, _list6)
}, _list7)
});

@@ -81,0 +93,0 @@

import _extends from 'babel-runtime/helpers/extends';
import { SELECTOR_CHOOSE, SELECTOR_COMMIT_TO_DRAFT, SELECTOR_SET_AVAILABLE, SELECTOR_UPDATE } from '../actions/selectors';
import { SELECTOR_CHOOSE, SELECTOR_COMMIT_TO_DRAFT, SELECTOR_SET_AVAILABLE, SELECTOR_UPDATE, SELECTOR_COMMIT_TO_DRAFT_FIELD } from '../actions/selectors';
import update from 'immutability-helper';

@@ -36,2 +36,3 @@

case SELECTOR_COMMIT_TO_DRAFT:
case SELECTOR_COMMIT_TO_DRAFT_FIELD:
return update(state, {

@@ -38,0 +39,0 @@ currentSelector: { $set: {} }

'use strict';
exports.__esModule = true;
exports.DRAFT_UNPREVIEW = exports.DRAFT_PREVIEW = exports.DRAFT_PUBLISHED = exports.DRAFT_PUBLISHING = exports.DRAFT_DESELECT = exports.DRAFT_SELECT = exports.DRAFT_UPDATE_INPUT = exports.DRAFT_UPDATE_SELECTOR = exports.DRAFT_CREATE = undefined;
exports.DRAFT_UNPREVIEW = exports.DRAFT_PREVIEW = exports.DRAFT_PUBLISHED = exports.DRAFT_PUBLISHING = exports.DRAFT_DESELECT = exports.DRAFT_SELECT = exports.DRAFT_UPDATE_INPUT = exports.DRAFT_UPDATE_FIELD_SELECTOR = exports.DRAFT_UPDATE_SELECTOR = exports.DRAFT_CREATE = undefined;
exports.createDraft = createDraft;
exports.deselectDraft = deselectDraft;
exports.updateDraft = updateDraft;
exports.addSelectorToDraftField = addSelectorToDraftField;
exports.addSelectorToDraft = addSelectorToDraft;

@@ -21,3 +22,3 @@ exports.selectDraft = selectDraft;

var _selectors = require('./selectors');
var _selectors2 = require('./selectors');

@@ -30,2 +31,3 @@ var _resourceTemplateQuery = require('../query/resourceTemplateQuery');

var DRAFT_UPDATE_SELECTOR = exports.DRAFT_UPDATE_SELECTOR = 'DRAFT_UPDATE_SELECTOR';
var DRAFT_UPDATE_FIELD_SELECTOR = exports.DRAFT_UPDATE_FIELD_SELECTOR = 'DRAFT_UPDATE_FIELD_SELECTOR';
var DRAFT_UPDATE_INPUT = exports.DRAFT_UPDATE_INPUT = 'DRAFT_UPDATE_INPUT';

@@ -41,6 +43,7 @@ var DRAFT_SELECT = exports.DRAFT_SELECT = 'DRAFT_SELECT';

var motivation = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'tagging';
var selectors = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
return function (dispatch, state) {
var id = (0, _v2.default)();
dispatch({ type: DRAFT_CREATE, payload: { id: id, input: input, template: template, motivation: motivation } });
dispatch({ type: DRAFT_CREATE, payload: { id: id, input: input, template: template, selectors: selectors ? selectors : input, motivation: motivation } });
dispatch(selectDraft(id));

@@ -51,3 +54,3 @@ var currentTemplate = (0, _resourceTemplateQuery.getCurrentResourceTemplate)(state());

if (form.meta && form.meta.selector) {
dispatch((0, _selectors.chooseSelector)(form.meta.selector));
dispatch((0, _selectors2.chooseSelector)(form.meta.selector));
}

@@ -66,2 +69,8 @@ }

function addSelectorToDraftField(id, selector, fieldId) {
var _selectors;
return { type: DRAFT_UPDATE_FIELD_SELECTOR, payload: { id: id, selectors: (_selectors = {}, _selectors[fieldId] = selector, _selectors) } };
}
function addSelectorToDraft(id, selector) {

@@ -68,0 +77,0 @@ return { type: DRAFT_UPDATE_SELECTOR, payload: { id: id, selector: selector } };

'use strict';
exports.__esModule = true;
exports.SELECTOR_COMMIT_TO_DRAFT = exports.SELECTOR_UPDATE = exports.SELECTOR_CHOOSE = exports.SELECTOR_SET_AVAILABLE = undefined;
exports.SELECTOR_COMMIT_TO_DRAFT_FIELD = exports.SELECTOR_COMMIT_TO_DRAFT = exports.SELECTOR_UPDATE = exports.SELECTOR_CHOOSE = exports.SELECTOR_SET_AVAILABLE = undefined;
var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
exports.setAvailableSelectors = setAvailableSelectors;
exports.chooseSelector = chooseSelector;
exports.chooseSecondarySelector = chooseSecondarySelector;
exports.updateSelector = updateSelector;
exports.commitToCurrentDraftField = commitToCurrentDraftField;
exports.commitToCurrentDraft = commitToCurrentDraft;

@@ -12,2 +19,4 @@

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var SELECTOR_SET_AVAILABLE = exports.SELECTOR_SET_AVAILABLE = 'SELECTOR_SET_AVAILABLE';

@@ -17,2 +26,3 @@ var SELECTOR_CHOOSE = exports.SELECTOR_CHOOSE = 'SELECTOR_CHOOSE';

var SELECTOR_COMMIT_TO_DRAFT = exports.SELECTOR_COMMIT_TO_DRAFT = 'SELECTOR_COMMIT_TO_DRAFT';
var SELECTOR_COMMIT_TO_DRAFT_FIELD = exports.SELECTOR_COMMIT_TO_DRAFT_FIELD = 'SELECTOR_COMMIT_TO_DRAFT_FIELD';

@@ -27,2 +37,6 @@ function setAvailableSelectors(selectors) {

function chooseSecondarySelector(type, defaults) {
return { type: SELECTOR_CHOOSE, payload: { type: type, defaults: (0, _extends3.default)({}, defaults, { secondary: true }) } };
}
function updateSelector(data) {

@@ -32,2 +46,9 @@ return { type: SELECTOR_UPDATE, payload: { data: data } };

function commitToCurrentDraftField(fieldId) {
return function (dispatch, getState) {
dispatch((0, _drafts.addSelectorToDraftField)(getState().drafts.currentDraft, getState().selector.currentSelector, fieldId));
dispatch({ type: SELECTOR_COMMIT_TO_DRAFT_FIELD });
};
}
function commitToCurrentDraft() {

@@ -34,0 +55,0 @@ return function (dispatch, getState) {

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

var _selectorQuery = require('./query/selectorQuery');
exports.default = (0, _reactRedux.connect)(function (state) {

@@ -31,2 +33,5 @@ var annotationList = (0, _elucidateQuery.richAnnotationList)(state);

state: state,
isSelecting: (0, _selectorQuery.isSelecting)(state),
isSelectingPrimary: (0, _selectorQuery.isSelecting)(state) && (0, _selectorQuery.currentSelectorIsSecondary)(state) === false,
isSelectingSecondary: (0, _selectorQuery.isSelecting)(state) && (0, _selectorQuery.currentSelectorIsSecondary)(state) === true,
currentSelector: state.selector && state.selector.currentSelector ? state.selector.currentSelector : null,

@@ -33,0 +38,0 @@ currentDraft: (0, _draftQuery.getCurrentDraft)(state),

@@ -24,4 +24,17 @@ 'use strict';

function draftModel(draft) {
return {
id: draft.id,
input: draft.input || {},
selectors: draft.selectors || {},
template: draft.template,
motivation: draft.motivation,
isPublishing: draft.isPublishing || false,
isPreviewing: draft.isPreviewing || false,
selector: draft.selector || null
};
}
function draftReducer() {
var _list, _list2, _list3, _list4, _list5, _list6;
var _list, _list2, _list3, _list4, _list5, _list6, _list7;

@@ -35,28 +48,27 @@ var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultState;

list: (_list = {}, _list[action.payload.id] = {
$set: {
id: action.payload.id,
input: action.payload.input,
template: action.payload.template,
motivation: action.payload.motivation,
isPublishing: false,
isPreviewing: false,
selector: null
}
$set: draftModel(action.payload)
}, _list)
});
case _drafts.DRAFT_UPDATE_INPUT:
case _drafts.DRAFT_UPDATE_FIELD_SELECTOR:
return (0, _immutabilityHelper2.default)(state, {
list: (_list2 = {}, _list2[action.payload.id] = {
input: { $merge: action.payload.fields }
selectors: { $merge: action.payload.selectors }
}, _list2)
});
case _drafts.DRAFT_UPDATE_SELECTOR:
case _drafts.DRAFT_UPDATE_INPUT:
return (0, _immutabilityHelper2.default)(state, {
list: (_list3 = {}, _list3[action.payload.id] = {
selector: { $set: action.payload.selector ? action.payload.selector : state.list[action.payload.id].selector }
input: { $merge: action.payload.fields }
}, _list3)
});
case _drafts.DRAFT_UPDATE_SELECTOR:
return (0, _immutabilityHelper2.default)(state, {
list: (_list4 = {}, _list4[action.payload.id] = {
selector: { $set: action.payload.selector ? action.payload.selector : state.list[action.payload.id].selector }
}, _list4)
});
case _drafts.DRAFT_SELECT:

@@ -74,5 +86,5 @@ return (0, _immutabilityHelper2.default)(state, {

return (0, _immutabilityHelper2.default)(state, {
list: (_list4 = {}, _list4[action.payload.id] = {
list: (_list5 = {}, _list5[action.payload.id] = {
isPublishing: { $set: true }
}, _list4)
}, _list5)
});

@@ -82,5 +94,5 @@

return (0, _immutabilityHelper2.default)(state, {
list: (_list5 = {}, _list5[action.payload.id] = {
list: (_list6 = {}, _list6[action.payload.id] = {
isPreviewing: { $set: true }
}, _list5)
}, _list6)
});

@@ -90,5 +102,5 @@

return (0, _immutabilityHelper2.default)(state, {
list: (_list6 = {}, _list6[action.payload.id] = {
list: (_list7 = {}, _list7[action.payload.id] = {
isPreviewing: { $set: false }
}, _list6)
}, _list7)
});

@@ -95,0 +107,0 @@

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

case _selectors.SELECTOR_COMMIT_TO_DRAFT:
case _selectors.SELECTOR_COMMIT_TO_DRAFT_FIELD:
return (0, _immutabilityHelper2.default)(state, {

@@ -52,0 +53,0 @@ currentSelector: { $set: {} }

{
"name": "digirati-annotation-redux",
"version": "0.2.20",
"version": "0.3.0-alpha.902c3bec",
"description": "Describe annotation-redux here",

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

# Annotation Redux
Annotation redux covers NLW-124 and is responsible for creating the redux store, actions and reducers.
Annotation redux is made of actions, queries and a few interfaces for plugging your own redux flows (middleware, reducers)
## Overview
- Actions (dispatch-able)
- annotations
- `addAnnotation`
- drafts
- `createDraft`
- `deselectDraft`
- `updateDraft`
- `addSelectorToDraft`
- `selectDraft`
- `previewDraft`
- `unpreviewDraft`
- `asyncPublishDraft`
- `publishDraft`
- elucidate
- `initialiseElucidate`
- `setServer`
- `setResource`
- `createCollection`
- `setCollection`
- `addElucidateAnnotation`
- `sendAnnotation`
- logging
- `log`
- manifest
- `requestManifest`
- `selectCanvas`
- `selectManifest`
- `addManifest`
- `removeManifest`
- resourceTemplate
- `moveForward`
- `moveBack`
- `reset`
- `addResourceTemplate`
- `addCaptureModel`
- `addInteractiveResource`
- selectors
- `setAvailableSelectors`
- `chooseSelector`
- `updateSelector`
- `commitToCurrentDraft`
- viewer
- `setViewer`
- `withViewer`
- lib/elucidate (not dispatch-able)
- `AnnotationSelector` (class)
- `makeRequest`
- `get`
- `post`
- `getAnnotation`
- `getAllAnnotationsFromCollection`
- `fetchPageCollection`
- `createElucidateCollection`
- `sendAnnotationToServer`
- query
- draftQuery
- `getCurrentDraftId`
- `getDraftById`
- `getCurrentDraft`
- elucidateQuery
- `getServer`
- `getAnnotationById`
- `isSendingAnnotations`
- `getCanvasFromManifest`
- `getCollectionId`
- `richAnnotationList` (will be renamed `annotationList`)
- `annotationList`
- manifestQuery
- `currentManifest`
- `getImageServiceFromCanvas`
- `currentImageService`
- `currentCanvas`
- `manifestById`
- `allManifests
- resourceTemplateQuery
- `getCurrentResourceTemplate`
- `getForm`
- `resourceTemplateList`
- `getCurrentPath`
- `connector`
- `createStore`
- middleware
- `logger`
- `viewerAware`
- `thunk`
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