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.1 to 0.0.2

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 n=await PLAPI.networkTool.get(a,{},1,5e3,!0),o=JSON.parse(n.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 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;
{
"name": "@future-scholars/paperlib-citation-count-extension",
"version": "0.0.1",
"version": "0.0.2",
"author": "Paperlib",

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

"type": "commonjs",
"manifest_version": "1.0.0",
"manifest_version": "0.0.16",
"scripts": {

@@ -15,3 +15,3 @@ "prebuild": "tsc --noEmit",

"engines": {
"node": ">=16.17.1"
"node": ">=18.16.1"
},

@@ -21,3 +21,3 @@ "devDependencies": {

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

@@ -24,0 +24,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