New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

vite-plugin-url-copy

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-url-copy - npm Package Compare versions

Comparing version 1.1.3 to 1.1.4

3

dist/index.d.ts
import { Plugin } from 'vite';
import { ColorName } from 'consola/utils';

@@ -13,2 +14,3 @@ interface CopyOptions {

custom?: string | ((URL: string) => string);
color?: ColorName;
}

@@ -21,2 +23,3 @@ interface QRCodeOptions {

custom?: string | ((URL: string) => string);
color?: ColorName;
}

@@ -23,0 +26,0 @@ interface Options {

16

dist/index.js

@@ -1,8 +0,10 @@

import w,{consola as $}from"consola";import{colorize as d}from"consola/utils";import{renderUnicodeCompact as S}from"uqr";const l=console.log;function x(t){return Object.prototype.toString.call(t)==="[object Object]"}function h(t=0){return new Promise(e=>{setTimeout(()=>{e()},t)})}async function f(t){try{return await t()}catch(e){return Promise.reject(e)}}let v={};function P(t){let e=!1;function o(c,i){for(const r of Object.keys(c))if(x(c[r])){const n=o(c[r],i[r]);if(n)return n}else if(c[r]!==i[r])return e=!0,e;return e}return o(t,v),e&&(v=t),e}const k=10;let b=0;async function m(t){const e=t.resolvedUrls;if(b>=k)throw new Error("timeout");return e?(b=0,e):(b++,await h(),m(t))}const p=[];function C(...t){p.push(...t)}const U=d("blue"," vite-plugin-url-copy_debug ");function O(t){if(!t)return;const e=p.length;let o="";for(const[c,i]of p.entries())o+=d("blue",i),c!==e-1&&(o+=`
import{colorize as l}from"consola/utils";import h,{consola as v}from"consola";import{renderUnicodeCompact as U}from"uqr";const C="vite-plugin-url-copy",O="1.1.4",f=console.log;function x(o){return Object.prototype.toString.call(o)==="[object Object]"}function p(o=0){return new Promise(e=>{setTimeout(()=>{e()},o)})}async function g(o){try{return await o()}catch(e){return Promise.reject(e)}}let P={};function k(o){let e=!1;function t(r,s){for(const i of Object.keys(r))if(x(r[i])){const c=t(r[i],s[i]);if(c)return c}else if(r[i]!==s[i])return e=!0,e;return e}return t(o,P),e&&(P=o),e}const L=10;let w=0;async function $(o){const e=o.resolvedUrls;if(w>=L)throw new Error("timeout");return e?(w=0,e):(w++,await p(),$(o))}const y=[];function j(...o){y.push(...o)}const B=l("blue"," vite-plugin-url-copy_debug ");function q(o){if(!o)return;const e=y.length;let t="";for(const[r,s]of y.entries())t+=l("blue",s),r!==e-1&&(t+=`
`);l(`
`),w.box({title:U,message:o,style:{padding:1,borderColor:"gray",borderStyle:"rounded"}}),p.length=0}const j=(t,e)=>{const{custom:o,mode:c,disabled:i}=e.copy,r=e.debug;if(!i)return f(async()=>{let n="",u=!1;typeof o=="string"&&o&&(u=!0,n=o),typeof o=="function"&&(u=!0,n=o(t[c][0])),n||(n=t[c][0]);const s=u?"cutsom":c;if(r&&C(`copy: ${s} - ${n}`,`copy: ${JSON.stringify(e.copy)}`),!n){await h(),$.warn(`url-copy: ${c} mode URL is undefined, Please check your vite configuration.`);return}return await(await import("clipboardy")).default.write(n),l(d("green",`
\u2714 `),d("bgGreen",` \xB7${s}\xB7 already copied to clipboard - ${n} `)),n}).catch(n=>{$.warn(`url-copy: ${n}`)})},g="network",q=(t,e)=>{const{custom:o,disabled:c}=e.qrcode,i=e.debug;if(c)return;let r="",n=!1;if(typeof o=="string"&&o&&(n=!0,r=o),typeof o=="function"&&(n=!0,r=o(t[g][0])),r||(r=t[g][0]),i&&C(`qrcode: ${n?"cutsom":g} - ${r}`,`qrcode: ${JSON.stringify(e.copy)}`),!r){w.warn("url-copy: QR-Code uses a network URL, Please check your vite configuration.");return}const u=B(r);let s="";try{s=[...u].map((a,y)=>(y||(a=` ${a}`),a===`
`&&(a=`${a} `),a)).join("")}catch{s=u}l(d("green",`
\u2714 `),d("bgGreen",` \xB7QRCode\xB7 of the ${g} - ${r} `),`
`),l(d("green",s))};function B(t){return S(t,{ecc:"L",border:1})}const Q={copy:{disabled:!1,mode:"local",custom:""},qrcode:{disabled:!0,custom:""},disabled:!1,debug:!1};function L(t){const{disabled:e,copy:o={},qrcode:c={},debug:i}=t,{disabled:r,copy:n,qrcode:u,debug:s}=Q;return{copy:{...n,...o},qrcode:{...u,...c},disabled:e??r,debug:i??s}}function N(t={}){const e=L(t);return{name:"server-url-copy",configureServer(o){if(e.disabled)return;const c=o.listen,i=o;i.listen=function(...r){const[n,u]=r;return f(async()=>{const s=await c.apply(this,r),a=await m(s);return f(async()=>{const y=s.config.server.port,R=P({port:y,...e});u&&!R||(await j(a,e),q(a,e),O(e.debug))}),s})}},configurePreviewServer(o){e.disabled||o.httpServer.once("listening",()=>{f(async()=>{const c=await m(o);await j(c,e),q(c,e),O(e.debug)})})}}}export{N as default};
`);f(`
`),h.box({title:B,message:t,style:{padding:1,borderColor:"gray",borderStyle:"rounded"}}),y.length=0}const R=(o,e)=>{const{custom:t,mode:r,disabled:s,color:i}=e.copy,c=e.debug;if(!s)return g(async()=>{let n="",u=!1;typeof t=="string"&&t&&(u=!0,n=t),typeof t=="function"&&(u=!0,n=t(o[r][0])),n||(n=o[r][0]);const a=u?"cutsom":r;if(c&&j(`copy: ${a} - ${n}`,`copy: ${JSON.stringify(e.copy)}`),!n){await p(),v.warn(`url-copy: ${r} mode URL is undefined, Please check your vite configuration.`);return}return await(await import("clipboardy")).default.write(n),f(l("green",`
\u2714 `),l(i,`\xB7${a}\xB7 already copied to clipboard - ${n} `)),n}).catch(n=>{v.warn(`url-copy: ${n}`)})},b="network",S=(o,e)=>{const{custom:t,disabled:r,color:s}=e.qrcode,i=e.debug;if(r)return;let c="",n=!1;if(typeof t=="string"&&t&&(n=!0,c=t),typeof t=="function"&&(n=!0,c=t(o[b][0])),c||(c=o[b][0]),i&&j(`qrcode: ${n?"cutsom":b} - ${c}`,`qrcode: ${JSON.stringify(e.copy)}`),!c){h.warn("url-copy: QR-Code uses a network URL, Please check your vite configuration.");return}const u=Q(c);let a="";try{a=[...u].map((d,m)=>(m||(d=` ${d}`),d===`
`&&(d=`${d} `),d)).join("")}catch{a=u}f(l("green",`
\u2714 `),l(s,`\xB7QRCode\xB7 of the ${b} - ${c} `),`
`),f(l(s,a))};function Q(o){return U(o,{ecc:"L",border:1})}const N={copy:{disabled:!1,mode:"local",custom:"",color:"green"},qrcode:{disabled:!0,custom:"",color:"green"},disabled:!1,debug:!1};function A(o){const{disabled:e,copy:t={},qrcode:r={},debug:s}=o,{disabled:i,copy:c,qrcode:n,debug:u}=N;return{copy:{...c,...t},qrcode:{...n,...r},disabled:e??i,debug:s??u}}function E(o={}){const e=A(o);return{name:"server-url-copy",configureServer(t){if(e.disabled)return;const r=t.listen,s=t;s.listen=function(...i){const[c,n]=i;return g(async()=>{const u=await r.apply(this,i),a=await $(u);return g(async()=>{const d=u.config.server.port,m=k({port:d,...e});n&&!m||(await p(),f(l("green",`
\u26A1${C.toLocaleUpperCase()} v${O}`)),await R(a,e),S(a,e),q(e.debug))}),u})}},configurePreviewServer(t){e.disabled||t.httpServer.once("listening",()=>{g(async()=>{await p(),f(l("green",`
\u26A1${C.toLocaleUpperCase()} v${O}`));const r=await $(t);await R(r,e),S(r,e),q(e.debug)})})}}}export{E as default};
{
"name": "vite-plugin-url-copy",
"type": "module",
"version": "1.1.3",
"packageManager": "pnpm@8.15.1",
"version": "1.1.4",
"packageManager": "pnpm@8.15.5",
"description": "Auto copy the Vite server URL and generate a QR code for easy access during dev or preview",

@@ -58,12 +58,12 @@ "author": "XioDone",

"devDependencies": {
"@antfu/eslint-config": "^2.6.4",
"@types/node": "^20.11.16",
"bumpp": "^9.3.0",
"eslint": "^8.56.0",
"@antfu/eslint-config": "^2.8.3",
"@types/node": "^20.11.30",
"bumpp": "^9.4.0",
"eslint": "^8.57.0",
"lint-staged": "^15.2.2",
"simple-git-hooks": "^2.9.0",
"tsup": "^8.0.1",
"typescript": "^5.3.3",
"simple-git-hooks": "^2.11.0",
"tsup": "^8.0.2",
"typescript": "^5.4.2",
"unbuild": "^2.0.0",
"vite": "^5.0.12"
"vite": "^5.2.2"
},

@@ -70,0 +70,0 @@ "simple-git-hooks": {

@@ -97,5 +97,7 @@ <h1 align="center">

disabled: false,
// Custom display color
color: 'green',
},
qrcode: {
// Custom string for the generate network QR code, It will overwrite the server URL
// Custom string for the generate QR code, It will overwrite the server URL
// custom?: string | ((URL: string) => string)

@@ -105,2 +107,4 @@ custom: '',

disabled: true,
// Custom display color
color: 'green',
},

@@ -107,0 +111,0 @@ // Disable plugin

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