Socket
Socket
Sign inDemoInstall

@tkskto/vue-component-analyzer

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tkskto/vue-component-analyzer - npm Package Compare versions

Comparing version 0.4.1 to 0.5.0

dist/index.mjs

8

bin/analyze.js
#!/usr/bin/env node
import {vueComponentAnalyze} from '../dist/index.mjs';
/**

@@ -9,5 +11,3 @@ * Catch and report unexpected error.

function onCatchError(error) {
const {version} = require('../package.json');
console.error(`Something went wrong. component-analyzer: ${version}. follow error message.`);
console.error('Something went wrong. component-analyzer. follow error message.');
console.error(`${error.message}`);

@@ -23,3 +23,3 @@

try {
require('../dist/index');
vueComponentAnalyze();
} catch (err) {

@@ -26,0 +26,0 @@ onCatchError(err);

# Changelog
## 0.5.0
change package type to `module`.
### Chores
- \#158 update dependency `commander` to v9.0.0
- \#159 update dependency `globby` to v13.0.0
## 0.4.1

@@ -4,0 +13,0 @@

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

class e{constructor(e){this.type=e,this.currentTarget=null}}e.COMPLETE="complete",e.CHANGE_PROPERTY="changeProperty";class t{constructor(e,t,s=0){this.type=e,this.handler=t,this.priority=s}equalCurrentListener(e,t){return this.type===e&&this.handler===t}}class s extends class{constructor(){this.listeners={}}dispatchEvent(t){let s,i;if(t instanceof e?(i=t.type,s=t):(i=t,s=new e(i)),null!==this.listeners[i]){const e=this.listeners[i].length;s.currentTarget=this;for(let t=0;t<e;t++){const e=this.listeners[i][t];try{e.handler(s)}catch(e){e instanceof Error&&console.error(e.stack)}}}else console.warn('implement "addEventListener" before dispatch')}addEventListener(e,s,i=0){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(new t(e,s,i)),this.listeners[e].sort(((e,t)=>t.priority-e.priority))}removeEventListener(e,t){if(this.hasEventListener(e,t))for(let s=0;s<this.listeners[e].length;s++){if(this.listeners[e][s].equalCurrentListener(e,t))return void this.listeners[e].splice(s,1)}}clearEventListener(){this.listeners={}}containEventListener(e){return!!this.listeners[e]&&this.listeners[e].length>0}hasEventListener(e,t){if(!this.listeners[e])return!1;for(let s=0;s<this.listeners[e].length;s++){if(this.listeners[e][s].equalCurrentListener(e,t))return!0}return!1}}{constructor(){super(),this._data={entries:[],count:{}},this._viewType="GRAPH",this._visibleSettings=!1,this._visibleProps=!0,this._visibleFileSize=!0,this._visibleLastUpdated=!0,this._visibleReferenceCount=!0,this.getHowManyDaysAgo=e=>{const t=e.getTime(),s=this._todayTime-t;return Math.floor(s/864e5)},this._today=new Date,this._todayTime=this._today.getTime()}get data(){return this._data}set data(e){this._data=e,this.dispatchEvent(s.EVENT.DATA_UPDATE)}get viewType(){return this._viewType}set viewType(e){this._viewType=e,this.dispatchEvent(s.EVENT.SETTING_CHANGED)}get visibleSettings(){return this._visibleSettings}set visibleSettings(e){this._visibleSettings=e,this.dispatchEvent(s.EVENT.SETTING_CHANGED)}get visibleProps(){return this._visibleProps}set visibleProps(e){this._visibleProps=e,this.dispatchEvent(s.EVENT.SETTING_CHANGED)}get visibleFileSize(){return this._visibleFileSize}set visibleFileSize(e){this._visibleFileSize=e,this.dispatchEvent(s.EVENT.SETTING_CHANGED)}get visibleLastUpdated(){return this._visibleLastUpdated}set visibleLastUpdated(e){this._visibleLastUpdated=e,this.dispatchEvent(s.EVENT.SETTING_CHANGED)}get visibleReferenceCount(){return this._visibleReferenceCount}set visibleReferenceCount(e){this._visibleReferenceCount=e,this.dispatchEvent(s.EVENT.SETTING_CHANGED)}}s.EVENT={DATA_UPDATE:"dataUpdate",SETTING_CHANGED:"settingChanged"};class i{constructor(e,t,s){this._model=s,this._children=[],this._name=e.name,this._props=e.props,this._fileSize=e.size,this._lastModifiedTime=e.lastModifiedTime,this._count=t}renderChildren(){let e="";for(let t=0,s=this._children.length;t<s;t++)e+=this._children[t].render();return`<div class="group">\n ${e}\n </div>`}renderProps(){return this._props?`<pre class="file__props">props: ${JSON.stringify(this._props,null,"\t")}</pre>`:""}renderMetaData(){let e="";const t=(this._fileSize/1024).toFixed(2);return t&&(e+=`<span class="file__meta meta__fileSize">FileSize: ${t} KB</span>`),e+=`<span class="file__meta meta__lastUpdated">LastUpdated: ${0===this._lastModifiedTime?0:this._model.getHowManyDaysAgo(new Date(this._lastModifiedTime))} days ago</span>`,e}renderSummary(){let e=this._name;return this._name.endsWith(".vue")?e=`<svg class="icon" viewBox="0 0 128 128" width="24" height="24"><use xlink:href="#logo"></use></svg>${e}`:this._name.endsWith(".js")?e=`<img class="icon" src="https://raw.githubusercontent.com/voodootikigod/logo.js/master/js.png" alt="">${e}`:this._name.endsWith(".ts")&&(e=`<img class="icon" src="../dist/icon/icon-ts.png" alt="">${e}`),`<summary>${e}</summary>`}renderDetails(){return`<details class="detail">\n ${this.renderSummary()}\n ${this.renderProps()}\n ${this.renderMetaData()}\n </details>`}render(){const e=this.renderDetails();let t="",s="";return this._children.length>0?t=this.renderChildren():s=" -no-child",this.isJS()&&(s+=" js"),`<div class="seed${s}">\n <div class="file">\n <div class="filename">\n <div class="file__text">${e}</div>\n ${this.getCountText()}\n </div>\n </div>\n ${t}\n </div>`}getCountText(){return 0===this._count?"":1===this._count?'<span class="file__count">1 time referenced.</span>':`<span class="file__count">${this._count} times referenced.</span>`}get children(){return this._children}set children(e){this._children=e}isJS(){return this._name.endsWith(".js")}}class n{constructor(e,t){this._elm=e,this._model=t,this._type=e.dataset.settingName,e.addEventListener("change",this.onChange.bind(this))}onChange(){switch(this._type){case"props":this._model.visibleProps=this._elm.checked;break;case"fileSize":this._model.visibleFileSize=this._elm.checked;break;case"lastUpdated":this._model.visibleLastUpdated=this._elm.checked;break;case"referenceCount":this._model.visibleReferenceCount=this._elm.checked;break;default:throw new Error(`not supported type: ${this._type}`)}}}class r{constructor(e,t,s){this._elm=e,this._type=t,this._model=s,e.addEventListener("change",this.onChange.bind(this))}onChange(){this._model.viewType=this._type}}class o{constructor(e,t){this._isOpen=!1,this._details=null,this._textElement=document.getElementById("btn-toggle-visible-state-text"),e.addEventListener("click",this.onClick.bind(this)),t.addEventListener(s.EVENT.DATA_UPDATE,this.onDataUpdated.bind(this))}open(){this._details&&this._details.forEach((e=>{e.open=!0})),this._textElement&&(this._textElement.textContent="collapse all")}close(){this._details&&this._details.forEach((e=>{e.open=!1})),this._textElement&&(this._textElement.textContent="expand all")}onClick(){this._isOpen=!this._isOpen,this._isOpen?this.open():this.close()}onDataUpdated(){this._details=document.querySelectorAll(".detail")}}
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
function l(e,t,s,i){return new(s||(s=Promise))((function(n,r){function o(e){try{a(i.next(e))}catch(e){r(e)}}function l(e){try{a(i.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(o,l)}a((i=i.apply(e,t||[])).next())}))}const a=new class{constructor(){this._contents=document.getElementById("dialog-contents"),this._btnClose=document.getElementById("btn-dialog-close"),this._btnExport=document.getElementById("btn-export"),this._btnClose&&this._btnClose.addEventListener("click",this.close.bind(this))}show(){document.body.classList.add("-dialog-show"),(e=>{let t=Array.from(document.querySelectorAll("a, button, summary"));e&&(t=t.filter((t=>null===t.closest(e)))),t.forEach((e=>{e.classList.add("-focus-disabled"),e.setAttribute("tabindex","-1")}))})("#dialog")}close(){document.body.classList.remove("-dialog-show"),document.querySelectorAll(".-focus-disabled").forEach((e=>{e.classList.remove("-focus-disabled"),e.removeAttribute("tabindex")}))}load(){this.show(),this._contents&&(this._contents.innerHTML="<p>now loading...</p>")}complete(e){this._contents&&(this._contents.innerHTML=e)}showExportDialog(){return l(this,void 0,void 0,(function*(){this.load();const e=yield c();this._btnExport.href=e.src,this.complete(e.outerHTML)}))}};const d=new class{constructor(){this._style="",this.getStyle=()=>fetch("/dist/style.css").then((e=>e.text())),this.getCurrentStyleText=()=>l(this,void 0,void 0,(function*(){if(this._style)return this._style;const e=yield this.getStyle();return this._style=e.replace('@charset "UTF-8";',"").trim(),this._style}))}},h=e=>new Promise(((t,s)=>{const i=new Image;i.addEventListener("load",(()=>{t(i)})),i.addEventListener("error",s),i.src=e})),c=()=>l(void 0,void 0,void 0,(function*(){const e=document.querySelector(".root.html");if(e){const t=e.scrollWidth,s=e.scrollHeight,i=yield((e,t,s)=>l(void 0,void 0,void 0,(function*(){const i=e.cloneNode(!0);i.querySelectorAll("img, script, svg").forEach((e=>{e.parentElement&&e.parentElement.removeChild(e)}));const n=yield d.getCurrentStyleText();return`<svg width="${t}" height="${s}" viewBox="0 0 ${t} ${s}" xmlns="http://www.w3.org/2000/svg"><foreignObject width="${t}" height="${s}" requiredExtensions="http://www.w3.org/1999/xhtml"><body xmlns="http://www.w3.org/1999/xhtml"><style>${n}</style>${i.outerHTML}</body></foreignObject></svg>`})))(e,t,s),n=yield h(`data:image/svg+xml;base64,${btoa(i)}`);return yield((e,t,s)=>l(void 0,void 0,void 0,(function*(){const i=document.createElement("canvas");i.width=t,i.height=s;const n=i.getContext("2d");n&&n.drawImage(e,0,0);const r=i.toDataURL("image/png",100);return yield h(r)})))(n,t,s)}return new Image})),u=new s;let p;new class{constructor(e){this._model=e,this._tree=[],this.ready=()=>{if("GRAPH"===this._model.viewType){const{data:e}=this._model,{entries:t}=e;for(let s=0,n=t.length;s<n;s++){const n=t[s];if(e){const e=new i(n,0,this._model);this._tree.push(this.generateSeed(n,e))}}}this.render()},this._app=document.getElementById("app"),e.addEventListener(s.EVENT.DATA_UPDATE,this.ready)}generateSeed(e,t){const s=[],{children:n}=e,r=[],{count:o}=this._model.data;for(let e=0,t=n.length;e<t;e++){const t=n[e],s=new i(t,o[t.name],this._model);r.push(s),this.generateSeed(t,s)}return t.children=r,s.push(t),s}renderLine(e,t,s){let i=" ";for(let e=0;e<t;e++)i+="│ ";return i+=s?"└─ ":"├─ ",i+=e,`${i}\n`}renderEntry(e,t){let s="";for(let i=0,n=e.children.length;i<n;i++){const r=e.children[i];s+=this.renderLine(r.name,t,i===n-1),s+=this.renderEntry(r,t+1)}return s}render(){let e="";for(let t=0,s=this._tree.length;t<s;t++){const[s]=this._tree[t];e+=s.render()}e=`<div class="root html">${e}</div>`;const{entries:t}=this._model.data;let s="";for(let e=0,i=t.length;e<i;e++){s+=`${t[e].name}\n`,s+=this.renderEntry(t[e],0),e<i-1&&(s+="\n")}s=`<div class="root text"><pre class="tree">${s}</pre></div>`,this._app&&(this._app.innerHTML=e+s)}}(u);try{window.enableWebSocket&&(p=new WebSocket(`ws://${location.host}`))}catch(e){console.warn("Couldn't connect to analyzer websocket server so you'll have to reload page manually to see updates in the treemap")}document.addEventListener("DOMContentLoaded",(()=>{p?p.addEventListener("message",(e=>{const t=JSON.parse(e.data);(e=>{const t=document.getElementById("btn-toggle-visible-state");t&&new o(t,e)})(u),u.data=t,function(e){const{body:t}=document,i=document.getElementById("btn-settings"),o=t.querySelectorAll(".js-settings-toggle"),l=document.getElementById("js-view-switch-graph"),a=document.getElementById("js-view-switch-text");new r(l,"GRAPH",e),new r(a,"TEXT",e);const d=function(){t.className=`${e.viewType}`,e.visibleSettings&&t.classList.add("show-settings"),e.visibleProps||t.classList.add("no-props"),e.visibleFileSize||t.classList.add("no-fileSize"),e.visibleLastUpdated||t.classList.add("no-lastUpdated"),e.visibleReferenceCount||t.classList.add("no-referenceCount")};o.forEach((t=>{new n(t,e)})),e.addEventListener(s.EVENT.SETTING_CHANGED,d),i&&i.addEventListener("click",(()=>{e.visibleSettings=!e.visibleSettings})),d()}(u),function(){const e=document.querySelector("#btn-capture");e&&e.addEventListener("click",(()=>l(this,void 0,void 0,(function*(){try{yield a.showExportDialog()}catch(e){console.error(e)}}))))}()})):console.warn("Couldn't connect to analyzer websocket server so you'll have to reload page manually to see updates in the treemap")}));
class e{constructor(e){this.type=e,this.currentTarget=null}}e.COMPLETE="complete",e.CHANGE_PROPERTY="changeProperty";class t{constructor(e,t,s=0){this.type=e,this.handler=t,this.priority=s}equalCurrentListener(e,t){return this.type===e&&this.handler===t}}class s extends class{constructor(){this.listeners={}}dispatchEvent(t){let s,i;if(t instanceof e?(i=t.type,s=t):(i=t,s=new e(i)),null!==this.listeners[i]){const e=this.listeners[i].length;s.currentTarget=this;for(let t=0;t<e;t++){const e=this.listeners[i][t];try{e.handler(s)}catch(e){e instanceof Error&&console.error(e.stack)}}}else console.warn('implement "addEventListener" before dispatch')}addEventListener(e,s,i=0){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(new t(e,s,i)),this.listeners[e].sort(((e,t)=>t.priority-e.priority))}removeEventListener(e,t){if(this.hasEventListener(e,t))for(let s=0;s<this.listeners[e].length;s++){if(this.listeners[e][s].equalCurrentListener(e,t))return void this.listeners[e].splice(s,1)}}clearEventListener(){this.listeners={}}containEventListener(e){return!!this.listeners[e]&&this.listeners[e].length>0}hasEventListener(e,t){if(!this.listeners[e])return!1;for(let s=0;s<this.listeners[e].length;s++){if(this.listeners[e][s].equalCurrentListener(e,t))return!0}return!1}}{constructor(){super(),this._data={entries:[],count:{}},this._viewType="GRAPH",this._visibleSettings=!1,this._visibleProps=!0,this._visibleFileSize=!0,this._visibleLastUpdated=!0,this._visibleReferenceCount=!0,this.getHowManyDaysAgo=e=>{const t=e.getTime(),s=this._todayTime-t;return Math.floor(s/864e5)},this._today=new Date,this._todayTime=this._today.getTime()}get data(){return this._data}set data(e){this._data=e,this.dispatchEvent(s.EVENT.DATA_UPDATE)}get viewType(){return this._viewType}set viewType(e){this._viewType=e,this.dispatchEvent(s.EVENT.SETTING_CHANGED)}get visibleSettings(){return this._visibleSettings}set visibleSettings(e){this._visibleSettings=e,this.dispatchEvent(s.EVENT.SETTING_CHANGED)}get visibleProps(){return this._visibleProps}set visibleProps(e){this._visibleProps=e,this.dispatchEvent(s.EVENT.SETTING_CHANGED)}get visibleFileSize(){return this._visibleFileSize}set visibleFileSize(e){this._visibleFileSize=e,this.dispatchEvent(s.EVENT.SETTING_CHANGED)}get visibleLastUpdated(){return this._visibleLastUpdated}set visibleLastUpdated(e){this._visibleLastUpdated=e,this.dispatchEvent(s.EVENT.SETTING_CHANGED)}get visibleReferenceCount(){return this._visibleReferenceCount}set visibleReferenceCount(e){this._visibleReferenceCount=e,this.dispatchEvent(s.EVENT.SETTING_CHANGED)}}s.EVENT={DATA_UPDATE:"dataUpdate",SETTING_CHANGED:"settingChanged"};class i{constructor(e,t,s){this._model=s,this._children=[],this._name=e.name,this._props=e.props,this._fileSize=e.size,this._lastModifiedTime=e.lastModifiedTime,this._count=t}renderChildren(){let e="";for(let t=0,s=this._children.length;t<s;t++)e+=this._children[t].render();return`<div class="group">\n ${e}\n </div>`}renderProps(){return this._props?`<pre class="file__props">props: ${JSON.stringify(this._props,null,"\t")}</pre>`:""}renderMetaData(){let e="";const t=(this._fileSize/1024).toFixed(2);return t&&(e+=`<span class="file__meta meta__fileSize">FileSize: ${t} KB</span>`),e+=`<span class="file__meta meta__lastUpdated">LastUpdated: ${0===this._lastModifiedTime?0:this._model.getHowManyDaysAgo(new Date(this._lastModifiedTime))} days ago</span>`,e}renderSummary(){let e=this._name;return this._name.endsWith(".vue")?e=`<svg class="icon" viewBox="0 0 128 128" width="24" height="24"><use xlink:href="#logo"></use></svg>${e}`:this._name.endsWith(".js")?e=`<img class="icon" src="https://raw.githubusercontent.com/voodootikigod/logo.js/master/js.png" alt="">${e}`:this._name.endsWith(".ts")&&(e=`<img class="icon" src="../dist/icon/icon-ts.png" alt="">${e}`),`<summary>${e}</summary>`}renderDetails(){return`<details class="detail">\n ${this.renderSummary()}\n ${this.renderProps()}\n ${this.renderMetaData()}\n </details>`}render(){const e=this.renderDetails();let t="",s="";return this._children.length>0?t=this.renderChildren():s=" -no-child",this.isJS()&&(s+=" js"),`<div class="seed${s}">\n <div class="file">\n <div class="filename">\n <div class="file__text">${e}</div>\n ${this.getCountText()}\n </div>\n </div>\n ${t}\n </div>`}getCountText(){return 0===this._count?"":1===this._count?'<span class="file__count">1 time referenced.</span>':`<span class="file__count">${this._count} times referenced.</span>`}get children(){return this._children}set children(e){this._children=e}isJS(){return this._name.endsWith(".js")}}class n{constructor(e,t){this._elm=e,this._model=t,this._type=e.dataset.settingName,e.addEventListener("change",this.onChange.bind(this))}onChange(){switch(this._type){case"props":this._model.visibleProps=this._elm.checked;break;case"fileSize":this._model.visibleFileSize=this._elm.checked;break;case"lastUpdated":this._model.visibleLastUpdated=this._elm.checked;break;case"referenceCount":this._model.visibleReferenceCount=this._elm.checked;break;default:throw new Error(`not supported type: ${this._type}`)}}}class r{constructor(e,t,s){this._elm=e,this._type=t,this._model=s,e.addEventListener("change",this.onChange.bind(this))}onChange(){this._model.viewType=this._type}}class l{constructor(e,t){this._isOpen=!1,this._details=null,this._textElement=document.getElementById("btn-toggle-visible-state-text"),e.addEventListener("click",this.onClick.bind(this)),t.addEventListener(s.EVENT.DATA_UPDATE,this.onDataUpdated.bind(this))}open(){this._details&&this._details.forEach((e=>{e.open=!0})),this._textElement&&(this._textElement.textContent="collapse all")}close(){this._details&&this._details.forEach((e=>{e.open=!1})),this._textElement&&(this._textElement.textContent="expand all")}onClick(){this._isOpen=!this._isOpen,this._isOpen?this.open():this.close()}onDataUpdated(){this._details=document.querySelectorAll(".detail")}}const o=new class{constructor(){this._contents=document.getElementById("dialog-contents"),this._btnClose=document.getElementById("btn-dialog-close"),this._btnExport=document.getElementById("btn-export"),this._btnClose&&this._btnClose.addEventListener("click",this.close.bind(this))}show(){document.body.classList.add("-dialog-show"),(e=>{let t=Array.from(document.querySelectorAll("a, button, summary"));e&&(t=t.filter((t=>null===t.closest(e)))),t.forEach((e=>{e.classList.add("-focus-disabled"),e.setAttribute("tabindex","-1")}))})("#dialog")}close(){document.body.classList.remove("-dialog-show"),document.querySelectorAll(".-focus-disabled").forEach((e=>{e.classList.remove("-focus-disabled"),e.removeAttribute("tabindex")}))}load(){this.show(),this._contents&&(this._contents.innerHTML="<p>now loading...</p>")}complete(e){this._contents&&(this._contents.innerHTML=e)}async showExportDialog(){this.load();const e=await d();this._btnExport.href=e.src,this.complete(e.outerHTML)}};const a=new class{constructor(){this._style="",this.getStyle=async()=>{const e=document.querySelector("#style");let t="";return e&&(t=await fetch(e.href).then((e=>e.text()))),t},this.getCurrentStyleText=async()=>{if(this._style)return this._style;const e=await this.getStyle();return this._style=e.replace('@charset "UTF-8";',"").trim(),this._style}}},h=e=>new Promise(((t,s)=>{const i=new Image;i.addEventListener("load",(()=>{t(i)})),i.addEventListener("error",s),i.src=e})),d=async()=>{const e=document.querySelector(".root.html");if(e){const t=e.scrollWidth,s=e.scrollHeight,i=await(async(e,t,s)=>{const i=e.cloneNode(!0);return i.querySelectorAll("img, script, svg").forEach((e=>{e.parentElement&&e.parentElement.removeChild(e)})),`<svg width="${t}" height="${s}" viewBox="0 0 ${t} ${s}" xmlns="http://www.w3.org/2000/svg"><foreignObject width="${t}" height="${s}" requiredExtensions="http://www.w3.org/1999/xhtml"><body xmlns="http://www.w3.org/1999/xhtml"><style>${await a.getCurrentStyleText()}</style>${i.outerHTML}</body></foreignObject></svg>`})(e,t,s),n=await h(`data:image/svg+xml;base64,${btoa(i)}`);return await(async(e,t,s)=>{const i=document.createElement("canvas");i.width=t,i.height=s;const n=i.getContext("2d");n&&n.drawImage(e,0,0);const r=i.toDataURL("image/png",100);return await h(r)})(n,t,s)}return new Image},c=new s;let u;new class{constructor(e){this._model=e,this._tree=[],this.ready=()=>{if("GRAPH"===this._model.viewType){const{data:e}=this._model,{entries:t}=e;for(let s=0,n=t.length;s<n;s++){const n=t[s];if(e){const e=new i(n,0,this._model);this._tree.push(this.generateSeed(n,e))}}}this.render()},this._app=document.getElementById("app"),e.addEventListener(s.EVENT.DATA_UPDATE,this.ready)}generateSeed(e,t){const s=[],{children:n}=e,r=[],{count:l}=this._model.data;for(let e=0,t=n.length;e<t;e++){const t=n[e],s=new i(t,l[t.name],this._model);r.push(s),this.generateSeed(t,s)}return t.children=r,s.push(t),s}renderLine(e,t,s){let i=" ";for(let e=0;e<t;e++)i+="│ ";return i+=s?"└─ ":"├─ ",i+=e,`${i}\n`}renderEntry(e,t){let s="";for(let i=0,n=e.children.length;i<n;i++){const r=e.children[i];s+=this.renderLine(r.name,t,i===n-1),s+=this.renderEntry(r,t+1)}return s}render(){let e="";for(let t=0,s=this._tree.length;t<s;t++){const[s]=this._tree[t];e+=s.render()}e=`<div class="root html">${e}</div>`;const{entries:t}=this._model.data;let s="";for(let e=0,i=t.length;e<i;e++){s+=`${t[e].name}\n`,s+=this.renderEntry(t[e],0),e<i-1&&(s+="\n")}s=`<div class="root text"><pre class="tree">${s}</pre></div>`,this._app&&(this._app.innerHTML=e+s)}}(c);try{window.enableWebSocket&&(u=new WebSocket(`ws://${location.host}`))}catch(e){console.warn("Couldn't connect to analyzer websocket server so you'll have to reload page manually to see updates in the treemap")}document.addEventListener("DOMContentLoaded",(()=>{u?u.addEventListener("message",(e=>{const t=JSON.parse(e.data);(e=>{const t=document.getElementById("btn-toggle-visible-state");t&&new l(t,e)})(c),c.data=t,function(e){const{body:t}=document,i=document.getElementById("btn-settings"),l=t.querySelectorAll(".js-settings-toggle"),o=document.getElementById("js-view-switch-graph"),a=document.getElementById("js-view-switch-text");new r(o,"GRAPH",e),new r(a,"TEXT",e);const h=function(){t.className=`${e.viewType}`,e.visibleSettings&&t.classList.add("show-settings"),e.visibleProps||t.classList.add("no-props"),e.visibleFileSize||t.classList.add("no-fileSize"),e.visibleLastUpdated||t.classList.add("no-lastUpdated"),e.visibleReferenceCount||t.classList.add("no-referenceCount")};l.forEach((t=>{new n(t,e)})),e.addEventListener(s.EVENT.SETTING_CHANGED,h),i&&i.addEventListener("click",(()=>{e.visibleSettings=!e.visibleSettings})),h()}(c),function(){const e=document.querySelector("#btn-capture");e&&e.addEventListener("click",(async()=>{try{await o.showExportDialog()}catch(e){console.error(e)}}))}()})):console.warn("Couldn't connect to analyzer websocket server so you'll have to reload page manually to see updates in the treemap")}));
{
"name": "@tkskto/vue-component-analyzer",
"version": "0.4.1",
"version": "0.5.0",
"description": "Analyze dependency tree for Vue.js SFC (Single File Component)",
"main": "dist/index.js",
"module": "dist/index.js",
"type": "module",
"bin": {

@@ -17,6 +16,6 @@ "vca": "bin/analyze.js"

"cover:report": "nyc report --reporter=html",
"test": "npm run test:base -- --timeout 60000",
"test:base": "ts-mocha ./test/specs/*.ts",
"test:base:update": "ts-mocha ./test/specs/*.ts --update",
"tmp": "node dist/index.js --dir . -p 8888"
"test": "npm run test:base",
"test:base": "jest --config=jest.config.js --testTimeout=60000",
"test:base:update": "jest --config=jest.config.js --updateSnapshot --testTimeout=60000",
"tmp": "node bin/analyze.js --dir . -p 8888"
},

@@ -49,6 +48,6 @@ "keywords": [

"dependencies": {
"commander": "8.3.0",
"commander": "9.0.0",
"ejs": "3.1.6",
"express": "4.17.3",
"globby": "11.0.4",
"globby": "13.1.1",
"mkdirp": "1.0.4",

@@ -67,5 +66,5 @@ "opener": "1.5.2",

"@types/express": "4.17.13",
"@types/jest": "27.4.1",
"@types/mkdirp": "1.0.2",
"@types/mocha": "9.1.0",
"@types/node": "16.11.11",
"@types/node": "16.11.26",
"@types/opener": "1.4.0",

@@ -77,4 +76,4 @@ "@types/ws": "8.2.3",

"husky": "7.0.4",
"jest": "27.5.1",
"lint-staged": "12.3.4",
"mocha": "9.2.1",
"nyc": "15.1.0",

@@ -84,4 +83,5 @@ "rollup": "2.67.3",

"rollup-plugin-terser": "7.0.2",
"ts-mocha": "8.0.0",
"typescript": "4.5.2"
"ts-jest": "27.1.3",
"ts-node": "10.7.0",
"typescript": "4.6.2"
},

@@ -88,0 +88,0 @@ "lint-staged": {

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