citation-js 0.5.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/citation.js CHANGED
@@ -2854,19 +2854,11 @@ var TypeParser = function () {
2854
2854
  var constraints = [].concat(this.data.propertyConstraint || []);
2855
2855
  return constraints.map(function (_ref) {
2856
2856
  var props = _ref.props,
2857
- _ref$match = _ref.match,
2858
- match = _ref$match === void 0 ? 'every' : _ref$match,
2857
+ match = _ref.match,
2859
2858
  value = _ref.value;
2860
2859
  props = [].concat(props);
2861
2860
 
2862
2861
  switch (match) {
2863
- case 'every':
2864
- return function (input) {
2865
- return props.every(function (prop) {
2866
- return prop in input && (!value || value(input[prop]));
2867
- });
2868
- };
2869
-
2870
2862
  case 'any':
2871
2863
  case 'some':
2872
2864
  return function (input) {
@@ -2881,6 +2873,14 @@ var TypeParser = function () {
2881
2873
  return prop in input && (!value || value(input[prop]));
2882
2874
  });
2883
2875
  };
2876
+
2877
+ case 'every':
2878
+ default:
2879
+ return function (input) {
2880
+ return props.every(function (prop) {
2881
+ return prop in input && (!value || value(input[prop]));
2882
+ });
2883
+ };
2884
2884
  }
2885
2885
  });
2886
2886
  }
@@ -4204,7 +4204,7 @@ Translator.CONVERT_TO_TARGET = Symbol('convert to target');
4204
4204
  },{}],43:[function(require,module,exports){
4205
4205
  module.exports={
4206
4206
  "name": "@citation-js/core",
4207
- "version": "0.5.1",
4207
+ "version": "0.5.2",
4208
4208
  "description": "Convert different bibliographic metadata sources",
4209
4209
  "keywords": [
4210
4210
  "citation-js",
@@ -4243,7 +4243,7 @@ module.exports={
4243
4243
  "devDependencies": {
4244
4244
  "@babel/plugin-proposal-class-properties": "^7.12.1"
4245
4245
  },
4246
- "gitHead": "3f3eee0813c7d578a454c34e402fa342d0693cfa"
4246
+ "gitHead": "a902e8781abc685e8f99dbb9c5d35424bb02065c"
4247
4247
  }
4248
4248
 
4249
4249
  },{}],44:[function(require,module,exports){
@@ -7332,7 +7332,7 @@ var _default = new _core.util.Translator([].concat(aliases, nonSpec, [{
7332
7332
  target: 'issued',
7333
7333
  convert: _shared.Converters.DATE
7334
7334
  }, {
7335
- source: ['year', 'month'],
7335
+ source: ['year', 'month', 'day'],
7336
7336
  target: 'issued',
7337
7337
  convert: _shared.Converters.YEAR_MONTH,
7338
7338
  when: {
@@ -7718,7 +7718,7 @@ var _default = new _core.util.Translator([{
7718
7718
  }
7719
7719
  }
7720
7720
  }, {
7721
- source: ['year', 'month'],
7721
+ source: ['year', 'month', 'day'],
7722
7722
  target: 'issued',
7723
7723
  convert: _shared.Converters.YEAR_MONTH
7724
7724
  }, {
@@ -8344,11 +8344,15 @@ var Converters = {
8344
8344
  }
8345
8345
  },
8346
8346
  YEAR_MONTH: {
8347
- toTarget: function toTarget(year, month) {
8347
+ toTarget: function toTarget(year, month, day) {
8348
8348
  if (isNaN(+year)) {
8349
8349
  return {
8350
8350
  literal: year
8351
8351
  };
8352
+ } else if (!isNaN(+day) && !isNaN(+month)) {
8353
+ return {
8354
+ 'date-parts': [[+year, +month, +day]]
8355
+ };
8352
8356
  } else {
8353
8357
  return {
8354
8358
  'date-parts': [[+year].concat(_toConsumableArray(parseMonth(month)))]
@@ -8984,6 +8988,16 @@ for (var format in _citeproc["default"].Output.Formats) {
8984
8988
  _citeproc["default"].Output.Formats[format]['@bibliography/entry'] = getWrapperProxy(original);
8985
8989
  }
8986
8990
 
8991
+ function retrieveLocale(lang) {
8992
+ var unnormalised = lang.replace('-', '_');
8993
+
8994
+ if (_locales.locales.has(lang)) {
8995
+ return _locales.locales.get(lang);
8996
+ } else if (_locales.locales.has(unnormalised)) {
8997
+ return _locales.locales.get(unnormalised);
8998
+ }
8999
+ }
9000
+
8987
9001
  var engines = {};
8988
9002
 
8989
9003
  var fetchEngine = function fetchEngine(style, lang, template, retrieveItem, retrieveLocale) {
@@ -9017,7 +9031,7 @@ var prepareEngine = function prepareEngine(data, templateName, language, format)
9017
9031
  language = _locales.locales.has(language) ? language : 'en-US';
9018
9032
  var engine = fetchEngine(templateName, language, template, function (key) {
9019
9033
  return items[key];
9020
- }, _locales.locales.get.bind(_locales.locales));
9034
+ }, retrieveLocale);
9021
9035
  engine.setOutputFormat(format);
9022
9036
  return engine;
9023
9037
  };
@@ -16055,18 +16069,18 @@ function completeResponse(entities, old) {
16055
16069
  if (!old) {
16056
16070
  var allIds = [];
16057
16071
 
16058
- for (var _id2 in entities) {
16059
- var _ids = collectAdditionalIds(entities[_id2], FETCH_ADDITIONAL);
16072
+ for (var id in entities) {
16073
+ var _ids = collectAdditionalIds(entities[id], FETCH_ADDITIONAL);
16060
16074
 
16061
16075
  var _iterator = _createForOfIteratorHelper(_ids),
16062
16076
  _step;
16063
16077
 
16064
16078
  try {
16065
16079
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
16066
- var _id3 = _step.value;
16080
+ var _id2 = _step.value;
16067
16081
 
16068
- if (!allIds.includes(_id3)) {
16069
- allIds.push(_id3);
16082
+ if (!allIds.includes(_id2)) {
16083
+ allIds.push(_id2);
16070
16084
  }
16071
16085
  }
16072
16086
  } catch (err) {
@@ -16086,8 +16100,8 @@ function completeResponse(entities, old) {
16086
16100
 
16087
16101
  try {
16088
16102
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
16089
- var id = _step2.value;
16090
- var entity = entities[id];
16103
+ var _id3 = _step2.value;
16104
+ var entity = entities[_id3];
16091
16105
 
16092
16106
  if (!entity._needed) {
16093
16107
  continue;
@@ -35728,6 +35742,12 @@ var truthyPropertyClaims = function truthyPropertyClaims(propClaims) {
35728
35742
  return aggregate.preferred || aggregate.normal || [];
35729
35743
  };
35730
35744
 
35745
+ var nonDeprecatedPropertyClaims = function nonDeprecatedPropertyClaims(propClaims) {
35746
+ return propClaims.filter(function (claim) {
35747
+ return claim.rank !== 'deprecated';
35748
+ });
35749
+ };
35750
+
35731
35751
  var aggregatePerRank = function aggregatePerRank(aggregate, claim) {
35732
35752
  var rank = claim.rank;
35733
35753
  aggregate[rank] || (aggregate[rank] = []);
@@ -35745,7 +35765,8 @@ var truthyClaims = function truthyClaims(claims) {
35745
35765
 
35746
35766
  module.exports = {
35747
35767
  truthyClaims: truthyClaims,
35748
- truthyPropertyClaims: truthyPropertyClaims
35768
+ truthyPropertyClaims: truthyPropertyClaims,
35769
+ nonDeprecatedPropertyClaims: nonDeprecatedPropertyClaims
35749
35770
  };
35750
35771
 
35751
35772
  },{}],509:[function(require,module,exports){
@@ -35827,7 +35848,8 @@ var _require2 = require('../utils/utils'),
35827
35848
  uniq = _require2.uniq;
35828
35849
 
35829
35850
  var _require3 = require('./rank'),
35830
- truthyPropertyClaims = _require3.truthyPropertyClaims;
35851
+ truthyPropertyClaims = _require3.truthyPropertyClaims,
35852
+ nonDeprecatedPropertyClaims = _require3.nonDeprecatedPropertyClaims;
35831
35853
 
35832
35854
  var simplifyClaims = function simplifyClaims(claims) {
35833
35855
  for (var _len = arguments.length, options = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
@@ -35861,9 +35883,12 @@ var simplifyPropertyClaims = function simplifyPropertyClaims(propClaims) {
35861
35883
 
35862
35884
  var _parseOptions2 = parseOptions(options),
35863
35885
  keepNonTruthy = _parseOptions2.keepNonTruthy,
35886
+ keepNonDeprecated = _parseOptions2.keepNonDeprecated,
35864
35887
  areSubSnaks = _parseOptions2.areSubSnaks;
35865
35888
 
35866
- if (!(keepNonTruthy || areSubSnaks)) {
35889
+ if (keepNonDeprecated) {
35890
+ propClaims = nonDeprecatedPropertyClaims(propClaims);
35891
+ } else if (!(keepNonTruthy || areSubSnaks)) {
35867
35892
  propClaims = truthyPropertyClaims(propClaims);
35868
35893
  }
35869
35894
 
@@ -36181,6 +36206,11 @@ module.exports = function (sitelinks) {
36181
36206
 
36182
36207
  var aggregateValues = function aggregateValues(sitelinks, addUrl) {
36183
36208
  return function (index, key) {
36209
+ if (sitelinks[key] == null) {
36210
+ index[key] = sitelinks[key];
36211
+ return index;
36212
+ }
36213
+
36184
36214
  var title = sitelinks[key].title;
36185
36215
 
36186
36216
  if (addUrl) {
@@ -36572,7 +36602,7 @@ module.exports = {
36572
36602
  },{"../utils/utils":531,"./helpers":505,"./sitelinks_languages":518}],518:[function(require,module,exports){
36573
36603
  "use strict";
36574
36604
 
36575
- module.exports = ['aa', 'ab', 'ace', 'ady', 'af', 'ak', 'als', 'alt', 'am', 'ang', 'an', 'arc', 'ar', 'ary', 'arz', 'ast', 'as', 'atj', 'avk', 'av', 'awa', 'ay', 'azb', 'az', 'ban', 'bar', 'bat_smg', 'ba', 'bcl', 'be_x_old', 'be', 'bg', 'bh', 'bi', 'bjn', 'bm', 'bn', 'bo', 'bpy', 'br', 'bs', 'bug', 'bxr', 'ca', 'cbk_zam', 'cdo', 'ceb', 'ce', 'cho', 'chr', 'ch', 'chy', 'ckb', 'co', 'crh', 'cr', 'csb', 'cs', 'cu', 'cv', 'cy', 'da', 'de', 'din', 'diq', 'dsb', 'dty', 'dv', 'dz', 'ee', 'el', 'eml', 'en', 'eo', 'es', 'et', 'eu', 'ext', 'fa', 'ff', 'fiu_vro', 'fi', 'fj', 'fo', 'frp', 'frr', 'fr', 'fur', 'fy', 'gag', 'gan', 'ga', 'gcr', 'gd', 'glk', 'gl', 'gn', 'gom', 'gor', 'got', 'gu', 'gv', 'hak', 'ha', 'haw', 'he', 'hif', 'hi', 'ho', 'hr', 'hsb', 'ht', 'hu', 'hy', 'hyw', 'hz', 'ia', 'id', 'ie', 'ig', 'ii', 'ik', 'ilo', 'inh', 'io', 'is', 'it', 'iu', 'jam', 'ja', 'jbo', 'jv', 'kaa', 'kab', 'ka', 'kbd', 'kbp', 'kg', 'ki', 'kj', 'kk', 'kl', 'km', 'kn', 'koi', 'ko', 'krc', 'kr', 'ksh', 'ks', 'ku', 'kv', 'kw', 'ky', 'lad', 'la', 'lbe', 'lb', 'lez', 'lfn', 'lg', 'lij', 'li', 'lld', 'lmo', 'ln', 'lo', 'lrc', 'ltg', 'lt', 'lv', 'mad', 'mai', 'map_bms', 'mdf', 'mg', 'mhr', 'mh', 'min', 'mi', 'mk', 'ml', 'mni', 'mn', 'mnw', 'mo', 'mrj', 'mr', 'ms', 'mt', 'mus', 'mwl', 'myv', 'my', 'mzn', 'nah', 'nap', 'na', 'nds_nl', 'nds', 'ne', 'new', 'ng', 'nia', 'nl', 'nn', 'nov', 'no', 'nqo', 'nrm', 'nso', 'nv', 'ny', 'oc', 'olo', 'om', 'or', 'os', 'pag', 'pam', 'pap', 'pa', 'pcd', 'pdc', 'pfl', 'pih', 'pi', 'pl', 'pms', 'pnb', 'pnt', 'ps', 'pt', 'qu', 'rm', 'rmy', 'rn', 'roa_rup', 'roa_tara', 'ro', 'rue', 'ru', 'rw', 'sah', 'sat', 'sa', 'scn', 'sco', 'sc', 'sd', 'se', 'sg', 'shn', 'sh', 'shy', 'simple', 'si', 'skr', 'sk', 'sl', 'smn', 'sm', 'sn', 'sources', 'so', 'sq', 'srn', 'sr', 'ss', 'stq', 'st', 'su', 'sv', 'sw', 'szl', 'szy', 'ta', 'tay', 'tcy', 'tet', 'te', 'tg', 'th', 'ti', 'tk', 'tl', 'tn', 'to', 'tpi', 'trv', 'tr', 'ts', 'tt', 'tum', 'tw', 'tyv', 'ty', 'udm', 'ug', 'uk', 'ur', 'uz', 'vec', 'vep', 've', 'vi', 'vls', 'vo', 'war', 'wa', 'wo', 'wuu', 'xal', 'xh', 'xmf', 'yi', 'yo', 'yue', 'za', 'zea', 'zh_classical', 'zh_min_nan', 'zh_yue', 'zh', 'zu'];
36605
+ module.exports = ['aa', 'ab', 'ace', 'ady', 'af', 'ak', 'als', 'alt', 'am', 'ang', 'an', 'arc', 'ar', 'ary', 'arz', 'ast', 'as', 'atj', 'avk', 'av', 'awa', 'ay', 'azb', 'az', 'ban', 'bar', 'bat_smg', 'ba', 'bcl', 'be_x_old', 'be', 'bg', 'bh', 'bi', 'bjn', 'bm', 'bn', 'bo', 'bpy', 'br', 'bs', 'bug', 'bxr', 'ca', 'cbk_zam', 'cdo', 'ceb', 'ce', 'cho', 'chr', 'ch', 'chy', 'ckb', 'co', 'crh', 'cr', 'csb', 'cs', 'cu', 'cv', 'cy', 'dag', 'da', 'de', 'din', 'diq', 'dsb', 'dty', 'dv', 'dz', 'ee', 'el', 'eml', 'en', 'eo', 'es', 'et', 'eu', 'ext', 'fa', 'ff', 'fiu_vro', 'fi', 'fj', 'fo', 'frp', 'frr', 'fr', 'fur', 'fy', 'gag', 'gan', 'ga', 'gcr', 'gd', 'glk', 'gl', 'gn', 'gom', 'gor', 'got', 'gu', 'gv', 'hak', 'ha', 'haw', 'he', 'hif', 'hi', 'ho', 'hr', 'hsb', 'ht', 'hu', 'hy', 'hyw', 'hz', 'ia', 'id', 'ie', 'ig', 'ii', 'ik', 'ilo', 'inh', 'io', 'is', 'it', 'iu', 'jam', 'ja', 'jbo', 'jv', 'kaa', 'kab', 'ka', 'kbd', 'kbp', 'kg', 'ki', 'kj', 'kk', 'kl', 'km', 'kn', 'koi', 'ko', 'krc', 'kr', 'ksh', 'ks', 'ku', 'kv', 'kw', 'ky', 'lad', 'la', 'lbe', 'lb', 'lez', 'lfn', 'lg', 'lij', 'li', 'lld', 'lmo', 'ln', 'lo', 'lrc', 'ltg', 'lt', 'lv', 'mad', 'mai', 'map_bms', 'mdf', 'mg', 'mhr', 'mh', 'min', 'mi', 'mk', 'ml', 'mni', 'mn', 'mnw', 'mo', 'mrj', 'mr', 'ms', 'mt', 'mus', 'mwl', 'myv', 'my', 'mzn', 'nah', 'nap', 'na', 'nds_nl', 'nds', 'ne', 'new', 'ng', 'nia', 'nl', 'nn', 'nov', 'no', 'nqo', 'nrm', 'nso', 'nv', 'ny', 'oc', 'olo', 'om', 'or', 'os', 'pag', 'pam', 'pap', 'pa', 'pcd', 'pdc', 'pfl', 'pih', 'pi', 'pl', 'pms', 'pnb', 'pnt', 'ps', 'pt', 'qu', 'rm', 'rmy', 'rn', 'roa_rup', 'roa_tara', 'ro', 'rue', 'ru', 'rw', 'sah', 'sat', 'sa', 'scn', 'sco', 'sc', 'sd', 'se', 'sg', 'shi', 'shn', 'sh', 'shy', 'simple', 'si', 'skr', 'sk', 'sl', 'smn', 'sm', 'sn', 'sources', 'so', 'sq', 'srn', 'sr', 'ss', 'stq', 'st', 'su', 'sv', 'sw', 'szl', 'szy', 'ta', 'tay', 'tcy', 'tet', 'te', 'tg', 'th', 'ti', 'tk', 'tl', 'tn', 'to', 'tpi', 'trv', 'tr', 'ts', 'tt', 'tum', 'tw', 'tyv', 'ty', 'udm', 'ug', 'uk', 'ur', 'uz', 'vec', 'vep', 've', 'vi', 'vls', 'vo', 'war', 'wa', 'wo', 'wuu', 'xal', 'xh', 'xmf', 'yi', 'yo', 'yue', 'za', 'zea', 'zh_classical', 'zh_min_nan', 'zh_yue', 'zh', 'zu'];
36576
36606
 
36577
36607
  },{}],519:[function(require,module,exports){
36578
36608
  "use strict";
@@ -36842,7 +36872,7 @@ var validate = require('../helpers/validate');
36842
36872
  var _require = require('../utils/utils'),
36843
36873
  isPlainObject = _require.isPlainObject;
36844
36874
 
36845
- module.exports = function (instance) {
36875
+ module.exports = function (instance, wgScriptPath) {
36846
36876
  return function (id, revision) {
36847
36877
  if (isPlainObject(id)) {
36848
36878
  revision = id.revision;
@@ -36851,7 +36881,7 @@ module.exports = function (instance) {
36851
36881
 
36852
36882
  validate.entityId(id);
36853
36883
  validate.revisionId(revision);
36854
- return "".concat(instance, "/w/index.php?title=Special:EntityData/").concat(id, ".json&revision=").concat(revision);
36884
+ return "".concat(instance, "/").concat(wgScriptPath, "/index.php?title=Special:EntityData/").concat(id, ".json&revision=").concat(revision);
36855
36885
  };
36856
36886
  };
36857
36887
 
@@ -37140,6 +37170,9 @@ var WBK = function WBK(config) {
37140
37170
  if (!isPlainObject(config)) throw new Error('invalid config');
37141
37171
  var instance = config.instance,
37142
37172
  sparqlEndpoint = config.sparqlEndpoint;
37173
+ var _config$wgScriptPath = config.wgScriptPath,
37174
+ wgScriptPath = _config$wgScriptPath === void 0 ? 'w' : _config$wgScriptPath;
37175
+ wgScriptPath = wgScriptPath.replace(/^\//, '');
37143
37176
 
37144
37177
  if (!(instance || sparqlEndpoint)) {
37145
37178
  throw new Error("one of instance or sparqlEndpoint should be set at initialization.\n".concat(tip));
@@ -37149,8 +37182,8 @@ var WBK = function WBK(config) {
37149
37182
 
37150
37183
  if (instance) {
37151
37184
  validateEndpoint('instance', instance);
37152
- instanceRoot = instance.replace(/\/$/, '').replace('/w/api.php', '');
37153
- instanceApiEndpoint = "".concat(instanceRoot, "/w/api.php");
37185
+ instanceRoot = instance.replace(/\/$/, '').replace("/".concat(wgScriptPath, "/api.php"), '');
37186
+ instanceApiEndpoint = "".concat(instanceRoot, "/").concat(wgScriptPath, "/api.php");
37154
37187
 
37155
37188
  var buildUrl = require('./utils/build_url')(instanceApiEndpoint);
37156
37189
 
@@ -37160,7 +37193,7 @@ var WBK = function WBK(config) {
37160
37193
  getEntities: require('./queries/get_entities')(buildUrl),
37161
37194
  getManyEntities: require('./queries/get_many_entities')(buildUrl),
37162
37195
  getRevisions: require('./queries/get_revisions')(buildUrl),
37163
- getEntityRevision: require('./queries/get_entity_revision')(instance),
37196
+ getEntityRevision: require('./queries/get_entity_revision')(instance, wgScriptPath),
37164
37197
  getEntitiesFromSitelinks: require('./queries/get_entities_from_sitelinks')(buildUrl)
37165
37198
  };
37166
37199
  } else {