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

@aaron-dev/torchlight-cli

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aaron-dev/torchlight-cli - npm Package Compare versions

Comparing version 0.1.1655321148 to 0.1.1655321213

7

dist/torchlight-cli.cjs.js

@@ -212,10 +212,5 @@ 'use strict';

const token = this.config('token');
if (!token) {
throw new Error('No Torchlight token configured!');
} // For huge sites, we need to send blocks in chunks so
const token = this.config('token'); // For huge sites, we need to send blocks in chunks so
// that we don't send e.g. 500 blocks in one request.
if (blocks.length > this.chunkSize) {

@@ -222,0 +217,0 @@ return this.fan(blocks);

2

dist/torchlight-cli.cjs.min.js

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("axios"),e=require("md5"),i=require("lodash.get"),o=require("lodash.chunk"),n=require("chalk");function r(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var s=r(t),h=r(e),l=r(i),a=r(o),c=r(n);let u=!1;function g(t,e){e=Array.from(e),u||console.log(t(e.shift()),...e)}var f={error:function(){g(c.default.bold.bgRed,arguments)},info:function(){g(c.default.green,arguments)},silence:function(t=!0){u=t}};let d={};function p(){}p.prototype.get=function(t,e){if(!Object.prototype.hasOwnProperty.call(d,t))return e;const i=d[t];return Date.now()/1e3>i.expires?(this.delete(t),e):i.value},p.prototype.set=function(t,e,i=10080){d[t]={expires:Date.now()/1e3+i,value:e}},p.prototype.delete=function(t){delete d[t]},p.prototype.clear=function(){d={}};const y=function(){this.initialized=!1,this.chunkSize=30,this.configuration={}};y.prototype.init=function(t,e){var i,o,n;return this.initialized||(t=t||{},null===(i=process)||void 0===i||null===(o=i.env)||void 0===o||!o.TORCHLIGHT_TOKEN||null!==(n=t)&&void 0!==n&&n.token||(t.token=process.env.TORCHLIGHT_TOKEN),this.initialized=!0,this.configuration=t,this.cache=e||new p),this},y.prototype.config=function(t,e){return l.default(this.configuration,t,e)},y.prototype.configHash=function(){return h.default(this.configuration)},y.prototype.highlight=function(t){t.map((t=>t.setResponseData(this.cache.get(t.hash(),{}))));const e=t.filter((t=>!t.highlighted));return this.request(e).then((i=>(e.forEach((t=>{const e=i.find((e=>t.id===e.id));e&&e.highlighted&&(this.cache.set(t.hash(),{highlighted:e.highlighted,classes:e.classes,styles:e.styles}),t.setResponseData(e))})),t.filter((t=>!t.highlighted)).forEach((t=>{f.error(`A block failed to highlight. The code was: \`${t.code.substring(0,20)} [...]\``),t.highlighted=t.code.split("\n").map((t=>{return`<div class="line">${e=t,String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}</div>`;var e})).join(""),t.classes="torchlight"})),t)))},y.prototype.request=function(t){if(!t.length)return Promise.resolve([]);const e=this.config("token");if(!e)throw new Error("No Torchlight token configured!");if(t.length>this.chunkSize)return this.fan(t);const i=this.config("host","https://api.torchlight.dev");return s.default.post(`${i}/highlight`,{blocks:t.map((t=>t.toRequestParams())),options:this.config("options",{})},{headers:{Authorization:`Bearer ${e}`,"X-Torchlight-Client":"Torchlight CLI"}}).then((t=>t.data.blocks))},y.prototype.fan=function(t){const e=[],i=[],o=a.default(t,this.chunkSize).map((t=>this.request(t)));return Promise.allSettled(o).then((t=>{if(t.forEach((t=>{"fulfilled"===t.status&&e.push(...t.value),"rejected"===t.status&&i.push(t.reason)})),e.length)return i.length&&f.error(`${i.length} fanned request(s) failed, but others succeeded. Error: ${i[0]}.`),e;if(i.length)throw new Error(i[0]);return[]}))};var m=new y;function v(){const t=()=>Math.floor(65536*(1+Math.random())).toString(16).substring(1);return`${t()}${t()}-${t()}-${t()}-${t()}-${t()}${t()}${t()}`.toLowerCase()}function $(t={}){t={id:v(),theme:m.config("theme","nord"),...t},this.id=t.id,this.code=t.code,this.language=t.language,this.theme=t.theme,this.highlighted=null,this.classes=null,this.styles=null}$.prototype.hash=function(){return h.default(""+this.language+this.theme+this.code+m.config("bust",0)+JSON.stringify(m.config("options")))},$.prototype.code=function(t){return this.code=t,this},$.prototype.language=function(t){return this.language=t,this},$.prototype.theme=function(t){return this.theme=t,this},$.prototype.placeholder=function(t=""){return t&&(t=`-${t}`),`__torchlight-block-[${this.id}]${t}__`},$.prototype.setResponseData=function(t){return t&&(this.highlighted=t.highlighted,this.classes=t.classes,this.styles=t.styles),this},$.prototype.toRequestParams=function(){return{id:this.id,hash:this.hash,language:this.language,theme:this.theme,code:this.code}},exports.Block=$,exports.torchlight=m;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("axios"),e=require("md5"),i=require("lodash.get"),o=require("lodash.chunk"),n=require("chalk");function s(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var r=s(t),h=s(e),l=s(i),a=s(o),u=s(n);let c=!1;function g(t,e){e=Array.from(e),c||console.log(t(e.shift()),...e)}var f={error:function(){g(u.default.bold.bgRed,arguments)},info:function(){g(u.default.green,arguments)},silence:function(t=!0){c=t}};let d={};function p(){}p.prototype.get=function(t,e){if(!Object.prototype.hasOwnProperty.call(d,t))return e;const i=d[t];return Date.now()/1e3>i.expires?(this.delete(t),e):i.value},p.prototype.set=function(t,e,i=10080){d[t]={expires:Date.now()/1e3+i,value:e}},p.prototype.delete=function(t){delete d[t]},p.prototype.clear=function(){d={}};const y=function(){this.initialized=!1,this.chunkSize=30,this.configuration={}};y.prototype.init=function(t,e){var i,o,n;return this.initialized||(t=t||{},null===(i=process)||void 0===i||null===(o=i.env)||void 0===o||!o.TORCHLIGHT_TOKEN||null!==(n=t)&&void 0!==n&&n.token||(t.token=process.env.TORCHLIGHT_TOKEN),this.initialized=!0,this.configuration=t,this.cache=e||new p),this},y.prototype.config=function(t,e){return l.default(this.configuration,t,e)},y.prototype.configHash=function(){return h.default(this.configuration)},y.prototype.highlight=function(t){t.map((t=>t.setResponseData(this.cache.get(t.hash(),{}))));const e=t.filter((t=>!t.highlighted));return this.request(e).then((i=>(e.forEach((t=>{const e=i.find((e=>t.id===e.id));e&&e.highlighted&&(this.cache.set(t.hash(),{highlighted:e.highlighted,classes:e.classes,styles:e.styles}),t.setResponseData(e))})),t.filter((t=>!t.highlighted)).forEach((t=>{f.error(`A block failed to highlight. The code was: \`${t.code.substring(0,20)} [...]\``),t.highlighted=t.code.split("\n").map((t=>{return`<div class="line">${e=t,String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}</div>`;var e})).join(""),t.classes="torchlight"})),t)))},y.prototype.request=function(t){if(!t.length)return Promise.resolve([]);const e=this.config("token");if(t.length>this.chunkSize)return this.fan(t);const i=this.config("host","https://api.torchlight.dev");return r.default.post(`${i}/highlight`,{blocks:t.map((t=>t.toRequestParams())),options:this.config("options",{})},{headers:{Authorization:`Bearer ${e}`,"X-Torchlight-Client":"Torchlight CLI"}}).then((t=>t.data.blocks))},y.prototype.fan=function(t){const e=[],i=[],o=a.default(t,this.chunkSize).map((t=>this.request(t)));return Promise.allSettled(o).then((t=>{if(t.forEach((t=>{"fulfilled"===t.status&&e.push(...t.value),"rejected"===t.status&&i.push(t.reason)})),e.length)return i.length&&f.error(`${i.length} fanned request(s) failed, but others succeeded. Error: ${i[0]}.`),e;if(i.length)throw new Error(i[0]);return[]}))};var m=new y;function v(){const t=()=>Math.floor(65536*(1+Math.random())).toString(16).substring(1);return`${t()}${t()}-${t()}-${t()}-${t()}-${t()}${t()}${t()}`.toLowerCase()}function $(t={}){t={id:v(),theme:m.config("theme","nord"),...t},this.id=t.id,this.code=t.code,this.language=t.language,this.theme=t.theme,this.highlighted=null,this.classes=null,this.styles=null}$.prototype.hash=function(){return h.default(""+this.language+this.theme+this.code+m.config("bust",0)+JSON.stringify(m.config("options")))},$.prototype.code=function(t){return this.code=t,this},$.prototype.language=function(t){return this.language=t,this},$.prototype.theme=function(t){return this.theme=t,this},$.prototype.placeholder=function(t=""){return t&&(t=`-${t}`),`__torchlight-block-[${this.id}]${t}__`},$.prototype.setResponseData=function(t){return t&&(this.highlighted=t.highlighted,this.classes=t.classes,this.styles=t.styles),this},$.prototype.toRequestParams=function(){return{id:this.id,hash:this.hash,language:this.language,theme:this.theme,code:this.code}},exports.Block=$,exports.torchlight=m;
//# sourceMappingURL=torchlight-cli.cjs.min.js.map

@@ -200,10 +200,5 @@ import axios from 'axios';

const token = this.config('token');
if (!token) {
throw new Error('No Torchlight token configured!');
} // For huge sites, we need to send blocks in chunks so
const token = this.config('token'); // For huge sites, we need to send blocks in chunks so
// that we don't send e.g. 500 blocks in one request.
if (blocks.length > this.chunkSize) {

@@ -210,0 +205,0 @@ return this.fan(blocks);

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

import t from"axios";import e from"md5";import i from"lodash.get";import o from"lodash.chunk";import n from"chalk";let s=!1;function h(t,e){e=Array.from(e),s||console.log(t(e.shift()),...e)}var r={error:function(){h(n.bold.bgRed,arguments)},info:function(){h(n.green,arguments)},silence:function(t=!0){s=t}};let c={};function l(){}l.prototype.get=function(t,e){if(!Object.prototype.hasOwnProperty.call(c,t))return e;const i=c[t];return Date.now()/1e3>i.expires?(this.delete(t),e):i.value},l.prototype.set=function(t,e,i=10080){c[t]={expires:Date.now()/1e3+i,value:e}},l.prototype.delete=function(t){delete c[t]},l.prototype.clear=function(){c={}};const a=function(){this.initialized=!1,this.chunkSize=30,this.configuration={}};a.prototype.init=function(t,e){var i,o,n;return this.initialized||(t=t||{},null===(i=process)||void 0===i||null===(o=i.env)||void 0===o||!o.TORCHLIGHT_TOKEN||null!==(n=t)&&void 0!==n&&n.token||(t.token=process.env.TORCHLIGHT_TOKEN),this.initialized=!0,this.configuration=t,this.cache=e||new l),this},a.prototype.config=function(t,e){return i(this.configuration,t,e)},a.prototype.configHash=function(){return e(this.configuration)},a.prototype.highlight=function(t){t.map((t=>t.setResponseData(this.cache.get(t.hash(),{}))));const e=t.filter((t=>!t.highlighted));return this.request(e).then((i=>(e.forEach((t=>{const e=i.find((e=>t.id===e.id));e&&e.highlighted&&(this.cache.set(t.hash(),{highlighted:e.highlighted,classes:e.classes,styles:e.styles}),t.setResponseData(e))})),t.filter((t=>!t.highlighted)).forEach((t=>{r.error(`A block failed to highlight. The code was: \`${t.code.substring(0,20)} [...]\``),t.highlighted=t.code.split("\n").map((t=>{return`<div class="line">${e=t,String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}</div>`;var e})).join(""),t.classes="torchlight"})),t)))},a.prototype.request=function(e){if(!e.length)return Promise.resolve([]);const i=this.config("token");if(!i)throw new Error("No Torchlight token configured!");if(e.length>this.chunkSize)return this.fan(e);const o=this.config("host","https://api.torchlight.dev");return t.post(`${o}/highlight`,{blocks:e.map((t=>t.toRequestParams())),options:this.config("options",{})},{headers:{Authorization:`Bearer ${i}`,"X-Torchlight-Client":"Torchlight CLI"}}).then((t=>t.data.blocks))},a.prototype.fan=function(t){const e=[],i=[],n=o(t,this.chunkSize).map((t=>this.request(t)));return Promise.allSettled(n).then((t=>{if(t.forEach((t=>{"fulfilled"===t.status&&e.push(...t.value),"rejected"===t.status&&i.push(t.reason)})),e.length)return i.length&&r.error(`${i.length} fanned request(s) failed, but others succeeded. Error: ${i[0]}.`),e;if(i.length)throw new Error(i[0]);return[]}))};var u=new a;function g(){const t=()=>Math.floor(65536*(1+Math.random())).toString(16).substring(1);return`${t()}${t()}-${t()}-${t()}-${t()}-${t()}${t()}${t()}`.toLowerCase()}function p(t={}){t={id:g(),theme:u.config("theme","nord"),...t},this.id=t.id,this.code=t.code,this.language=t.language,this.theme=t.theme,this.highlighted=null,this.classes=null,this.styles=null}p.prototype.hash=function(){return e(""+this.language+this.theme+this.code+u.config("bust",0)+JSON.stringify(u.config("options")))},p.prototype.code=function(t){return this.code=t,this},p.prototype.language=function(t){return this.language=t,this},p.prototype.theme=function(t){return this.theme=t,this},p.prototype.placeholder=function(t=""){return t&&(t=`-${t}`),`__torchlight-block-[${this.id}]${t}__`},p.prototype.setResponseData=function(t){return t&&(this.highlighted=t.highlighted,this.classes=t.classes,this.styles=t.styles),this},p.prototype.toRequestParams=function(){return{id:this.id,hash:this.hash,language:this.language,theme:this.theme,code:this.code}};export{p as Block,u as torchlight};
import t from"axios";import e from"md5";import i from"lodash.get";import o from"lodash.chunk";import n from"chalk";let s=!1;function h(t,e){e=Array.from(e),s||console.log(t(e.shift()),...e)}var r={error:function(){h(n.bold.bgRed,arguments)},info:function(){h(n.green,arguments)},silence:function(t=!0){s=t}};let l={};function c(){}c.prototype.get=function(t,e){if(!Object.prototype.hasOwnProperty.call(l,t))return e;const i=l[t];return Date.now()/1e3>i.expires?(this.delete(t),e):i.value},c.prototype.set=function(t,e,i=10080){l[t]={expires:Date.now()/1e3+i,value:e}},c.prototype.delete=function(t){delete l[t]},c.prototype.clear=function(){l={}};const a=function(){this.initialized=!1,this.chunkSize=30,this.configuration={}};a.prototype.init=function(t,e){var i,o,n;return this.initialized||(t=t||{},null===(i=process)||void 0===i||null===(o=i.env)||void 0===o||!o.TORCHLIGHT_TOKEN||null!==(n=t)&&void 0!==n&&n.token||(t.token=process.env.TORCHLIGHT_TOKEN),this.initialized=!0,this.configuration=t,this.cache=e||new c),this},a.prototype.config=function(t,e){return i(this.configuration,t,e)},a.prototype.configHash=function(){return e(this.configuration)},a.prototype.highlight=function(t){t.map((t=>t.setResponseData(this.cache.get(t.hash(),{}))));const e=t.filter((t=>!t.highlighted));return this.request(e).then((i=>(e.forEach((t=>{const e=i.find((e=>t.id===e.id));e&&e.highlighted&&(this.cache.set(t.hash(),{highlighted:e.highlighted,classes:e.classes,styles:e.styles}),t.setResponseData(e))})),t.filter((t=>!t.highlighted)).forEach((t=>{r.error(`A block failed to highlight. The code was: \`${t.code.substring(0,20)} [...]\``),t.highlighted=t.code.split("\n").map((t=>{return`<div class="line">${e=t,String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}</div>`;var e})).join(""),t.classes="torchlight"})),t)))},a.prototype.request=function(e){if(!e.length)return Promise.resolve([]);const i=this.config("token");if(e.length>this.chunkSize)return this.fan(e);const o=this.config("host","https://api.torchlight.dev");return t.post(`${o}/highlight`,{blocks:e.map((t=>t.toRequestParams())),options:this.config("options",{})},{headers:{Authorization:`Bearer ${i}`,"X-Torchlight-Client":"Torchlight CLI"}}).then((t=>t.data.blocks))},a.prototype.fan=function(t){const e=[],i=[],n=o(t,this.chunkSize).map((t=>this.request(t)));return Promise.allSettled(n).then((t=>{if(t.forEach((t=>{"fulfilled"===t.status&&e.push(...t.value),"rejected"===t.status&&i.push(t.reason)})),e.length)return i.length&&r.error(`${i.length} fanned request(s) failed, but others succeeded. Error: ${i[0]}.`),e;if(i.length)throw new Error(i[0]);return[]}))};var u=new a;function g(){const t=()=>Math.floor(65536*(1+Math.random())).toString(16).substring(1);return`${t()}${t()}-${t()}-${t()}-${t()}-${t()}${t()}${t()}`.toLowerCase()}function p(t={}){t={id:g(),theme:u.config("theme","nord"),...t},this.id=t.id,this.code=t.code,this.language=t.language,this.theme=t.theme,this.highlighted=null,this.classes=null,this.styles=null}p.prototype.hash=function(){return e(""+this.language+this.theme+this.code+u.config("bust",0)+JSON.stringify(u.config("options")))},p.prototype.code=function(t){return this.code=t,this},p.prototype.language=function(t){return this.language=t,this},p.prototype.theme=function(t){return this.theme=t,this},p.prototype.placeholder=function(t=""){return t&&(t=`-${t}`),`__torchlight-block-[${this.id}]${t}__`},p.prototype.setResponseData=function(t){return t&&(this.highlighted=t.highlighted,this.classes=t.classes,this.styles=t.styles),this},p.prototype.toRequestParams=function(){return{id:this.id,hash:this.hash,language:this.language,theme:this.theme,code:this.code}};export{p as Block,u as torchlight};
//# sourceMappingURL=torchlight-cli.esm.min.js.map

@@ -223,10 +223,5 @@ #! /usr/bin/env node

const token = this.config('token');
if (!token) {
throw new Error('No Torchlight token configured!');
} // For huge sites, we need to send blocks in chunks so
const token = this.config('token'); // For huge sites, we need to send blocks in chunks so
// that we don't send e.g. 500 blocks in one request.
if (blocks.length > this.chunkSize) {

@@ -233,0 +228,0 @@ return this.fan(blocks);

{
"name": "@aaron-dev/torchlight-cli",
"version": "0.1.1655321148",
"version": "0.1.1655321213",
"description": "A CLI for Torchlight - the syntax highlighting API",

@@ -5,0 +5,0 @@ "source": "./src/index.js",

@@ -116,6 +116,2 @@ import axios from 'axios'

if (!token) {
throw new Error('No Torchlight token configured!')
}
// For huge sites, we need to send blocks in chunks so

@@ -122,0 +118,0 @@ // that we don't send e.g. 500 blocks in one request.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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