@annotation-studio/plugin-core
Advanced tools
Comparing version 1.0.0-next.060662c8 to 1.0.0-next.2022bf79
@@ -38,3 +38,5 @@ var _class, _temp2; | ||
}, _this.warnUser = function (event) { | ||
var drafts = _this.props.drafts; | ||
var _this$props = _this.props, | ||
drafts = _this$props.drafts, | ||
disableCloseWarning = _this$props.disableCloseWarning; | ||
@@ -44,3 +46,11 @@ var changes = drafts ? Object.values(drafts).filter(function (draft) { | ||
}) : []; | ||
if (changes.length) { | ||
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.';; | ||
@@ -77,3 +87,5 @@ event.preventDefault(); | ||
if (canvasId) { | ||
fetch(manifest).then(function (response) { | ||
fetch(manifest, { | ||
cache: process.env.NODE_ENV === 'production' ? 'default' : 'force-cache' | ||
}).then(function (response) { | ||
return response.json(); | ||
@@ -80,0 +92,0 @@ }).then(function (response) { |
@@ -17,4 +17,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; } | ||
elucidateServer = _ref.elucidateServer, | ||
disableCloseWarning = _ref.disableCloseWarning, | ||
locale = _ref.locale, | ||
unknownProps = _objectWithoutProperties(_ref, ['manifest', 'canvas', 'elucidateServer', 'locale']); | ||
unknownProps = _objectWithoutProperties(_ref, ['manifest', 'canvas', 'elucidateServer', 'disableCloseWarning', 'locale']); | ||
@@ -27,2 +28,3 @@ unknownPropertyWarning(unknownProps); | ||
var savedDraftList = localstorage.get('annotation-studio/' + url) || {}; | ||
var disableCloseWarningBoolean = disableCloseWarning ? disableCloseWarning === 'true' : false; | ||
@@ -33,2 +35,3 @@ var store = createStore(reducers, [], locale); | ||
manifest: manifest, | ||
disableCloseWarning: disableCloseWarningBoolean, | ||
savedDraftList: savedDraftList, | ||
@@ -35,0 +38,0 @@ elucidateServer: elucidateServer, |
@@ -0,4 +1,9 @@ | ||
import _regeneratorRuntime from 'babel-runtime/regenerator'; | ||
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"); }); }; } | ||
import React from 'react'; | ||
import { render } from 'react-dom'; | ||
import { Provider } from 'react-redux'; | ||
import moment from 'moment'; | ||
@@ -16,2 +21,70 @@ export function getAttributes($el) { | ||
export var fetchResourceTemplate = function () { | ||
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(resource) { | ||
var headers, locale; | ||
return _regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
headers = new Headers(); | ||
locale = moment.locale(); | ||
if (locale && process.env.NODE_ENV === 'production') { | ||
headers.set("X-Annotation-Studio-Locale", locale); | ||
} | ||
_context.prev = 3; | ||
_context.next = 6; | ||
return fetch('' + resource, { | ||
credentials: process.env.NODE_ENV === 'production' ? 'include' : null, | ||
cache: process.env.NODE_ENV === 'production' ? 'default' : 'force-cache', | ||
headers: headers | ||
}); | ||
case 6: | ||
return _context.abrupt('return', _context.sent); | ||
case 9: | ||
_context.prev = 9; | ||
_context.t0 = _context['catch'](3); | ||
console.warn('Can\'t send credentials, not same origin. Falling back.', _context.t0); | ||
_context.prev = 12; | ||
_context.next = 15; | ||
return fetch('' + resource, { | ||
cache: process.env.NODE_ENV === 'production' ? 'default' : 'force-cache', | ||
headers: headers | ||
}); | ||
case 15: | ||
return _context.abrupt('return', _context.sent); | ||
case 18: | ||
_context.prev = 18; | ||
_context.t1 = _context['catch'](12); | ||
console.warn('Unable to send locale, likely CORS not available. falling back.', _context.t1); | ||
_context.next = 23; | ||
return fetch('' + resource, { | ||
cache: process.env.NODE_ENV === 'production' ? 'default' : 'force-cache' | ||
}); | ||
case 23: | ||
return _context.abrupt('return', _context.sent); | ||
case 24: | ||
case 'end': | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee, this, [[3, 9], [12, 18]]); | ||
})); | ||
return function fetchResourceTemplate(_x) { | ||
return _ref.apply(this, arguments); | ||
}; | ||
}(); | ||
export function deferred() { | ||
@@ -18,0 +91,0 @@ var resolve = null; |
@@ -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,3 +59,11 @@ var changes = drafts ? Object.values(drafts).filter(function (draft) { | ||
}) : []; | ||
if (changes.length) { | ||
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.';; | ||
@@ -90,3 +100,5 @@ event.preventDefault(); | ||
if (canvasId) { | ||
fetch(manifest).then(function (response) { | ||
fetch(manifest, { | ||
cache: process.env.NODE_ENV === 'production' ? 'default' : 'force-cache' | ||
}).then(function (response) { | ||
return response.json(); | ||
@@ -93,0 +105,0 @@ }).then(function (response) { |
@@ -38,4 +38,5 @@ 'use strict'; | ||
elucidateServer = _ref.elucidateServer, | ||
disableCloseWarning = _ref.disableCloseWarning, | ||
locale = _ref.locale, | ||
unknownProps = _objectWithoutProperties(_ref, ['manifest', 'canvas', 'elucidateServer', 'locale']); | ||
unknownProps = _objectWithoutProperties(_ref, ['manifest', 'canvas', 'elucidateServer', 'disableCloseWarning', 'locale']); | ||
@@ -48,2 +49,3 @@ (0, _core.unknownPropertyWarning)(unknownProps); | ||
var savedDraftList = _store2.default.get('annotation-studio/' + url) || {}; | ||
var disableCloseWarningBoolean = disableCloseWarning ? disableCloseWarning === 'true' : false; | ||
@@ -54,2 +56,3 @@ var store = (0, _redux.createStore)(_redux.reducers, [], locale); | ||
manifest: manifest, | ||
disableCloseWarning: disableCloseWarningBoolean, | ||
savedDraftList: savedDraftList, | ||
@@ -56,0 +59,0 @@ elucidateServer: elucidateServer, |
'use strict'; | ||
exports.__esModule = true; | ||
exports.fetchResourceTemplate = undefined; | ||
var _regenerator = require('babel-runtime/regenerator'); | ||
var _regenerator2 = _interopRequireDefault(_regenerator); | ||
var fetchResourceTemplate = exports.fetchResourceTemplate = function () { | ||
var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee(resource) { | ||
var headers, locale; | ||
return _regenerator2.default.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
headers = new Headers(); | ||
locale = _moment2.default.locale(); | ||
if (locale && process.env.NODE_ENV === 'production') { | ||
headers.set("X-Annotation-Studio-Locale", locale); | ||
} | ||
_context.prev = 3; | ||
_context.next = 6; | ||
return fetch('' + resource, { | ||
credentials: process.env.NODE_ENV === 'production' ? 'include' : null, | ||
cache: process.env.NODE_ENV === 'production' ? 'default' : 'force-cache', | ||
headers: headers | ||
}); | ||
case 6: | ||
return _context.abrupt('return', _context.sent); | ||
case 9: | ||
_context.prev = 9; | ||
_context.t0 = _context['catch'](3); | ||
console.warn('Can\'t send credentials, not same origin. Falling back.', _context.t0); | ||
_context.prev = 12; | ||
_context.next = 15; | ||
return fetch('' + resource, { | ||
cache: process.env.NODE_ENV === 'production' ? 'default' : 'force-cache', | ||
headers: headers | ||
}); | ||
case 15: | ||
return _context.abrupt('return', _context.sent); | ||
case 18: | ||
_context.prev = 18; | ||
_context.t1 = _context['catch'](12); | ||
console.warn('Unable to send locale, likely CORS not available. falling back.', _context.t1); | ||
_context.next = 23; | ||
return fetch('' + resource, { | ||
cache: process.env.NODE_ENV === 'production' ? 'default' : 'force-cache' | ||
}); | ||
case 23: | ||
return _context.abrupt('return', _context.sent); | ||
case 24: | ||
case 'end': | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee, this, [[3, 9], [12, 18]]); | ||
})); | ||
return function fetchResourceTemplate(_x) { | ||
return _ref.apply(this, arguments); | ||
}; | ||
}(); | ||
exports.getAttributes = getAttributes; | ||
@@ -20,4 +94,10 @@ exports.deferred = deferred; | ||
var _moment = require('moment'); | ||
var _moment2 = _interopRequireDefault(_moment); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
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"); }); }; } | ||
function getAttributes($el) { | ||
@@ -24,0 +104,0 @@ var attributes = {}; |
{ | ||
"name": "@annotation-studio/plugin-core", | ||
"version": "1.0.0-next.060662c8", | ||
"version": "1.0.0-next.2022bf79", | ||
"description": "Annotation studio core plugin", | ||
@@ -21,7 +21,6 @@ "main": "lib/index.js", | ||
}, | ||
"dependencies": { | ||
"@annotation-studio/bridge": "^1.0.0-next.060662c8", | ||
"@annotation-studio/redux": "^1.0.0-next.060662c8" | ||
}, | ||
"peerDependencies": { | ||
"@annotation-studio/bridge": "^1.0.0-rc.13", | ||
"@annotation-studio/redux": "^1.0.0-rc.13", | ||
"moment": "*", | ||
"react": "*", | ||
@@ -32,2 +31,4 @@ "react-dom": "*", | ||
"devDependencies": { | ||
"@annotation-studio/bridge": "^1.0.0-next.2022bf79", | ||
"@annotation-studio/redux": "^1.0.0-next.2022bf79", | ||
"babel-cli": "^6.24.1", | ||
@@ -39,2 +40,3 @@ "babel-plugin-transform-flow-strip-types": "^6.22.0", | ||
"extract-text-webpack-plugin": "^2.1.0", | ||
"moment": "^2.20.1", | ||
"nwb": "^0.21.5", | ||
@@ -41,0 +43,0 @@ "react": "*", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36018
754
6
13
13
8
+ Addedmoment@2.30.1(transitive)