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

@future-scholars/paperlib-citation-count-extension

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@future-scholars/paperlib-citation-count-extension - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

2

dist/main.js

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

"use strict";var m=Object.defineProperty;var b=(i,e,t)=>e in i?m(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var l=(i,e)=>m(i,"name",{value:e,configurable:!0});var u=(i,e,t)=>(b(i,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("fs");require("path");const g=class g{constructor({id:e,defaultPreference:t}){u(this,"id");u(this,"defaultPreference");this.id=e,this.checkPreference(t),this.defaultPreference=t}checkPreference(e){if(typeof e!="object")throw new Error("Preference must be a dict");for(const t in e){if(!e[t].type||!["string","boolean","options","pathpicker"].includes(e[t].type))throw new Error(`Preference ${t} has wrong type ${e[t].type}`);if(!e[t].name)throw new Error(`Preference ${t} has no name`);if(!e[t].description)throw new Error(`Preference ${t} has no description`);if(e[t].value===void 0||e[t].value===null)throw new Error(`Preference ${t} has no default value`);if(e[t].type==="options"&&!e[t].options)throw new Error(`Preference ${t} has no options`)}}};l(g,"PLExtension");let h=g;const v=l(({str:i,removeNewline:e=!1,removeWhite:t=!1,removeSymbol:a=!1,removeStr:n=null,lowercased:o=!1,trimWhite:s=!1,whiteSymbol:c=!1})=>{if(!i)return"";let r=i;return r?(n&&(r=r.replaceAll(n,"")),e&&(r=r.replace(/(\r\n|\n|\r)/gm,"")),s&&(r=r.trim()),t&&(r=r.replace(/\s/g,"")),a&&(r=r.replace(/[^\p{L}|\s]/gu,"")),o&&(r=r.toLowerCase()),c&&(r=r.replace(/[^\p{L}]/gu," ")),r):""},"formatString"),f={formatString:v};function S(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}l(S,"getDefaultExportFromCjs");var y={compareTwoStrings:C,findBestMatch:A};function C(i,e){if(i=i.replace(/\s+/g,""),e=e.replace(/\s+/g,""),i===e)return 1;if(i.length<2||e.length<2)return 0;let t=new Map;for(let n=0;n<i.length-1;n++){const o=i.substring(n,n+2),s=t.has(o)?t.get(o)+1:1;t.set(o,s)}let a=0;for(let n=0;n<e.length-1;n++){const o=e.substring(n,n+2),s=t.has(o)?t.get(o):0;s>0&&(t.set(o,s-1),a++)}return 2*a/(i.length+e.length-2)}l(C,"compareTwoStrings");function A(i,e){if(!$(i,e))throw new Error("Bad arguments: First argument should be a string, second should be an array of strings");const t=[];let a=0;for(let o=0;o<e.length;o++){const s=e[o],c=C(i,s);t.push({target:s,rating:c}),c>t[a].rating&&(a=o)}const n=t[a];return{ratings:t,bestMatch:n,bestMatchIndex:a}}l(A,"findBestMatch");function $(i,e){return!(typeof i!="string"||!Array.isArray(e)||!e.length||e.find(function(t){return typeof t!="string"}))}l($,"areArgsValid");const k=S(y),d=class d extends h{constructor(){super({id:"@future-scholars/paperlib-citation-count-extension",defaultPreference:{}});u(this,"disposeCallbacks");this.disposeCallbacks=[]}async initialize(){await PLExtAPI.extensionPreferenceService.register(this.id,this.defaultPreference),this.disposeCallbacks.push(PLAPI.uiStateService.onChanged("selectedPaperEntities",t=>{t.value.length===1&&this.getCitationCount(t.value[0])}))}async dispose(){for(const t of this.disposeCallbacks)t();PLExtAPI.extensionPreferenceService.unregister(this.id)}async getCitationCount(t){await PLAPI.uiSlotService.updateSlot("paperDetailsPanelSlot1",{"paperlib-citation-count":{title:"Citation Count",content:"N/A (N/A)"}});let a;t.doi!==""?a=`https://api.semanticscholar.org/graph/v1/paper/${t.doi}?fields=title,citationCount,influentialCitationCount`:t.arxiv!==""?a=`https://api.semanticscholar.org/graph/v1/paper/arXiv:${t.arxiv.toLowerCase().replace("arxiv:","").split("v")[0]}?fields=title,citationCount,influentialCitationCount`:a=`https://api.semanticscholar.org/graph/v1/paper/search?query=${f.formatString({str:t.title,whiteSymbol:!0})}&limit=10&fields=title,citationCount,influentialCitationCount`;try{const o=(await PLExtAPI.networkTool.get(a,{},1,5e3,!0,!0)).body,s={semanticscholarId:"",citationCount:"N/A",influentialCitationCount:"N/A"};let c;o.data?c=o.data:c=[o];for(const r of c){const w=f.formatString({str:r.title,removeStr:"&amp;",removeSymbol:!0,lowercased:!0}),P=f.formatString({str:t.title,removeStr:"&amp;",removeSymbol:!0,lowercased:!0});if(k.compareTwoStrings(w,P)>.95){s.citationCount=`${r.citationCount}`,s.influentialCitationCount=`${r.influentialCitationCount}`;break}}PLAPI.uiSlotService.updateSlot("paperDetailsPanelSlot1",{"paperlib-citation-count":{title:"Citation Count",content:`${s.citationCount} (${s.influentialCitationCount})`}})}catch(n){if(n.message==="Response code 404 (Not Found)")return;PLAPI.logService.error("Failed to get citation count.",n,!1,"CitationCountExt")}}};l(d,"PaperlibCitationCountExtension");let p=d;async function L(){const i=new p;return await i.initialize(),i}l(L,"initialize");exports.initialize=L;
"use strict";var m=Object.defineProperty;var P=(i,e,t)=>e in i?m(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var l=(i,e)=>m(i,"name",{value:e,configurable:!0});var u=(i,e,t)=>(P(i,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("fs");require("path");const g=class g{constructor({id:e,defaultPreference:t}){u(this,"id");u(this,"defaultPreference");this.id=e,this.checkPreference(t),this.defaultPreference=t}checkPreference(e){if(typeof e!="object")throw new Error("Preference must be a dict");for(const t in e){if(!e[t].type||!["string","boolean","options","pathpicker"].includes(e[t].type))throw new Error(`Preference ${t} has wrong type ${e[t].type}`);if(!e[t].name)throw new Error(`Preference ${t} has no name`);if(!e[t].description)throw new Error(`Preference ${t} has no description`);if(e[t].value===void 0||e[t].value===null)throw new Error(`Preference ${t} has no default value`);if(e[t].type==="options"&&!e[t].options)throw new Error(`Preference ${t} has no options`)}}};l(g,"PLExtension");let p=g;const S=l(({str:i,removeNewline:e=!1,removeWhite:t=!1,removeSymbol:a=!1,removeStr:n=null,lowercased:o=!1,trimWhite:s=!1,whiteSymbol:c=!1})=>{if(!i)return"";let r=i;return r?(n&&(r=r.replaceAll(n,"")),e&&(r=r.replace(/(\r\n|\n|\r)/gm,"")),s&&(r=r.trim()),t&&(r=r.replace(/\s/g,"")),a&&(r=r.replace(/[^\p{L}|\s]/gu,"")),o&&(r=r.toLowerCase()),c&&(r=r.replace(/[^\p{L}]/gu," ")),r):""},"formatString"),f={formatString:S};function v(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}l(v,"getDefaultExportFromCjs");var y={compareTwoStrings:w,findBestMatch:A};function w(i,e){if(i=i.replace(/\s+/g,""),e=e.replace(/\s+/g,""),i===e)return 1;if(i.length<2||e.length<2)return 0;let t=new Map;for(let n=0;n<i.length-1;n++){const o=i.substring(n,n+2),s=t.has(o)?t.get(o)+1:1;t.set(o,s)}let a=0;for(let n=0;n<e.length-1;n++){const o=e.substring(n,n+2),s=t.has(o)?t.get(o):0;s>0&&(t.set(o,s-1),a++)}return 2*a/(i.length+e.length-2)}l(w,"compareTwoStrings");function A(i,e){if(!$(i,e))throw new Error("Bad arguments: First argument should be a string, second should be an array of strings");const t=[];let a=0;for(let o=0;o<e.length;o++){const s=e[o],c=w(i,s);t.push({target:s,rating:c}),c>t[a].rating&&(a=o)}const n=t[a];return{ratings:t,bestMatch:n,bestMatchIndex:a}}l(A,"findBestMatch");function $(i,e){return!(typeof i!="string"||!Array.isArray(e)||!e.length||e.find(function(t){return typeof t!="string"}))}l($,"areArgsValid");const L=v(y),d=class d extends p{constructor(){super({id:"@future-scholars/paperlib-citation-count-extension",defaultPreference:{}});u(this,"disposeCallbacks");this.disposeCallbacks=[]}async initialize(){await PLExtAPI.extensionPreferenceService.register(this.id,this.defaultPreference),this.disposeCallbacks.push(PLAPI.uiStateService.onChanged("selectedPaperEntities",t=>{t.value.length===1&&this.getCitationCount(t.value[0])}))}async dispose(){for(const t of this.disposeCallbacks)t();PLExtAPI.extensionPreferenceService.unregister(this.id)}async getCitationCount(t){await PLAPI.uiSlotService.updateSlot("paperDetailsPanelSlot1",{"paperlib-citation-count":{title:"Citation Count",content:"N/A (N/A)"}});let a;t.doi!==""?a=`https://api.paperlib.app/metadata/citationcount?doi=${t.doi}`:t.arxiv!==""?a=`https://api.paperlib.app/metadata/citationcount?arxiv=${t.arxiv.toLowerCase().replace("arxiv:","").split("v")[0]}`:a=`https://api.paperlib.app/metadata/citationcount?title=${f.formatString({str:t.title,whiteSymbol:!0})}`;try{const o=(await PLExtAPI.networkTool.get(a,{},1,5e3,!0,!0)).body,s={semanticscholarId:"",citationCount:"N/A",influentialCitationCount:"N/A"};let c;o.data?c=o.data:c=[o];for(const r of c){const C=f.formatString({str:r.title,removeStr:"&amp;",removeSymbol:!0,lowercased:!0}),b=f.formatString({str:t.title,removeStr:"&amp;",removeSymbol:!0,lowercased:!0});if(L.compareTwoStrings(C,b)>.95){s.citationCount=`${r.citationCount}`,s.influentialCitationCount=`${r.influentialCitationCount}`;break}}PLAPI.uiSlotService.updateSlot("paperDetailsPanelSlot1",{"paperlib-citation-count":{title:"Citation Count",content:`${s.citationCount} (${s.influentialCitationCount})`}})}catch(n){if(n.message.includes("404")){PLAPI.logService.warn("Citation count not found.","",!1,"CitationCountExt");return}PLAPI.logService.error("Failed to get citation count.",n,!1,"CitationCountExt")}}};l(d,"PaperlibCitationCountExtension");let h=d;async function k(){const i=new h;return await i.initialize(),i}l(k,"initialize");exports.initialize=k;
{
"name": "@future-scholars/paperlib-citation-count-extension",
"version": "0.0.3",
"version": "0.0.4",
"author": "Paperlib",

@@ -20,3 +20,3 @@ "description": "Show the citation count in the detail panel.",

"@types/node": "16.18.1",
"paperlib-api": "^0.0.16",
"paperlib-api": "^0.1.2",
"prettier": "^3.1.1",

@@ -23,0 +23,0 @@ "prettier-plugin-organize-imports": "^3.2.4",

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