@annotation-studio/plugin-core
Advanced tools
Comparing version 1.0.0-pr.b779cdbf to 1.0.0-pr.c2a24007
@@ -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-pr.b779cdbf", | ||
"version": "1.0.0-pr.c2a24007", | ||
"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,14 +20,15 @@ "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.b779cdbf", | ||
"@annotation-studio/redux": "^1.0.0-pr.b779cdbf" | ||
}, | ||
"peerDependencies": { | ||
"react": "*", | ||
"react-dom": "*", | ||
"@annotation-studio/bridge": "^1.0.0-rc.14", | ||
"@annotation-studio/redux": "^1.0.0-rc.14", | ||
"moment": "*", | ||
"react": "^15.6.2", | ||
"react-dom": "^15.6.2", | ||
"react-redux": "*" | ||
}, | ||
"devDependencies": { | ||
"@annotation-studio/bridge": "^1.0.0-pr.c2a24007", | ||
"@annotation-studio/redux": "^1.0.0-pr.c2a24007", | ||
"babel-cli": "^6.24.1", | ||
@@ -39,5 +40,7 @@ "babel-plugin-transform-flow-strip-types": "^6.22.0", | ||
"extract-text-webpack-plugin": "^2.1.0", | ||
"moment": "^2.20.1", | ||
"nwb": "^0.21.5", | ||
"react": "*", | ||
"react-dom": "*", | ||
"nwb-watch": "^1.0.0-pr.c2a24007", | ||
"react": "^15.6.2", | ||
"react-dom": "^15.6.2", | ||
"react-redux": "*" | ||
@@ -44,0 +47,0 @@ }, |
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
36100
754
6
14
13
8
+ Addedasap@2.0.6(transitive)
+ Addedcore-js@1.2.7(transitive)
+ Addedcreate-react-class@15.7.0(transitive)
+ Addedencoding@0.1.13(transitive)
+ Addedfbjs@0.8.18(transitive)
+ Addediconv-lite@0.6.3(transitive)
+ Addedis-stream@1.1.0(transitive)
+ Addedisomorphic-fetch@2.2.1(transitive)
+ Addedmoment@2.30.1(transitive)
+ Addednode-fetch@1.7.3(transitive)
+ Addedpromise@7.3.1(transitive)
+ Addedreact@15.7.0(transitive)
+ Addedreact-dom@15.7.0(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsetimmediate@1.0.5(transitive)
+ Addedua-parser-js@0.7.40(transitive)
- Removedreact@16.14.0(transitive)
- Removedreact-dom@19.0.0(transitive)
- Removedscheduler@0.25.0(transitive)