@master/css-compiler 2.0.0-beta.5 → 2.0.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{esm → dist/esm}/compiler.d.ts +0 -0
- package/{esm → dist/esm}/compiler.js +0 -0
- package/{esm → dist/esm}/compiler.js.map +0 -0
- package/{esm → dist/esm}/index.d.ts +0 -0
- package/{esm → dist/esm}/index.js +0 -0
- package/{esm → dist/esm}/index.js.map +0 -0
- package/{esm → dist/esm}/options/extract.d.ts +0 -0
- package/{esm → dist/esm}/options/extract.js +0 -0
- package/{esm → dist/esm}/options/extract.js.map +0 -0
- package/{esm → dist/esm}/options/index.d.ts +0 -0
- package/{esm → dist/esm}/options/index.js +0 -0
- package/{esm → dist/esm}/options/index.js.map +0 -0
- package/{esm → dist/esm}/utils/write-file.d.ts +0 -0
- package/{esm → dist/esm}/utils/write-file.js +0 -0
- package/{esm → dist/esm}/utils/write-file.js.map +0 -0
- package/{esm → dist/esm}/vite.d.ts +0 -0
- package/{esm → dist/esm}/vite.js +0 -0
- package/{esm → dist/esm}/vite.js.map +0 -0
- package/{esm → dist/esm}/webpack.d.ts +0 -0
- package/{esm → dist/esm}/webpack.js +0 -0
- package/{esm → dist/esm}/webpack.js.map +0 -0
- package/dist/index.cjs.js +2 -0
- package/{index.js.map → dist/index.cjs.js.map} +1 -1
- package/package.json +101 -27
- package/readme.md +80 -0
- package/index.js +0 -2
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/{esm → dist/esm}/vite.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
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});
|
|
2
|
+
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts", "../src/compiler.ts", "../src/options/extract.ts", "../src/options/index.ts", "../src/webpack.ts", "../src/vite.ts", "../src/utils/write-file.ts"],
|
|
4
4
|
"sourcesContent": ["\nexport { default as MasterCSSCompiler } from './compiler'\nexport { default as MasterCSSWebpackPlugin } from './webpack'\nexport { default as MasterCSSVitePlugin } from './vite'\n", "import path from 'path'\nimport chalk from 'chalk'\nimport defaultOptions, { MasterCSSCompilerOptions, MasterCSSCompilerSource } from './options'\nimport MasterCSS, { configure, extend } from '@master/css'\nimport { performance } from 'perf_hooks'\nimport type { MasterCSSConfig } from '@master/css'\n\nexport default class MasterCSSCompiler {\n\n constructor(\n public options: Partial<MasterCSSCompilerOptions>\n ) {\n this.options = extend(defaultOptions, options)\n let userConfig: MasterCSSConfig\n try {\n userConfig = require(path.resolve(process.cwd(), options.config || './master.css.js'))\n // eslint-disable-next-line no-empty\n } catch (err) { }\n this.css = new MasterCSS(configure(userConfig))\n }\n\n css: MasterCSS\n extractions = new Set<string>()\n\n extract({ name, content }: MasterCSSCompilerSource) {\n if (\n !name || !content\n || !this.options.accept?.({ content, name })\n ) {\n return []\n }\n const eachExtractions: string[] = []\n\n this.log('accepts', ` \u2192 ${path.relative(process.cwd(), name)}`)\n\n for (const eachNewExtraction of this.options.extract({ content, name })) {\n if (this.extractions.has(eachNewExtraction)) {\n continue\n } else {\n this.extractions.add(eachNewExtraction)\n eachExtractions.push(eachNewExtraction)\n }\n }\n return eachExtractions\n }\n\n insert(extractions) {\n const p1 = performance.now()\n\n /* \u6839\u64DA\u985E\u540D\u5C0B\u627E\u4E26\u63D2\u5165\u898F\u5247 ( MasterCSS \u672C\u8EAB\u5E36\u6709\u5FEB\u53D6\u6A5F\u5236\uFF0C\u91CD\u8907\u7684\u985E\u540D\u4E0D\u6703\u518D\u7DE8\u8B6F\u53CA\u7522\u751F ) */\n for (const eachExtraction of extractions) {\n this.css.findAndInsert(eachExtraction)\n }\n\n const spent = Math.round((performance.now() - p1) * 1000)\n const validClasses = this.css.rules.map((rule) => rule.className)\n\n /* \u5370\u51FA Master CSS \u7DE8\u8B6F\u6642\u9593 */\n console.log(`[Master CSS] process ${chalk.green(extractions.length)} extractions in ${chalk.green(spent)} \u00B5s [${chalk.green(this.css.rules.length)} rules in ${chalk.green(path.join(this.options.output.dir, this.options.output.name))}]`)\n\n this.log('extractions', ` \u2192 ${chalk.green(extractions.length)} extractions: ${chalk.blue(extractions.join(' '))}`)\n this.log('validClasses', ` \u2192 ${chalk.green(validClasses.length)} total valid classes: ${chalk.blue(validClasses.join(' '))}`)\n }\n\n log(name, content) {\n if (this.options.debug === true || Array.isArray(this.options.debug) && this.options.debug.includes(name)) {\n console.log(content)\n }\n }\n}", "import { defaultSemantics } from '@master/css'\nimport type { MasterCSSCompilerSource } from './index'\n\nexport default function extract({ content }: MasterCSSCompilerSource) {\n const blocks = content.match(/[^\\s]+/g) ?? []\n const strings = new Set<string>()\n for (const block of blocks) {\n const result = peelString(block)\n if (result.size) {\n for (const string of result) {\n strings.add(string)\n }\n } else {\n strings.add(trimString(block))\n }\n }\n return [...strings].filter(x => x && !checkToExclude(x))\n}\n\nconst trimString = (content) => {\n const originContent = content\n content = content.replace(/^([\\w={[(\\\\]*[\"'`])/, '')\n if (!content.match(/^content:((?<!\\\\)[\"'`])((?:\\\\\\1|(?:(?!\\1))[\\S\\s])*)((?<!\\\\)\\1)$/)) {\n content = content.replace(/(\\.*|[([{\\\\:#]*|[\"'`].*)$/, '')\n }\n if (originContent === content) {\n return content\n } else {\n return trimString(content)\n }\n}\n\nconst peelString = (content) => {\n const strings = new Set<string>()\n const stringRegx = /((?<!\\\\)[\"'`])((?:\\\\\\1|(?:(?!\\1))[\\S\\s])*)((?<!\\\\)\\1)/g\n let m\n while ((m = stringRegx.exec(content)) !== null) {\n if (m.index === stringRegx.lastIndex) {\n stringRegx.lastIndex++\n }\n const result = peelString(m[2])\n if (result.size) {\n for (const string of result) {\n strings.add(string)\n }\n } else {\n strings.add(trimString(m[2]))\n }\n }\n return strings\n}\n\nconst checkToExclude = (content) => {\n return !content\n || (!content.match(/(?:^[\\w-]+:[\\w$#]+)|(?:^[@~][\\w-]+$)/) && !Object.keys(defaultSemantics).includes(content))\n || content.match(/\\*\\*/)\n || content.match(/:\\[/)\n || content.match(/\\$\\{/)\n || content.match(/\\{\\{/)\n || content.match(/\\(\\{[^}]*\\}/)\n || content.match(/<\\w+>|<\\/\\w+>/)\n}", "import extract from './extract'\n\nconst defaultOptions: MasterCSSCompilerOptions = {\n output: {\n name: 'master.css',\n dir: ''\n },\n accept({ name }) {\n if (name.match(/[\\\\/]node_modules[\\\\/]/)) {\n return false\n }\n if (name.match(/\\.(html|js|jsx|ts|tsx|svelte|astro|vue)$/i)) {\n return true\n }\n },\n extract\n}\n\nexport declare type MasterCSSCompilerSource = {\n name: string\n content: string\n}\n\nexport interface MasterCSSCompilerOptions {\n output?: {\n name: string\n dir: string\n },\n accept?: (source: MasterCSSCompilerSource) => boolean\n extract?: (source: MasterCSSCompilerSource) => string[]\n config?: string\n debug?: string[] | boolean\n}\n\nexport default defaultOptions", "import path from 'path'\nimport MasterCSSCompiler from './compiler'\nimport type { Compiler } from 'webpack'\n\nconst NAME = 'MasterCSSWebpackPlugin'\n\nexport default class MasterCSSWebpackPlugin extends MasterCSSCompiler {\n\n apply(compiler: Compiler) {\n const { webpack } = compiler\n const { Template, RuntimeGlobals, RuntimeModule } = webpack\n const { RawSource } = webpack.sources\n const { Compilation } = webpack\n const { options } = this\n const outputPath = path.join(options.output.dir || '', options.output.name)\n const linkHref = outputPath.replace(/\\\\/g, '/')\n\n compiler.hooks.thisCompilation.tap(NAME, (compilation) => {\n\n const enabledChunks = new WeakSet()\n\n const handler = (chunk, set) => {\n if (enabledChunks.has(chunk))\n return\n\n enabledChunks.add(chunk)\n\n set.add(RuntimeGlobals.publicPath)\n\n compilation.addRuntimeModule(chunk, new CssLoadingRuntimeModule(set))\n }\n\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.ensureChunkHandlers)\n .tap(NAME, handler)\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.hmrDownloadUpdateHandlers)\n .tap(NAME, handler)\n\n class CssLoadingRuntimeModule extends RuntimeModule {\n\n runtimeRequirements: Set<string>\n\n constructor(runtimeRequirements: Set<string>) {\n super('master-css-loading', 10)\n\n this.runtimeRequirements = runtimeRequirements\n }\n\n generate() {\n const { runtimeRequirements } = this\n const withHmr = runtimeRequirements.has(RuntimeGlobals.hmrDownloadUpdateHandlers)\n if (!withHmr)\n return ''\n\n return Template.asString([\n Date.now().toString(),\n `const link = document.querySelector('[href*=\\\\'${linkHref}\\\\'][rel=stylesheet]')`,\n 'if (link) {',\n Template.indent([\n 'link.href = link.href.replace(/ts=[0-9]+/, \\'ts=\\' + Date.now())'\n ]),\n '}'\n ])\n }\n }\n })\n\n compiler.hooks.compilation.tap(NAME, (compilation) => {\n // \u589E\u52A0\u984D\u5916\u7684 `master.css` assets\n compilation.hooks.finishModules.tap(NAME, (modules) => {\n const { modifiedFiles, watching } = compiler\n const eachExtractions: string[] = []\n\n for (const eachModule of modules) {\n const name = eachModule['resource']\n // \u5F9E\u8A18\u61B6\u9AD4\u6216\u5FEB\u53D6\u53D6\u5F97\u7576\u524D module \u7684\u539F\u59CB\u78BC\n const content = eachModule['_source']?.source()\n // \u5728 watch \u6A21\u5F0F\u4E0B\u50C5\u8655\u7406\u7576\u4E0B\u8B8A\u66F4\u7684\u6A94\u6848\n if (watching && modifiedFiles?.size && !modifiedFiles.has(name)) { continue }\n eachExtractions.push(...this.extract({ name, content }))\n }\n\n if (eachExtractions.length) {\n const originalCssText = this.css.text\n /* \u6BD4\u5C0D\u63D0\u53D6\u7269\u4E26\u63D2\u5165 CSS \u898F\u5247 */\n this.insert(eachExtractions)\n /* \u6839\u64DA cssText \u751F\u6210 `master.css` \u4E26\u52A0\u5165\u5230 Webpack \u7684 assets \u4E2D */\n const cssText = this.css.text\n if (cssText !== originalCssText) {\n const newSource = new RawSource(cssText)\n if (compilation.getAsset(outputPath)) {\n compilation.updateAsset(outputPath, newSource)\n } else {\n compilation.emitAsset(outputPath, newSource)\n }\n }\n }\n })\n\n compilation.hooks.processAssets.tap({\n name: NAME,\n stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,\n }, () => {\n compilation.chunks.forEach((chunk) => {\n chunk.files.add(outputPath)\n })\n })\n })\n }\n}\n", "import MasterCSSCompiler from './compiler'\nimport path from 'path'\nimport writeFile from './utils/write-file'\nimport type { MasterCSSCompilerOptions } from './options'\nimport type { PluginOption } from 'vite'\n\nexport default function (options?: MasterCSSCompilerOptions): PluginOption {\n const compiler = new MasterCSSCompiler(options)\n const outputPath = path.join(compiler.options.output.dir || '', compiler.options.output.name)\n\n let server\n let outputFilePath: string\n let linkHref: string\n let rendered = false\n\n const extract = (name, content) => {\n const eachExtractions = compiler.extract({ name, content })\n if (eachExtractions.length) {\n const originalCssText = compiler.css.text\n /* \u6BD4\u5C0D\u63D0\u53D6\u7269\u4E26\u63D2\u5165 CSS \u898F\u5247 */\n compiler.insert(eachExtractions)\n /* \u6839\u64DA cssText \u751F\u6210 `master.css` \u4E26\u52A0\u5165\u5230 Webpack \u7684 assets \u4E2D */\n const cssText = compiler.css.text\n if (cssText !== originalCssText) {\n if (server) {\n writeFile(outputFilePath, cssText)\n\n const notify = () => {\n server.ws.send({\n type: 'update',\n updates: [{\n path: linkHref,\n timestamp: Date.now()\n }]\n })\n }\n\n if (rendered) {\n notify()\n } else {\n setTimeout(notify, 500)\n\n rendered = true\n }\n }\n }\n }\n }\n\n return {\n name: 'vite-plugin-master-css',\n enforce: 'pre',\n configureServer(_server) {\n server = _server\n },\n buildStart() {\n outputFilePath = path.resolve(server?.config.cacheDir ?? process.cwd(), outputPath)\n if (server) {\n writeFile(outputFilePath, '')\n\n linkHref = (server.config.cacheDir.slice(process.cwd().length) + '/' + outputPath).replace(/\\\\/g, '/')\n }\n },\n resolveId(source) {\n if (source.endsWith('master.css?direct'))\n return '\\0' + source\n },\n transform(code, id) {\n extract(id, code)\n },\n transformIndexHtml(html) {\n return html.replace(\n /(<head>)/,\n `$1<link rel=\"stylesheet\" href=\"${linkHref}\">`\n )\n },\n async handleHotUpdate(hmrContext) {\n extract(hmrContext.file, await hmrContext.read())\n },\n generateBundle() {\n const referenceId = this.emitFile({\n type: 'asset',\n name: outputPath,\n source: compiler.css.text\n })\n linkHref = '/' + this.getFileName(referenceId)\n }\n }\n}", "import fs from 'fs'\nimport path from 'path'\n\nexport default function writeFile(filePath: string, data: string | NodeJS.ArrayBufferView, options?: fs.WriteFileOptions) {\n const dirname = path.dirname(filePath)\n if (!fs.existsSync(dirname)) {\n fs.mkdirSync(dirname, { recursive: true })\n }\n fs.writeFileSync(filePath, data, options)\n\n}\n"],
|
|
5
|
-
"mappings": "6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,EAAA,wBAAAC,EAAA,2BAAAC,IAAA,eAAAC,EAAAL,GCAA,IAAAM,EAAiB,
|
|
5
|
+
"mappings": "6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,EAAA,wBAAAC,EAAA,2BAAAC,IAAA,eAAAC,EAAAL,GCAA,IAAAM,EAAiB,mBACjBC,EAAkB,oBCDlB,IAAAC,EAAiC,uBAGlB,SAARC,EAAyB,CAAE,QAAAC,CAAQ,EAA4B,CAClE,IAAMC,EAASD,EAAQ,MAAM,SAAS,GAAK,CAAC,EACtCE,EAAU,IAAI,IACpB,QAAWC,KAASF,EAAQ,CACxB,IAAMG,EAASC,EAAWF,CAAK,EAC/B,GAAIC,EAAO,KACP,QAAWE,KAAUF,EACjBF,EAAQ,IAAII,CAAM,OAGtBJ,EAAQ,IAAIK,EAAWJ,C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,EAC9EE,IACAU,EAAUT,EAAgB,EAAE,EAE5BC,GAAYF,EAAO,OAAO,SAAS,MAAM,QAAQ,IAAI,EAAE,MAAM,EAAI,IAAMF,GAAY,QAAQ,MAAO,GAAG,EAE7G,EACA,UAAUe,EAAQ,CACd,GAAIA,EAAO,SAAS,mBAAmB,EACnC,MAAO,KAAOA,CACtB,EACA,UAAUC,EAAMC,EAAI,CAChBX,EAAQW,EAAID,CAAI,CACpB,EACA,mBAAmBE,EAAM,CACrB,OAAOA,EAAK,QACR,WACA,kCAAkCd,KACtC,CACJ,EACA,MAAM,gBAAgBe,EAAY,CAC9Bb,EAAQa,EAAW,KAAM,MAAMA,EAAW,KAAK,CAAC,CACpD,EACA,gBAAiB,CACb,IAAMC,EAAc,KAAK,SAAS,CAC9B,KAAM,QACN,KAAMpB,EACN,OAAQF,EAAS,IAAI,IACzB,CAAC,EACDM,EAAW,IAAM,KAAK,YAAYgB,CAAW,CACjD,CACJ,CACJ",
|
|
6
6
|
"names": ["src_exports", "__export", "MasterCSSCompiler", "vite_default", "MasterCSSWebpackPlugin", "__toCommonJS", "import_path", "import_chalk", "import_css", "extract", "content", "blocks", "strings", "block", "result", "peelString", "string", "trimString", "x", "checkToExclude", "originContent", "stringRegx", "m", "defaultOptions", "name", "extract", "options_default", "import_css", "import_perf_hooks", "MasterCSSCompiler", "options", "options_default", "userConfig", "path", "MasterCSS", "name", "content", "eachExtractions", "eachNewExtraction", "extractions", "p1", "eachExtraction", "spent", "validClasses", "rule", "chalk", "import_path", "NAME", "MasterCSSWebpackPlugin", "MasterCSSCompiler", "compiler", "webpack", "Template", "RuntimeGlobals", "RuntimeModule", "RawSource", "Compilation", "options", "outputPath", "path", "linkHref", "compilation", "enabledChunks", "handler", "chunk", "set", "CssLoadingRuntimeModule", "runtimeRequirements", "modules", "modifiedFiles", "watching", "eachExtractions", "eachModule", "name", "content", "originalCssText", "cssText", "newSource", "import_path", "import_fs", "import_path", "writeFile", "filePath", "data", "options", "dirname", "path", "fs", "vite_default", "options", "compiler", "MasterCSSCompiler", "outputPath", "path", "server", "outputFilePath", "linkHref", "rendered", "extract", "name", "content", "eachExtractions", "originalCssText", "cssText", "writeFile", "notify", "_server", "source", "code", "id", "html", "hmrContext", "referenceId"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -3,21 +3,12 @@
|
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"description": "Compile Master CSS ahead of time with zero-configuration integration with build tools",
|
|
5
5
|
"author": "Aoyue Design LLC.",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"main": "index.js",
|
|
8
|
-
"module": "esm/index.js",
|
|
9
|
-
"types": "esm/index.d.ts",
|
|
10
|
-
"exports": {
|
|
11
|
-
".": {
|
|
12
|
-
"require": "./index.js",
|
|
13
|
-
"import": "./esm/index.js",
|
|
14
|
-
"types": "./esm/index.d.ts"
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
"sideEffects": false,
|
|
18
6
|
"funding": "https://docs.master.co/css/donate",
|
|
19
7
|
"homepage": "https://css.master.co",
|
|
20
|
-
"
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/master-co/css-compiler.git"
|
|
11
|
+
},
|
|
21
12
|
"keywords": [
|
|
22
13
|
"webpack",
|
|
23
14
|
"plugin",
|
|
@@ -29,15 +20,9 @@
|
|
|
29
20
|
"mastercss",
|
|
30
21
|
"vite-plugin"
|
|
31
22
|
],
|
|
32
|
-
"
|
|
33
|
-
"type": "git",
|
|
34
|
-
"url": "https://github.com/master-co/css-compiler.git"
|
|
35
|
-
},
|
|
36
|
-
"peerDependencies": {
|
|
37
|
-
"@master/css": "^2.0.0-beta.2"
|
|
38
|
-
},
|
|
23
|
+
"sideEffects": false,
|
|
39
24
|
"scripts": {
|
|
40
|
-
"build:cjs": "esbuild src/index.ts --outfile=dist/index.js --
|
|
25
|
+
"build:cjs": "esbuild src/index.ts --bundle --outfile=dist/index.cjs.js --format=cjs --platform=node --external:@master/css --external:chalk",
|
|
41
26
|
"build:esm": "tsc",
|
|
42
27
|
"dev:cjs": "npm run build:cjs -- --watch",
|
|
43
28
|
"dev:esm": "npm run build:esm -- --watch",
|
|
@@ -45,28 +30,117 @@
|
|
|
45
30
|
"test": "jest",
|
|
46
31
|
"lint": "eslint ./src"
|
|
47
32
|
},
|
|
33
|
+
"main": "./dist/index.cjs.js",
|
|
34
|
+
"browser": "./dist/index.browser.js",
|
|
35
|
+
"esnext": "./dist/esm/index.js",
|
|
36
|
+
"module": "./dist/esm/index.js",
|
|
37
|
+
"types": "./dist/esm/index.d.ts",
|
|
38
|
+
"exports": {
|
|
39
|
+
".": {
|
|
40
|
+
"require": "./dist/index.cjs.js",
|
|
41
|
+
"import": "./dist/esm/index.js",
|
|
42
|
+
"types": "./dist/esm/index.d.ts"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"jest": {
|
|
46
|
+
"testEnvironment": "node",
|
|
47
|
+
"transform": {
|
|
48
|
+
"^.+\\.(t|j)sx?$": "@swc/jest"
|
|
49
|
+
},
|
|
50
|
+
"testMatch": [
|
|
51
|
+
"<rootDir>/tests/*.ts",
|
|
52
|
+
"<rootDir>/src/**/*.test.ts"
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
"private": false,
|
|
56
|
+
"publishConfig": {
|
|
57
|
+
"access": "public"
|
|
58
|
+
},
|
|
59
|
+
"engines": {
|
|
60
|
+
"node": ">=14"
|
|
61
|
+
},
|
|
62
|
+
"release": {
|
|
63
|
+
"plugins": [
|
|
64
|
+
[
|
|
65
|
+
"@semantic-release/commit-analyzer",
|
|
66
|
+
{
|
|
67
|
+
"preset": "angular",
|
|
68
|
+
"releaseRules": [
|
|
69
|
+
{
|
|
70
|
+
"type": "docs",
|
|
71
|
+
"scope": "README",
|
|
72
|
+
"release": "patch"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"type": "refactor",
|
|
76
|
+
"release": "patch"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"type": "style",
|
|
80
|
+
"release": "patch"
|
|
81
|
+
}
|
|
82
|
+
],
|
|
83
|
+
"parserOpts": {
|
|
84
|
+
"noteKeywords": [
|
|
85
|
+
"BREAKING CHANGE",
|
|
86
|
+
"BREAKING CHANGES"
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
],
|
|
91
|
+
"@semantic-release/release-notes-generator",
|
|
92
|
+
[
|
|
93
|
+
"@semantic-release/exec",
|
|
94
|
+
{
|
|
95
|
+
"prepareCmd": "npm run prod"
|
|
96
|
+
}
|
|
97
|
+
],
|
|
98
|
+
[
|
|
99
|
+
"@semantic-release/github"
|
|
100
|
+
],
|
|
101
|
+
[
|
|
102
|
+
"@semantic-release/npm"
|
|
103
|
+
]
|
|
104
|
+
],
|
|
105
|
+
"branches": [
|
|
106
|
+
"+([0-9])?(.{+([0-9]),x}).x",
|
|
107
|
+
"main",
|
|
108
|
+
"next",
|
|
109
|
+
"next-major",
|
|
110
|
+
{
|
|
111
|
+
"name": "beta",
|
|
112
|
+
"prerelease": true
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"name": "alpha",
|
|
116
|
+
"prerelease": true
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
},
|
|
120
|
+
"files": [
|
|
121
|
+
"dist"
|
|
122
|
+
],
|
|
48
123
|
"devDependencies": {
|
|
49
124
|
"@semantic-release/exec": "^6.0.3",
|
|
50
125
|
"@swc/core": "^1.3.9",
|
|
51
126
|
"@swc/jest": "^0.2.23",
|
|
52
|
-
"@types/jest": "^
|
|
127
|
+
"@types/jest": "^29.2.0",
|
|
53
128
|
"@types/node": "^18.11.0",
|
|
54
129
|
"@types/webpack": "^5.28.0",
|
|
55
130
|
"@typescript-eslint/eslint-plugin": "^5.40.1",
|
|
56
131
|
"@typescript-eslint/parser": "^5.40.1",
|
|
57
132
|
"esbuild": "^0.15.10",
|
|
58
133
|
"eslint": "^8.25.0",
|
|
59
|
-
"jest": "^
|
|
134
|
+
"jest": "^29.2.2",
|
|
60
135
|
"semantic-release": "^19.0.5",
|
|
61
|
-
"ts-jest": "^28.0.3",
|
|
62
136
|
"typescript": "^4.8.4",
|
|
63
137
|
"vite": "^3.1.8"
|
|
64
138
|
},
|
|
65
|
-
"
|
|
66
|
-
"
|
|
139
|
+
"peerDependencies": {
|
|
140
|
+
"@master/css": "^2.0.0-beta"
|
|
67
141
|
},
|
|
68
142
|
"dependencies": {
|
|
69
143
|
"chalk": "^5.1.2"
|
|
70
144
|
},
|
|
71
|
-
"version": "2.0.0-beta.
|
|
145
|
+
"version": "2.0.0-beta.7"
|
|
72
146
|
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
<br><br>
|
|
2
|
+
<div align="center">
|
|
3
|
+
|
|
4
|
+
<p align="center">
|
|
5
|
+
<img src="https://raw.githubusercontent.com/master-co/package/document/images/logo-and-text.svg" alt="logo" width="142">
|
|
6
|
+
</p>
|
|
7
|
+
<p align="center">
|
|
8
|
+
<b><!-- name -->CSS Compiler<!----></b>
|
|
9
|
+
</p>
|
|
10
|
+
<p align="center"><!-- package.description -->Compile Master CSS ahead of time with zero-configuration integration with build tools<!----></p>
|
|
11
|
+
|
|
12
|
+
[](https://github.com/master-co/css-compiler/blob/main/LICENSE)
|
|
13
|
+
[](https://www.npmjs.com/package/@master/css-compiler)
|
|
14
|
+
[](https://css.master.co)
|
|
15
|
+
[](https://github.com/master-co/css)
|
|
16
|
+
[](https://discord.gg/sZNKpAAAw6)
|
|
17
|
+
[](https://circleci.com/gh/master-co/workflows/css-compiler/tree/main)
|
|
18
|
+
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
##### On this page
|
|
22
|
+
|
|
23
|
+
- [Usage](#usage)
|
|
24
|
+
- [`webpack.config.js`](#webpackconfigjs)
|
|
25
|
+
- [`vite.config.js`](#viteconfigjs)
|
|
26
|
+
- [`next.config.js`](#nextconfigjs)
|
|
27
|
+
- [Related](#related)
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
# Usage
|
|
32
|
+
|
|
33
|
+
## `webpack.config.js`
|
|
34
|
+
```js
|
|
35
|
+
const { MasterCSSWebpackPlugin } = require('@master/css-compiler')
|
|
36
|
+
|
|
37
|
+
module.exports = {
|
|
38
|
+
plugins: [
|
|
39
|
+
new MasterCSSWebpackPlugin()
|
|
40
|
+
]
|
|
41
|
+
};
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## `vite.config.js`
|
|
45
|
+
```js
|
|
46
|
+
import { MasterCSSVitePlugin } from '@master/css-compiler'
|
|
47
|
+
|
|
48
|
+
export default defineConfig({
|
|
49
|
+
plugins: [
|
|
50
|
+
MasterCSSVitePlugin()
|
|
51
|
+
]
|
|
52
|
+
})
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## `next.config.js`
|
|
56
|
+
```js
|
|
57
|
+
const { MasterCSSWebpackPlugin } = require('@master/css-compiler')
|
|
58
|
+
|
|
59
|
+
const nextConfig = {
|
|
60
|
+
...,
|
|
61
|
+
webpack: (config) => {
|
|
62
|
+
config.plugins.push(
|
|
63
|
+
new MasterCSSWebpackPlugin({
|
|
64
|
+
output: {
|
|
65
|
+
path: 'static/css'
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
)
|
|
69
|
+
return config
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
module.exports = nextConfig
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
# Related
|
|
79
|
+
- [@master/css](https://github.com/master-co/css) - A Virtual CSS language with enhanced syntax. ( ~13KB )
|
|
80
|
+
- [@master/css.react](https://github.com/master-co/css.react) - React hooks for Master CSS
|
package/index.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
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 v=h(require("fs"),1),q=h(require("path"),1);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});
|
|
2
|
-
//# sourceMappingURL=index.js.map
|