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

vite-plugin-style-to-vw

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-style-to-vw - npm Package Compare versions

Comparing version 1.0.9 to 1.1.0

21

dist/index.d.ts

@@ -1,11 +0,12 @@

declare module 'vite-plugin-style-to-vw' {
export interface IdefaultsProp {
unitToConvert: string,
viewportWidth: number,
unitPrecision: number,
viewportUnit: string,
fontViewportUnit: string,
minPixelValue: number,
}
export type VitePluginStyleToVw = (options?: IdefaultsProp)=>any
interface IdefaultsProp {
unitToConvert: string,
viewportWidth: number,
unitPrecision: number,
viewportUnit: string,
fontViewportUnit: string,
minPixelValue: number,
}
type VitePluginStyleToVw = (options?: IdefaultsProp)=>any
export { IdefaultsProp, VitePluginStyleToVw, VitePluginStyleToVw as default };

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

"use strict";var c=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var m=(t,e)=>{for(var i in e)c(t,i,{get:e[i],enumerable:!0})},S=(t,e,i,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of P(e))!x.call(t,a)&&a!==i&&c(t,a,{get:()=>e[a],enumerable:!(n=v(e,a))||n.enumerable});return t};var b=t=>S(c({},"__esModule",{value:!0}),t);var U={};m(U,{default:()=>T});module.exports=b(U);var w={unitToConvert:"px",viewportWidth:750,unitPrecision:5,viewportUnit:"vw",fontViewportUnit:"vw",minPixelValue:1};function M(t,e){let i=Math.pow(10,e+1),n=Math.floor(t*i);return Math.round(n/10)*10/i}function h(t,e,i,n){return function(a,r){if(!r)return;let s=parseFloat(r);if(!(s<=e))return M(s/t*100,i)+n}}var g=/<template>([\s\S]+)<\/template>/gi,o=/(\d+)px/g,p=/style\s*(:|=)\s*(?:"([^"]*?)"|'([^']*?)'|{([^}]*)})/g,R=(t=w)=>({name:"vite-plugin-style-to-vw",transform(e,i){if(t=Object.assign(w,t),/.vue$/.test(i)){let n="",a="";if(g.test(e)?(n=e.match(g)[0],a=e.match(g)[0]):e.includes("setup")&&(n=e,a=e),p.test(n)){let r=n.match(p);if(r?.length){let s=[];for(let l=0;l<r.length;l++){let f=r[l].replace(o,y=>y.replace(o,h(t.viewportWidth,t.minPixelValue,t.unitPrecision,t.viewportUnit)));s.push(f)}let u=n;for(let l=0;l<r.length;l++)u=u.replace(r[l],`${s[l]}`);e=e.replace(a,u)}}}else if(/\.tsx|\.jsx$/.test(i)){let n=e,a=e;if(p.test(n)){let r=n.match(p);if(r?.length){let s=[];for(let l=0;l<r.length;l++){let f=r[l].replace(o,y=>y.replace(o,h(t.viewportWidth,t.minPixelValue,t.unitPrecision,t.viewportUnit)));s.push(f)}let u=n;for(let l=0;l<r.length;l++)u=u.replace(r[l],`${s[l]}`);e=e.replace(a,u)}}}return{code:e}}}),T=R;0&&(module.exports={});
"use strict";var y=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var m=(t,e)=>{for(var i in e)y(t,i,{get:e[i],enumerable:!0})},S=(t,e,i,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of P(e))!v.call(t,a)&&a!==i&&y(t,a,{get:()=>e[a],enumerable:!(n=x(e,a))||n.enumerable});return t};var b=t=>S(y({},"__esModule",{value:!0}),t);var U={};m(U,{default:()=>T});module.exports=b(U);var h={unitToConvert:"px",viewportWidth:750,unitPrecision:5,viewportUnit:"vw",fontViewportUnit:"vw",minPixelValue:1};function M(t,e){let i=Math.pow(10,e+1),n=Math.floor(t*i);return Math.round(n/10)*10/i}function w(t,e,i,n){return function(a,r){if(!r)return;let s=parseFloat(r);if(!(s<=e))return M(s/t*100,i)+n}}var g=/<template>([\s\S]+)<\/template>/gi,o=/(\d+)px/g,p=/style\s*(:|=)\s*(?:"([^"]*?)"|'([^']*?)'|{([^}]*)})/g,R=(t=h)=>({name:"vite-plugin-style-to-vw",transform(e,i){if(t=Object.assign(h,t),/.vue$/.test(i)){let n="",a="";if(g.test(e)?(n=e.match(g)[0],a=e.match(g)[0]):e.includes("setup")&&(n=e,a=e),p.test(n)){let r=n.match(p);if(r?.length){let s=[];for(let l=0;l<r.length;l++){let f=r[l].replace(o,c=>c.replace(o,w(t.viewportWidth,t.minPixelValue,t.unitPrecision,t.viewportUnit)));s.push(f)}let u=n;for(let l=0;l<r.length;l++)u=u.replace(r[l],`${s[l]}`);e=e.replace(a,u)}}}else if(/\.tsx|\.jsx$/.test(i)){let n=e,a=e;if(p.test(n)){let r=n.match(p);if(r?.length){let s=[];for(let l=0;l<r.length;l++){let f=r[l].replace(o,c=>c.replace(o,w(t.viewportWidth,t.minPixelValue,t.unitPrecision,t.viewportUnit)));s.push(f)}let u=n;for(let l=0;l<r.length;l++)u=u.replace(r[l],`${s[l]}`);e=e.replace(a,u)}}}return{code:e}}}),T=R;0&&(module.exports={});
{
"name": "vite-plugin-style-to-vw",
"version": "1.0.9",
"version": "1.1.0",
"description": "一个可以将签内样式px转换vw的plugin",

@@ -5,0 +5,0 @@ "exports": {

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

export interface IdefaultsProp {
unitToConvert: string,
viewportWidth: number,
unitPrecision: number,
viewportUnit: string,
fontViewportUnit: string,
minPixelValue: number,
}
declare module 'vite-plugin-style-to-vw' {
export interface IdefaultsProp {
unitToConvert: string,
viewportWidth: number,
unitPrecision: number,
viewportUnit: string,
fontViewportUnit: string,
minPixelValue: number,
}
export type VitePluginStyleToVw = (options?: IdefaultsProp)=>any
}
export type VitePluginStyleToVw = (options?: IdefaultsProp)=>any
export default VitePluginStyleToVw

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

import type { IdefaultsProp,VitePluginStyleToVw } from 'vite-plugin-style-to-vw'
import type { IdefaultsProp,VitePluginStyleToVw } from './index.d'

@@ -3,0 +3,0 @@ // 默认参数

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