@master/css-compiler
Advanced tools
Comparing version 2.0.0-beta.7 to 2.0.0-beta.8
@@ -1,2 +0,2 @@ | ||
var _=Object.create;var b=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var U=Object.getPrototypeOf,B=Object.prototype.hasOwnProperty;var G=(t,e)=>{for(var s in e)b(t,s,{get:e[s],enumerable:!0})},j=(t,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of z(e))!B.call(t,o)&&o!==s&&b(t,o,{get:()=>e[o],enumerable:!(r=W(e,o))||r.enumerable});return t};var h=(t,e,s)=>(s=t!=null?_(U(t)):{},j(e||!t||!t.__esModule?b(s,"default",{value:t,enumerable:!0}):s,t)),V=t=>j(b({},"__esModule",{value:!0}),t);var K={};G(K,{MasterCSSCompiler:()=>m,MasterCSSVitePlugin:()=>N,MasterCSSWebpackPlugin:()=>x});module.exports=V(K);var $=h(require("path")),p=h(require("chalk"));var D=require("@master/css");function R({content:t}){let e=t.match(/[^\s]+/g)??[],s=new Set;for(let r of e){let o=H(r);if(o.size)for(let n of o)s.add(n);else s.add(T(r))}return[...s].filter(r=>r&&!J(r))}var T=t=>{let e=t;return t=t.replace(/^([\w={[(\\]*["'`])/,""),t.match(/^content:((?<!\\)["'`])((?:\\\1|(?:(?!\1))[\S\s])*)((?<!\\)\1)$/)||(t=t.replace(/(\.*|[([{\\:#]*|["'`].*)$/,"")),e===t?t:T(t)},H=t=>{let e=new Set,s=/((?<!\\)["'`])((?:\\\1|(?:(?!\1))[\S\s])*)((?<!\\)\1)/g,r;for(;(r=s.exec(t))!==null;){r.index===s.lastIndex&&s.lastIndex++;let o=H(r[2]);if(o.size)for(let n of o)e.add(n);else e.add(T(r[2]))}return e},J=t=>!t||!t.match(/(?:^[\w-]+:[\w$#]+)|(?:^[@~][\w-]+$)/)&&!Object.keys(D.defaultSemantics).includes(t)||t.match(/\*\*/)||t.match(/:\[/)||t.match(/\$\{/)||t.match(/\{\{/)||t.match(/\(\{[^}]*\}/)||t.match(/<\w+>|<\/\w+>/);var L={output:{name:"master.css",dir:""},accept({name:t}){if(t.match(/[\\/]node_modules[\\/]/))return!1;if(t.match(/\.(html|js|jsx|ts|tsx|svelte|astro|vue)$/i))return!0},extract:R},P=L;var S=h(require("@master/css")),E=require("perf_hooks"),m=class{constructor(e){this.options=e;this.options=(0,S.extend)(P,e);let s;try{s=require($.default.resolve(process.cwd(),e.config||"./master.css.js"))}catch{}this.css=new S.default((0,S.configure)(s))}css;extractions=new Set;extract({name:e,content:s}){if(!e||!s||!this.options.accept?.({content:s,name:e}))return[];let r=[];this.log("accepts",` \u2192 ${$.default.relative(process.cwd(),e)}`);for(let o of this.options.extract({content:s,name:e}))this.extractions.has(o)||(this.extractions.add(o),r.push(o));return r}insert(e){let s=E.performance.now();for(let n of e)this.css.findAndInsert(n);let r=Math.round((E.performance.now()-s)*1e3),o=this.css.rules.map(n=>n.className);console.log(`[Master CSS] process ${p.default.green(e.length)} extractions in ${p.default.green(r)} \xB5s [${p.default.green(this.css.rules.length)} rules in ${p.default.green($.default.join(this.options.output.dir,this.options.output.name))}]`),this.log("extractions",` \u2192 ${p.default.green(e.length)} extractions: ${p.default.blue(e.join(" "))}`),this.log("validClasses",` \u2192 ${p.default.green(o.length)} total valid classes: ${p.default.blue(o.join(" "))}`)}log(e,s){(this.options.debug===!0||Array.isArray(this.options.debug)&&this.options.debug.includes(e))&&console.log(s)}};var F=h(require("path"));var C="MasterCSSWebpackPlugin",x=class extends m{apply(e){let{webpack:s}=e,{Template:r,RuntimeGlobals:o,RuntimeModule:n}=s,{RawSource:w}=s.sources,{Compilation:M}=s,{options:i}=this,l=F.default.join(i.output.dir||"",i.output.name),k=l.replace(/\\/g,"/");e.hooks.thisCompilation.tap(C,a=>{let u=new WeakSet,f=(d,c)=>{u.has(d)||(u.add(d),c.add(o.publicPath),a.addRuntimeModule(d,new A(c)))};a.hooks.runtimeRequirementInTree.for(o.ensureChunkHandlers).tap(C,f),a.hooks.runtimeRequirementInTree.for(o.hmrDownloadUpdateHandlers).tap(C,f);class A extends n{runtimeRequirements;constructor(c){super("master-css-loading",10),this.runtimeRequirements=c}generate(){let{runtimeRequirements:c}=this;return c.has(o.hmrDownloadUpdateHandlers)?r.asString([Date.now().toString(),`const link = document.querySelector('[href*=\\'${k}\\'][rel=stylesheet]')`,"if (link) {",r.indent(["link.href = link.href.replace(/ts=[0-9]+/, 'ts=' + Date.now())"]),"}"]):""}}}),e.hooks.compilation.tap(C,a=>{a.hooks.finishModules.tap(C,u=>{let{modifiedFiles:f,watching:A}=e,d=[];for(let c of u){let g=c.resource,y=c._source?.source();A&&f?.size&&!f.has(g)||d.push(...this.extract({name:g,content:y}))}if(d.length){let c=this.css.text;this.insert(d);let g=this.css.text;if(g!==c){let y=new w(g);a.getAsset(l)?a.updateAsset(l,y):a.emitAsset(l,y)}}}),a.hooks.processAssets.tap({name:C,stage:M.PROCESS_ASSETS_STAGE_ADDITIONS},()=>{a.chunks.forEach(u=>{u.files.add(l)})})})}};var I=h(require("path"));var v=h(require("fs")),q=h(require("path"));function O(t,e,s){let r=q.default.dirname(t);v.default.existsSync(r)||v.default.mkdirSync(r,{recursive:!0}),v.default.writeFileSync(t,e,s)}function N(t){let e=new m(t),s=I.default.join(e.options.output.dir||"",e.options.output.name),r,o,n,w=!1,M=(i,l)=>{let k=e.extract({name:i,content:l});if(k.length){let a=e.css.text;e.insert(k);let u=e.css.text;if(u!==a&&r){O(o,u);let f=()=>{r.ws.send({type:"update",updates:[{path:n,timestamp:Date.now()}]})};w?f():(setTimeout(f,500),w=!0)}}};return{name:"vite-plugin-master-css",enforce:"pre",configureServer(i){r=i},buildStart(){o=I.default.resolve(r?.config.cacheDir??process.cwd(),s),r&&(O(o,""),n=(r.config.cacheDir.slice(process.cwd().length)+"/"+s).replace(/\\/g,"/"))},resolveId(i){if(i.endsWith("master.css?direct"))return"\0"+i},transform(i,l){M(l,i)},transformIndexHtml(i){return i.replace(/(<head>)/,`$1<link rel="stylesheet" href="${n}">`)},async handleHotUpdate(i){M(i.file,await i.read())},generateBundle(){let i=this.emitFile({type:"asset",name:s,source:e.css.text});n="/"+this.getFileName(i)}}}0&&(module.exports={MasterCSSCompiler,MasterCSSVitePlugin,MasterCSSWebpackPlugin}); | ||
var _=Object.create;var b=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var U=Object.getPrototypeOf,B=Object.prototype.hasOwnProperty;var G=(t,e)=>{for(var s in e)b(t,s,{get:e[s],enumerable:!0})},j=(t,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of z(e))!B.call(t,o)&&o!==s&&b(t,o,{get:()=>e[o],enumerable:!(r=W(e,o))||r.enumerable});return t};var h=(t,e,s)=>(s=t!=null?_(U(t)):{},j(e||!t||!t.__esModule?b(s,"default",{value:t,enumerable:!0}):s,t)),V=t=>j(b({},"__esModule",{value:!0}),t);var K={};G(K,{MasterCSSCompiler:()=>m,MasterCSSVitePlugin:()=>N,MasterCSSWebpackPlugin:()=>x});module.exports=V(K);var $=h(require("path"),1),p=h(require("chalk"),1);var D=require("@master/css");function R({content:t}){let e=t.match(/[^\s]+/g)??[],s=new Set;for(let r of e){let o=H(r);if(o.size)for(let n of o)s.add(n);else s.add(T(r))}return[...s].filter(r=>r&&!J(r))}var T=t=>{let e=t;return t=t.replace(/^([\w={[(\\]*["'`])/,""),t.match(/^content:((?<!\\)["'`])((?:\\\1|(?:(?!\1))[\S\s])*)((?<!\\)\1)$/)||(t=t.replace(/(\.*|[([{\\:#]*|["'`].*)$/,"")),e===t?t:T(t)},H=t=>{let e=new Set,s=/((?<!\\)["'`])((?:\\\1|(?:(?!\1))[\S\s])*)((?<!\\)\1)/g,r;for(;(r=s.exec(t))!==null;){r.index===s.lastIndex&&s.lastIndex++;let o=H(r[2]);if(o.size)for(let n of o)e.add(n);else e.add(T(r[2]))}return e},J=t=>!t||!t.match(/(?:^[\w-]+:[\w$#]+)|(?:^[@~][\w-]+$)/)&&!Object.keys(D.defaultSemantics).includes(t)||t.match(/\*\*/)||t.match(/:\[/)||t.match(/\$\{/)||t.match(/\{\{/)||t.match(/\(\{[^}]*\}/)||t.match(/<\w+>|<\/\w+>/);var L={output:{name:"master.css",dir:""},accept({name:t}){if(t.match(/[\\/]node_modules[\\/]/))return!1;if(t.match(/\.(html|js|jsx|ts|tsx|svelte|astro|vue)$/i))return!0},extract:R},P=L;var S=h(require("@master/css"),1),E=require("perf_hooks"),m=class{constructor(e){this.options=e;this.options=(0,S.extend)(P,e);let s;try{s=require($.default.resolve(process.cwd(),e.config||"./master.css.js"))}catch{}this.css=new S.default((0,S.configure)(s))}css;extractions=new Set;extract({name:e,content:s}){if(!e||!s||!this.options.accept?.({content:s,name:e}))return[];let r=[];this.log("accepts",` \u2192 ${$.default.relative(process.cwd(),e)}`);for(let o of this.options.extract({content:s,name:e}))this.extractions.has(o)||(this.extractions.add(o),r.push(o));return r}insert(e){let s=E.performance.now();for(let n of e)this.css.findAndInsert(n);let r=Math.round((E.performance.now()-s)*1e3),o=this.css.rules.map(n=>n.className);console.log(`[Master CSS] process ${p.default.green(e.length)} extractions in ${p.default.green(r)} \xB5s [${p.default.green(this.css.rules.length)} rules in ${p.default.green($.default.join(this.options.output.dir,this.options.output.name))}]`),this.log("extractions",` \u2192 ${p.default.green(e.length)} extractions: ${p.default.blue(e.join(" "))}`),this.log("validClasses",` \u2192 ${p.default.green(o.length)} total valid classes: ${p.default.blue(o.join(" "))}`)}log(e,s){(this.options.debug===!0||Array.isArray(this.options.debug)&&this.options.debug.includes(e))&&console.log(s)}};var F=h(require("path"),1);var C="MasterCSSWebpackPlugin",x=class extends m{apply(e){let{webpack:s}=e,{Template:r,RuntimeGlobals:o,RuntimeModule:n}=s,{RawSource:w}=s.sources,{Compilation:M}=s,{options:i}=this,l=F.default.join(i.output.dir||"",i.output.name),k=l.replace(/\\/g,"/");e.hooks.thisCompilation.tap(C,a=>{let u=new WeakSet,f=(d,c)=>{u.has(d)||(u.add(d),c.add(o.publicPath),a.addRuntimeModule(d,new A(c)))};a.hooks.runtimeRequirementInTree.for(o.ensureChunkHandlers).tap(C,f),a.hooks.runtimeRequirementInTree.for(o.hmrDownloadUpdateHandlers).tap(C,f);class A extends n{runtimeRequirements;constructor(c){super("master-css-loading",10),this.runtimeRequirements=c}generate(){let{runtimeRequirements:c}=this;return c.has(o.hmrDownloadUpdateHandlers)?r.asString([Date.now().toString(),`const link = document.querySelector('[href*=\\'${k}\\'][rel=stylesheet]')`,"if (link) {",r.indent(["link.href = link.href.replace(/ts=[0-9]+/, 'ts=' + Date.now())"]),"}"]):""}}}),e.hooks.compilation.tap(C,a=>{a.hooks.finishModules.tap(C,u=>{let{modifiedFiles:f,watching:A}=e,d=[];for(let c of u){let g=c.resource,y=c._source?.source();A&&f?.size&&!f.has(g)||d.push(...this.extract({name:g,content:y}))}if(d.length){let c=this.css.text;this.insert(d);let g=this.css.text;if(g!==c){let y=new w(g);a.getAsset(l)?a.updateAsset(l,y):a.emitAsset(l,y)}}}),a.hooks.processAssets.tap({name:C,stage:M.PROCESS_ASSETS_STAGE_ADDITIONS},()=>{a.chunks.forEach(u=>{u.files.add(l)})})})}};var I=h(require("path"),1);var O=h(require("fs"),1),q=h(require("path"),1);function v(t,e,s){let r=q.default.dirname(t);O.default.existsSync(r)||O.default.mkdirSync(r,{recursive:!0}),O.default.writeFileSync(t,e,s)}function N(t){let e=new m(t),s=I.default.join(e.options.output.dir||"",e.options.output.name),r,o,n,w=!1,M=(i,l)=>{let k=e.extract({name:i,content:l});if(k.length){let a=e.css.text;e.insert(k);let u=e.css.text;if(u!==a&&r){v(o,u);let f=()=>{r.ws.send({type:"update",updates:[{path:n,timestamp:Date.now()}]})};w?f():(setTimeout(f,500),w=!0)}}};return{name:"vite-plugin-master-css",enforce:"pre",configureServer(i){r=i},buildStart(){o=I.default.resolve(r?.config.cacheDir??process.cwd(),s),r&&(v(o,""),n=(r.config.cacheDir.slice(process.cwd().length)+"/"+s).replace(/\\/g,"/"))},resolveId(i){if(i.endsWith("master.css?direct"))return"\0"+i},transform(i,l){M(l,i)},transformIndexHtml(i){return i.replace(/(<head>)/,`$1<link rel="stylesheet" href="${n}">`)},async handleHotUpdate(i){M(i.file,await i.read())},generateBundle(){let i=this.emitFile({type:"asset",name:s,source:e.css.text});n="/"+this.getFileName(i)}}}0&&(module.exports={MasterCSSCompiler,MasterCSSVitePlugin,MasterCSSWebpackPlugin}); | ||
//# sourceMappingURL=index.cjs.js.map |
@@ -26,19 +26,21 @@ { | ||
"build:cjs": "esbuild src/index.ts --bundle --outfile=dist/index.cjs.js --format=cjs --platform=node --external:@master/css --external:chalk", | ||
"build:esm": "tsc", | ||
"build:esm": "esbuild src/index.ts --bundle --outfile=dist/index.esm.js --format=esm --platform=node --external:@master/css --external:chalk", | ||
"dev:cjs": "npm run build:cjs -- --watch", | ||
"dev:esm": "npm run build:esm -- --watch", | ||
"prod": "rm -rf dist && npm run build:cjs -- --minify --sourcemap && npm run build:esm", | ||
"prod": "rm -rf dist && npm run build:cjs -- --minify --sourcemap && npm run build:esm -- --minify --sourcemap && tsc --emitDeclarationOnly", | ||
"test": "jest", | ||
"lint": "eslint ./src" | ||
}, | ||
"type": "module", | ||
"main": "./dist/index.cjs.js", | ||
"jsnext:main": "./dist/index.esm.js", | ||
"browser": "./dist/index.browser.js", | ||
"esnext": "./dist/esm/index.js", | ||
"module": "./dist/esm/index.js", | ||
"types": "./dist/esm/index.d.ts", | ||
"esnext": "./dist/index.esm.js", | ||
"module": "./dist/index.esm.js", | ||
"types": "./dist/index.d.ts", | ||
"exports": { | ||
".": { | ||
"require": "./dist/index.cjs.js", | ||
"import": "./dist/esm/index.js", | ||
"types": "./dist/esm/index.d.ts" | ||
"import": "./dist/index.esm.js", | ||
"types": "./dist/index.d.ts" | ||
} | ||
@@ -141,3 +143,3 @@ }, | ||
"peerDependencies": { | ||
"@master/css": "^2.0.0-beta" | ||
"@master/css": "^2.0.0-beta.8" | ||
}, | ||
@@ -147,3 +149,3 @@ "dependencies": { | ||
}, | ||
"version": "2.0.0-beta.7" | ||
"version": "2.0.0-beta.8" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
66722
Yes
15
88
8
1