@master/css-compiler 2.0.0-beta.14 → 2.0.0-beta.16
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/dist/compiler.d.ts +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +2 -2
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +3 -3
- package/dist/vite.d.ts +2 -2
- package/dist/webpack.d.ts +1 -1
- package/package.json +2 -2
package/dist/compiler.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import MasterCSS from '@master/css';
|
|
|
3
3
|
export default class MasterCSSCompiler {
|
|
4
4
|
options?: MasterCSSCompilerOptions;
|
|
5
5
|
constructor(options?: MasterCSSCompilerOptions);
|
|
6
|
+
initializing: Promise<any>;
|
|
6
7
|
css: MasterCSS;
|
|
7
8
|
extractions: Set<string>;
|
|
8
9
|
extract({ name, content }: MasterCSSCompilerSource): string[];
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var N=Object.create;var k=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var U=Object.getPrototypeOf,B=Object.prototype.hasOwnProperty;var G=(t,e)=>{for(var s in e)k(t,s,{get:e[s],enumerable:!0})},P=(t,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of W(e))!B.call(t,i)&&i!==s&&k(t,i,{get:()=>e[i],enumerable:!(r=_(e,i))||r.enumerable});return t};var h=(t,e,s)=>(s=t!=null?N(U(t)):{},P(e||!t||!t.__esModule?k(s,"default",{value:t,enumerable:!0}):s,t)),V=t=>P(k({},"__esModule",{value:!0}),t);var K={};G(K,{MasterCSSCompiler:()=>m,MasterCSSVitePlugin:()=>z,MasterCSSWebpackPlugin:()=>C});module.exports=V(K);var b=h(require("path")),p=h(require("chalk"));var j=require("@master/css");function R({content:t}){let e=t.match(/[^\s]+/g)??[],s=new Set;for(let r of e){let i=D(r);if(i.size)for(let n of i)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)},D=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 i=D(r[2]);if(i.size)for(let n of i)e.add(n);else e.add(T(r[2]))}return e},J=t=>!t||!t.match(/(?:^[\w-]+:[\w$#]+)|(?:^[@~][\w-]+$)/)&&!Object.keys(j.defaultSemantics).includes(t)||t.match(/\*\*/)||t.match(/:\[/)||t.match(/\$\{/)||t.match(/\{\{/)||t.match(/\(\{[^}]*\}/)||t.match(/<\w+>|<\/\w+>/);var L={config:"./master.css.js",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},H=L;var $=h(require("@master/css")),E=require("perf_hooks"),m=class{constructor(e){this.options=e;this.options=(0,$.extend)(H,e),(async()=>{let s;try{s=(await import(b.default.resolve(process.cwd(),this.options.config))).default}catch{}this.css=new $.default({config:s})})()}initializing;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 ${b.default.relative(process.cwd(),e)}`);for(let i of this.options.extract({content:s,name:e}))this.extractions.has(i)||(this.extractions.add(i),r.push(i));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),i=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(b.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(i.length)} total valid classes: ${p.default.blue(i.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 S="MasterCSSWebpackPlugin",C=class extends m{async apply(e){await this.initializing;let{webpack:s}=e,{Template:r,RuntimeGlobals:i,RuntimeModule:n}=s,{RawSource:x}=s.sources,{Compilation:w}=s,{options:o}=this,l=F.default.join(o.output.dir||"",o.output.name),M=l.replace(/\\/g,"/");e.hooks.thisCompilation.tap(S,a=>{let u=new WeakSet,f=(d,c)=>{u.has(d)||(u.add(d),c.add(i.publicPath),a.addRuntimeModule(d,new O(c)))};a.hooks.runtimeRequirementInTree.for(i.ensureChunkHandlers).tap(S,f),a.hooks.runtimeRequirementInTree.for(i.hmrDownloadUpdateHandlers).tap(S,f);class O extends n{runtimeRequirements;constructor(c){super("master-css-loading",10),this.runtimeRequirements=c}generate(){let{runtimeRequirements:c}=this;return c.has(i.hmrDownloadUpdateHandlers)?r.asString([Date.now().toString(),`const link = document.querySelector('[href*=\\'${M}\\'][rel=stylesheet]')`,"if (link) {",r.indent(["link.href = link.href.replace(/ts=[0-9]+/, 'ts=' + Date.now())"]),"}"]):""}}}),e.hooks.compilation.tap(S,a=>{a.hooks.finishModules.tap(S,u=>{let{modifiedFiles:f,watching:O}=e,d=[];for(let c of u){let g=c.resource,y=c._source?.source();O&&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 x(g);a.getAsset(l)?a.updateAsset(l,y):a.emitAsset(l,y)}}}),a.hooks.processAssets.tap({name:S,stage:w.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 A(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)}async function z(t){let e=new m(t);await e.initializing;let s=I.default.join(e.options.output.dir||"",e.options.output.name),r,i,n,x=!1,w=(o,l)=>{let M=e.extract({name:o,content:l});if(M.length){let a=e.css.text;e.insert(M);let u=e.css.text;if(u!==a&&r){A(i,u);let f=()=>{r.ws.send({type:"update",updates:[{path:n,timestamp:Date.now()}]})};x?f():(setTimeout(f,500),x=!0)}}};return{name:"vite-plugin-master-css",enforce:"pre",configureServer(o){r=o},buildStart(){i=I.default.resolve(r?.config.cacheDir??process.cwd(),s),r&&(A(i,""),n=(r.config.cacheDir.slice(process.cwd().length)+"/"+s).replace(/\\/g,"/"))},resolveId(o){if(o.endsWith("master.css?direct"))return"\0"+o},transform(o,l){w(l,o)},transformIndexHtml(o){return o.replace(/(<head>)/,`$1<link rel="stylesheet" href="${n}">`)},async handleHotUpdate(o){w(o.file,await o.read())},generateBundle(){let o=this.emitFile({type:"asset",name:s,source:e.css.text});n="/"+this.getFileName(o)}}}0&&(module.exports={MasterCSSCompiler,MasterCSSVitePlugin,MasterCSSWebpackPlugin});
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
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
|
-
"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, { 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?: 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({ config: 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 } as PluginOption\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,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,CAAK,CAAC,CAErC,CACA,MAAO,CAAC,GAAGD,CAAO,EAAE,OAAOM,GAAKA,GAAK,CAACC,EAAeD,CAAC,CAAC,CAC3D,CAEA,IAAMD,EAAcP,GAAY,CAC5B,IAAMU,EAAgBV,EAKtB,OAJAA,EAAUA,EAAQ,QAAQ,sBAAuB,EAAE,EAC9CA,EAAQ,MAAM,iEAAiE,IAChFA,EAAUA,EAAQ,QAAQ,4BAA6B,EAAE,GAEzDU,IAAkBV,EACXA,EAEAO,EAAWP,CAAO,CAEjC,EAEMK,EAAcL,GAAY,CAC5B,IAAME,EAAU,IAAI,IACdS,EAAa,yDACfC,EACJ,MAAQA,EAAID,EAAW,KAAKX,CAAO,KAAO,MAAM,CACxCY,EAAE,QAAUD,EAAW,WACvBA,EAAW,YAEf,IAAMP,EAASC,EAAWO,EAAE,EAAE,EAC9B,GAAIR,EAAO,KACP,QAAWE,KAAUF,EACjBF,EAAQ,IAAII,CAAM,OAGtBJ,EAAQ,IAAIK,EAAWK,EAAE,EAAE,CAAC,CAEpC,CACA,OAAOV,CACX,EAEMO,EAAkBT,GACb,CAACA,GACA,CAACA,EAAQ,MAAM,sCAAsC,GAAK,CAAC,OAAO,KAAK,kBAAgB,EAAE,SAASA,CAAO,GAC1GA,EAAQ,MAAM,MAAM,GACpBA,EAAQ,MAAM,KAAK,GACnBA,EAAQ,MAAM,MAAM,GACpBA,EAAQ,MAAM,MAAM,GACpBA,EAAQ,MAAM,aAAa,GAC3BA,EAAQ,MAAM,eAAe,EC1DxC,IAAMa,EAA2C,CAC7C,OAAQ,CACJ,KAAM,aACN,IAAK,EACT,EACA,OAAO,CAAE,KAAAC,CAAK,EAAG,CACb,GAAIA,EAAK,MAAM,wBAAwB,EACnC,MAAO,GAEX,GAAIA,EAAK,MAAM,2CAA2C,EACtD,MAAO,EAEf,EACA,QAAAC,CACJ,EAkBOC,EAAQH,
|
|
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, { 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?: MasterCSSCompilerOptions\n ) {\n this.options = extend(defaultOptions, options);\n (async () => {\n let userConfig: MasterCSSConfig\n try {\n userConfig = (await import(path.resolve(process.cwd(), this.options.config))).default\n // eslint-disable-next-line no-empty\n } catch (err) { }\n this.css = new MasterCSS({ config: userConfig })\n })()\n }\n\n initializing: Promise<any>\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 config: './master.css.js',\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 async apply(compiler: Compiler) {\n await this.initializing\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 { Plugin } from 'vite'\n\nexport default async function (options?: MasterCSSCompilerOptions): Promise<Plugin> {\n const compiler = new MasterCSSCompiler(options)\n await compiler.initializing\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,mBACjBC,EAAkB,oBCDlB,IAAAC,EAAiC,uBAGlB,SAARC,EAAyB,CAAE,QAAAC,CAAQ,EAA4B,C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KAAM,SACN,QAAS,CAAC,CACN,KAAME,EACN,UAAW,KAAK,IAAI,CACxB,CAAC,CACL,CAAC,CACL,EAEIC,EACAQ,EAAO,GAEP,WAAWA,EAAQ,GAAG,EAEtBR,EAAW,GAEnB,CAER,CACJ,EAEA,MAAO,CACH,KAAM,yBACN,QAAS,MACT,gBAAgBS,EAAS,CACrBZ,EAASY,CACb,EACA,YAAa,CACTX,EAAiB,EAAAF,QAAK,QAAQC,GAAQ,OAAO,UAAY,QAAQ,IAAI,EAAGF,CAAU,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/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import v from"path";import f from"chalk";import{defaultSemantics as I}from"@master/css";function b({content:t}){let e=t.match(/[^\s]+/g)??[],r=new Set;for(let s of e){let i=O(s);if(i.size)for(let n of i)r.add(n);else r.add($(s))}return[...r].filter(s=>s&&!P(s))}var $=t=>{let e=t;return t=t.replace(/^([\w={[(\\]*["'`])/,""),t.match(/^content:((?<!\\)["'`])((?:\\\1|(?:(?!\1))[\S\s])*)((?<!\\)\1)$/)||(t=t.replace(/(\.*|[([{\\:#]*|["'`].*)$/,"")),e===t?t:$(t)},O=t=>{let e=new Set,r=/((?<!\\)["'`])((?:\\\1|(?:(?!\1))[\S\s])*)((?<!\\)\1)/g,s;for(;(s=r.exec(t))!==null;){s.index===r.lastIndex&&r.lastIndex++;let i=O(s[2]);if(i.size)for(let n of i)e.add(n);else e.add($(s[2]))}return e},P=t=>!t||!t.match(/(?:^[\w-]+:[\w$#]+)|(?:^[@~][\w-]+$)/)&&!Object.keys(I).includes(t)||t.match(/\*\*/)||t.match(/:\[/)||t.match(/\$\{/)||t.match(/\{\{/)||t.match(/\(\{[^}]*\}/)||t.match(/<\w+>|<\/\w+>/);var j={config:"./master.css.js",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:b},R=j;import D,{extend as H}from"@master/css";import{performance as T}from"perf_hooks";var d=class{constructor(e){this.options=e;this.options=H(R,e),(async()=>{let r;try{r=(await import(v.resolve(process.cwd(),this.options.config))).default}catch{}this.css=new D({config:r})})()}initializing;css;extractions=new Set;extract({name:e,content:r}){if(!e||!r||!this.options.accept?.({content:r,name:e}))return[];let s=[];this.log("accepts",` \u2192 ${v.relative(process.cwd(),e)}`);for(let i of this.options.extract({content:r,name:e}))this.extractions.has(i)||(this.extractions.add(i),s.push(i));return s}insert(e){let r=T.now();for(let n of e)this.css.findAndInsert(n);let s=Math.round((T.now()-r)*1e3),i=this.css.rules.map(n=>n.className);console.log(`[Master CSS] process ${f.green(e.length)} extractions in ${f.green(s)} \xB5s [${f.green(this.css.rules.length)} rules in ${f.green(v.join(this.options.output.dir,this.options.output.name))}]`),this.log("extractions",` \u2192 ${f.green(e.length)} extractions: ${f.blue(e.join(" "))}`),this.log("validClasses",` \u2192 ${f.green(i.length)} total valid classes: ${f.blue(i.join(" "))}`)}log(e,r){(this.options.debug===!0||Array.isArray(this.options.debug)&&this.options.debug.includes(e))&&console.log(r)}};import F from"path";var g="MasterCSSWebpackPlugin",M=class extends d{async apply(e){await this.initializing;let{webpack:r}=e,{Template:s,RuntimeGlobals:i,RuntimeModule:n}=r,{RawSource:S}=r.sources,{Compilation:C}=r,{options:o}=this,l=F.join(o.output.dir||"",o.output.name),x=l.replace(/\\/g,"/");e.hooks.thisCompilation.tap(g,a=>{let u=new WeakSet,p=(m,c)=>{u.has(m)||(u.add(m),c.add(i.publicPath),a.addRuntimeModule(m,new k(c)))};a.hooks.runtimeRequirementInTree.for(i.ensureChunkHandlers).tap(g,p),a.hooks.runtimeRequirementInTree.for(i.hmrDownloadUpdateHandlers).tap(g,p);class k extends n{runtimeRequirements;constructor(c){super("master-css-loading",10),this.runtimeRequirements=c}generate(){let{runtimeRequirements:c}=this;return c.has(i.hmrDownloadUpdateHandlers)?s.asString([Date.now().toString(),`const link = document.querySelector('[href*=\\'${x}\\'][rel=stylesheet]')`,"if (link) {",s.indent(["link.href = link.href.replace(/ts=[0-9]+/, 'ts=' + Date.now())"]),"}"]):""}}}),e.hooks.compilation.tap(g,a=>{a.hooks.finishModules.tap(g,u=>{let{modifiedFiles:p,watching:k}=e,m=[];for(let c of u){let h=c.resource,w=c._source?.source();k&&p?.size&&!p.has(h)||m.push(...this.extract({name:h,content:w}))}if(m.length){let c=this.css.text;this.insert(m);let h=this.css.text;if(h!==c){let w=new S(h);a.getAsset(l)?a.updateAsset(l,w):a.emitAsset(l,w)}}}),a.hooks.processAssets.tap({name:g,stage:C.PROCESS_ASSETS_STAGE_ADDITIONS},()=>{a.chunks.forEach(u=>{u.files.add(l)})})})}};import E from"path";import A from"fs";import q from"path";function y(t,e,r){let s=q.dirname(t);A.existsSync(s)||A.mkdirSync(s,{recursive:!0}),A.writeFileSync(t,e,r)}async function z(t){let e=new d(t);await e.initializing;let r=E.join(e.options.output.dir||"",e.options.output.name),s,i,n,S=!1,C=(o,l)=>{let x=e.extract({name:o,content:l});if(x.length){let a=e.css.text;e.insert(x);let u=e.css.text;if(u!==a&&s){y(i,u);let p=()=>{s.ws.send({type:"update",updates:[{path:n,timestamp:Date.now()}]})};S?p():(setTimeout(p,500),S=!0)}}};return{name:"vite-plugin-master-css",enforce:"pre",configureServer(o){s=o},buildStart(){i=E.resolve(s?.config.cacheDir??process.cwd(),r),s&&(y(i,""),n=(s.config.cacheDir.slice(process.cwd().length)+"/"+r).replace(/\\/g,"/"))},resolveId(o){if(o.endsWith("master.css?direct"))return"\0"+o},transform(o,l){C(l,o)},transformIndexHtml(o){return o.replace(/(<head>)/,`$1<link rel="stylesheet" href="${n}">`)},async handleHotUpdate(o){C(o.file,await o.read())},generateBundle(){let o=this.emitFile({type:"asset",name:r,source:e.css.text});n="/"+this.getFileName(o)}}}export{d as MasterCSSCompiler,z as MasterCSSVitePlugin,M as MasterCSSWebpackPlugin};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/compiler.ts", "../src/options/extract.ts", "../src/options/index.ts", "../src/webpack.ts", "../src/vite.ts", "../src/utils/write-file.ts"],
|
|
4
|
-
"sourcesContent": ["import path from 'path'\nimport chalk from 'chalk'\nimport defaultOptions, { MasterCSSCompilerOptions, MasterCSSCompilerSource } from './options'\nimport MasterCSS, { 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?: 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({ config: 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 } as PluginOption\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": "
|
|
6
|
-
"names": ["path", "chalk", "defaultSemantics", "extract", "content", "blocks", "strings", "block", "result", "peelString", "string", "trimString", "x", "checkToExclude", "originContent", "stringRegx", "m", "defaultOptions", "name", "extract", "options_default", "MasterCSS", "extend", "performance", "MasterCSSCompiler", "options", "
|
|
4
|
+
"sourcesContent": ["import path from 'path'\nimport chalk from 'chalk'\nimport defaultOptions, { MasterCSSCompilerOptions, MasterCSSCompilerSource } from './options'\nimport MasterCSS, { 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?: MasterCSSCompilerOptions\n ) {\n this.options = extend(defaultOptions, options);\n (async () => {\n let userConfig: MasterCSSConfig\n try {\n userConfig = (await import(path.resolve(process.cwd(), this.options.config))).default\n // eslint-disable-next-line no-empty\n } catch (err) { }\n this.css = new MasterCSS({ config: userConfig })\n })()\n }\n\n initializing: Promise<any>\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 config: './master.css.js',\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 async apply(compiler: Compiler) {\n await this.initializing\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 { Plugin } from 'vite'\n\nexport default async function (options?: MasterCSSCompilerOptions): Promise<Plugin> {\n const compiler = new MasterCSSCompiler(options)\n await compiler.initializing\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": "AAAA,OAAOA,MAAU,OACjB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,KAAK,CACX,KAAM,SACN,QAAS,CAAC,CACN,KAAME,EACN,UAAW,KAAK,IAAI,CACxB,CAAC,CACL,CAAC,CACL,EAEIC,EACAQ,EAAO,GAEP,WAAWA,EAAQ,GAAG,EAEtBR,EAAW,GAEnB,CAER,CACJ,EAEA,MAAO,CACH,KAAM,yBACN,QAAS,MACT,gBAAgBS,EAAS,CACrBZ,EAASY,CACb,EACA,YAAa,CACTX,EAAiBF,EAAK,QAAQC,GAAQ,OAAO,UAAY,QAAQ,IAAI,EAAGF,CAAU,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
|
+
"names": ["path", "chalk", "defaultSemantics", "extract", "content", "blocks", "strings", "block", "result", "peelString", "string", "trimString", "x", "checkToExclude", "originContent", "stringRegx", "m", "defaultOptions", "name", "extract", "options_default", "MasterCSS", "extend", "performance", "MasterCSSCompiler", "options", "options_default", "userConfig", "path", "name", "content", "eachExtractions", "eachNewExtraction", "extractions", "p1", "eachExtraction", "spent", "validClasses", "rule", "chalk", "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", "path", "fs", "path", "writeFile", "filePath", "data", "options", "dirname", "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/dist/vite.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { MasterCSSCompilerOptions } from './options';
|
|
2
|
-
import type {
|
|
3
|
-
export default function (options?: MasterCSSCompilerOptions):
|
|
2
|
+
import type { Plugin } from 'vite';
|
|
3
|
+
export default function (options?: MasterCSSCompilerOptions): Promise<Plugin>;
|
package/dist/webpack.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -138,10 +138,10 @@
|
|
|
138
138
|
"vite": "^3.1.8"
|
|
139
139
|
},
|
|
140
140
|
"peerDependencies": {
|
|
141
|
-
"@master/css": "^2.0.0-beta.
|
|
141
|
+
"@master/css": "^2.0.0-beta.22"
|
|
142
142
|
},
|
|
143
143
|
"dependencies": {
|
|
144
144
|
"chalk": "^4.0.0"
|
|
145
145
|
},
|
|
146
|
-
"version": "2.0.0-beta.
|
|
146
|
+
"version": "2.0.0-beta.16"
|
|
147
147
|
}
|