@master/css-compiler 2.0.0-beta.10 → 2.0.0-beta.100

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/README.md CHANGED
@@ -1,80 +1,156 @@
1
- <br><br>
1
+ <br>
2
2
  <div align="center">
3
3
 
4
4
  <p align="center">
5
- <img src="https://raw.githubusercontent.com/master-co/package/document/images/logo-and-text.svg" alt="logo" width="142">
5
+ <a href="https://css.master.co">
6
+ <picture>
7
+ <source media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/33840671/201701649-3bb7d698-abec-4d5f-ac30-ccc4d7bafcd4.svg">
8
+ <source media="(prefers-color-scheme: light)" srcset="https://user-images.githubusercontent.com/33840671/201703010-77bf2373-9899-40cc-98f5-30cf9b546941.svg">
9
+ <img alt="Master CSS" src="https://user-images.githubusercontent.com/33840671/201703010-77bf2373-9899-40cc-98f5-30cf9b546941.svg" width="100%">
10
+ </picture>
11
+ </a>
6
12
  </p>
13
+ <p align="center">The ahead-of-time compiler of Master CSS</p>
14
+
7
15
  <p align="center">
8
- <b><!-- name -->CSS Compiler<!----></b>
16
+ <a aria-label="overview" href="https://github.com/master-co/css/tree/beta">
17
+ <picture>
18
+ <source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/badge/%E2%AC%85%20back-%20?color=212022&style=for-the-badge">
19
+ <source media="(prefers-color-scheme: light)" srcset="https://img.shields.io/badge/%E2%AC%85%20back-%20?color=f6f7f8&style=for-the-badge">
20
+ <img alt="NPM Version" src="https://img.shields.io/badge/%E2%AC%85%20back-%20?color=f6f7f8&style=for-the-badge">
21
+ </picture>
22
+ </a>
23
+ <a aria-label="GitHub release (latest by date including pre-releases)" href="https://github.com/master-co/css/releases">
24
+ <picture>
25
+ <source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/github/v/release/master-co/css?include_prereleases&color=212022&label=&style=for-the-badge&logo=github&logoColor=fff">
26
+ <source media="(prefers-color-scheme: light)" srcset="https://img.shields.io/github/v/release/master-co/css?include_prereleases&color=f6f7f8&label=&style=for-the-badge&logo=github&logoColor=%23000">
27
+ <img alt="NPM Version" src="https://img.shields.io/github/v/release/master-co/css?include_prereleases&color=f6f7f8&label=&style=for-the-badge&logo=github">
28
+ </picture>
29
+ </a>
30
+ <a aria-label="NPM Package" href="https://www.npmjs.com/package/@master/css-compiler">
31
+ <picture>
32
+ <source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/dm/@master/css-compiler?color=212022&label=%20&logo=npm&style=for-the-badge">
33
+ <source media="(prefers-color-scheme: light)" srcset="https://img.shields.io/npm/dm/@master/css-compiler?color=f6f7f8&label=%20&logo=npm&style=for-the-badge">
34
+ <img alt="NPM package ( download / month )" src="https://img.shields.io/npm/dm/@master/css-compiler?color=f6f7f8&label=%20&logo=npm&style=for-the-badge">
35
+ </picture>
36
+ </a>
37
+ <a aria-label="Discord Community" href="https://discord.gg/sZNKpAAAw6">
38
+ <picture>
39
+ <source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/discord/917780624314613760?color=212022&label=%20&logo=discord&style=for-the-badge">
40
+ <source media="(prefers-color-scheme: light)" srcset="https://img.shields.io/discord/917780624314613760?color=f6f7f8&label=%20&logo=discord&style=for-the-badge">
41
+ <img alt="Discord online" src="https://img.shields.io/discord/917780624314613760?color=f6f7f8&label=%20&logo=discord&style=for-the-badge">
42
+ </picture>
43
+ </a>
44
+ <a aria-label="Follow @mastercorg" href="https://twitter.com/mastercorg">
45
+ <picture>
46
+ <source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/static/v1?label=%20&message=twitter&color=212022&logo=twitter&style=for-the-badge">
47
+ <source media="(prefers-color-scheme: light)" srcset="https://img.shields.io/static/v1?label=%20&message=twitter&color=f6f7f8&logo=twitter&style=for-the-badge">
48
+ <img alt="Follow @mastercorg" src="https://img.shields.io/static/v1?label=%20&message=twitter&color=f6f7f8&logo=twitter&style=for-the-badge">
49
+ </picture>
50
+ </a>
51
+ <a aria-label="Github Actions" href="https://github.com/1aron/repo/actions/workflows/release.yml">
52
+ <picture>
53
+ <source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/github/actions/workflow/status/master-co/css/release.yml?branch=beta&label=%20&message=twitter&color=212022&logo=githubactions&style=for-the-badge">
54
+ <source media="(prefers-color-scheme: light)" srcset="https://img.shields.io/github/actions/workflow/status/master-co/css/release.yml?branch=beta&label=%20&message=twitter&color=f6f7f8&logo=githubactions&style=for-the-badge&logoColor=%23000">
55
+ <img alt="Github release actions" src="https://img.shields.io/github/actions/workflow/status/master-co/css/release.yml?branch=beta&label=%20&message=twitter&color=f6f7f8&logo=githubactions&style=for-the-badge&logoColor=%23000">
56
+ </picture>
57
+ </a>
9
58
  </p>
10
- <p align="center"><!-- package.description -->Compile Master CSS ahead of time with zero-configuration integration with build tools<!----></p>
11
-
12
- [![MIT License](https://flat.badgen.net/github/license/master-co/css?color=yellow)](https://github.com/master-co/css-compiler/blob/main/LICENSE)
13
- [![Latest Release](https://flat.badgen.net/npm/v/@master/css-compiler?icon=npm&label&color=yellow)](https://www.npmjs.com/package/@master/css-compiler)
14
- [![Documentation](https://flat.badgen.net/badge/icon/Documentation?icon=awesome&label&color=yellow)](https://css.master.co)
15
- [![Github](https://flat.badgen.net/badge/icon/master-co%2Fcss-compiler?icon=github&label&color=yellow)](https://github.com/master-co/css)
16
- [![Discord](https://flat.badgen.net/badge/icon/discord?icon=discord&label&color=yellow)](https://discord.gg/sZNKpAAAw6)
17
- [![CI](https://flat.badgen.net/github/status/master-co/css-compiler/main/ci/circleci?icon=circleci)](https://circleci.com/gh/master-co/workflows/css-compiler/tree/main)
18
59
 
19
60
  </div>
20
61
 
21
- ##### On this page
62
+ ## Usage
63
+ ```bash
64
+ npm install @master/css-compiler
65
+ ```
22
66
 
23
- - [Usage](#usage)
24
- - [`webpack.config.js`](#webpackconfigjs)
25
- - [`vite.config.js`](#viteconfigjs)
26
- - [`next.config.js`](#nextconfigjs)
27
- - [Related](#related)
67
+ ```ts
68
+ const compiler = await new MasterCSSCompiler().init()
69
+ ```
28
70
 
29
- ---
71
+ ## Options
72
+ ```ts
73
+ {
74
+ // specify virtual CSS module id (e.g. virtual:master.css)
75
+ module: 'master.css',
76
+ // specify config file path or set `Config`
77
+ config: 'master.css.{ts,js,mjs,cjs}',
78
+ // forcibly specify sources for scanning, not excluded by `options.exclude`
79
+ sources: [],
80
+ // specify sources for scanning
81
+ include: ['**/*.{html,js,jsx,ts,tsx,svelte,astro,vue,md,mdx,pug,php}'],
82
+ // specify sources to exclude
83
+ exclude: [
84
+ '**/node_modules/**',
85
+ '**/*.d.ts',
86
+ '**/*.test.*',
87
+ 'node_modules',
88
+ 'master.css.{js,ts,mjs,cjs}',
89
+ 'dist',
90
+ 'out',
91
+ 'README.md'
92
+ ],
93
+ // whitelist of class names for unpredictable dynamics
94
+ fixedClasses: [],
95
+ // blacklist of class names to exclude accidentally captured
96
+ ignoredClasses: [], // or RegExp[]
97
+ cwd: process.cwd()
98
+ }
99
+ ```
30
100
 
31
- # Usage
101
+ ## Methods
32
102
 
33
- ## `webpack.config.js`
34
- ```js
35
- const { MasterCSSWebpackPlugin } = require('@master/css-compiler')
103
+ ```ts
104
+ // Initialize the compiler and MasterCSS
105
+ init(): this
106
+ ```
36
107
 
37
- module.exports = {
38
- plugins: [
39
- new MasterCSSWebpackPlugin()
40
- ]
41
- };
108
+ ```ts
109
+ // Scan sources, extract class names, and generate CSS rules
110
+ compile()
42
111
  ```
43
112
 
44
- ## `vite.config.js`
45
- ```js
46
- import { MasterCSSVitePlugin } from '@master/css-compiler'
113
+ ```ts
114
+ // Extract potential class names from the given file content
115
+ extract(name: string, content: string): string[]
116
+ ```
47
117
 
48
- export default defineConfig({
49
- plugins: [
50
- MasterCSSVitePlugin()
51
- ]
52
- })
118
+ ```ts
119
+ // `extract(name, content)`, insert extractions, and generate CSS rules
120
+ insert(name: string, content: string): boolean
53
121
  ```
54
122
 
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
- }
123
+ ```ts
124
+ // Read file source paths by `options.include` and `options.exclude`
125
+ get sources(): string[]
126
+ ```
72
127
 
73
- module.exports = nextConfig
128
+ ```ts
129
+ // Check source file path by `options.include` and `options.exclude`
130
+ checkSourcePath(name: string): boolean
74
131
  ```
75
132
 
76
- ---
133
+ ```ts
134
+ // Read user config file by `options.config`
135
+ readConfig(): Config
136
+ ```
77
137
 
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
138
+ ```ts
139
+ // Get user config path
140
+ get configPath(): string
141
+ ```
142
+
143
+ ```ts
144
+ // Get resolved user config path
145
+ get resolvedConfigPath(): string
146
+ ```
147
+
148
+ ## Properties
149
+
150
+ ```ts
151
+ export default class MasterCSSCompiler {
152
+ css: MasterCSS
153
+ extractions = new Set<string>()
154
+ ...
155
+ }
156
+ ```
@@ -1,11 +1,19 @@
1
- import { MasterCSSCompilerOptions, MasterCSSCompilerSource } from './options';
2
- import MasterCSS from '@master/css';
3
- export default class MasterCSSCompiler {
4
- options?: MasterCSSCompilerOptions;
5
- constructor(options?: MasterCSSCompilerOptions);
1
+ import { Options } from './options';
2
+ import MasterCSS, { Rule } from '@master/css';
3
+ import type { Config } from '@master/css';
4
+ import Techor from 'techor';
5
+ export default class MasterCSSCompiler extends Techor<Options, Config> {
6
+ constructor(options?: Options);
6
7
  css: MasterCSS;
7
8
  extractions: Set<string>;
8
- extract({ name, content }: MasterCSSCompilerSource): string[];
9
- insert(extractions: any): void;
10
- log(name: any, content: any): void;
9
+ get resolvedModuleId(): string;
10
+ get moduleHMREvent(): string;
11
+ init(): Promise<this>;
12
+ compile(): Promise<this>;
13
+ extract(name: string, content: string): string[];
14
+ insert(name: string, content: string): Promise<boolean>;
15
+ createRules(extraction: string): Promise<Rule[]>;
16
+ get sources(): string[];
17
+ checkSourcePath(name: string): boolean;
18
+ get config(): Config;
11
19
  }
@@ -0,0 +1,3 @@
1
+ import MasterCSS from '@master/css';
2
+ import type { Source } from './options';
3
+ export default function extract({ content }: Source, { config, classes }: MasterCSS): string[];
package/dist/index.cjs CHANGED
@@ -1,2 +1,10 @@
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 O=h(require("fs")),q=h(require("path"));function v(t,e,s){let r=q.default.dirname(t);O.default.existsSync(r)||O.default.mkdirSync(r,{recursive:!0}),O.default.writeFileSync(t,e,s)}function N(t){let e=new m(t),s=I.default.join(e.options.output.dir||"",e.options.output.name),r,o,n,w=!1,M=(i,l)=>{let k=e.extract({name:i,content:l});if(k.length){let a=e.css.text;e.insert(k);let u=e.css.text;if(u!==a&&r){v(o,u);let f=()=>{r.ws.send({type:"update",updates:[{path:n,timestamp:Date.now()}]})};w?f():(setTimeout(f,500),w=!0)}}};return{name:"vite-plugin-master-css",enforce:"pre",configureServer(i){r=i},buildStart(){o=I.default.resolve(r?.config.cacheDir??process.cwd(),s),r&&(v(o,""),n=(r.config.cacheDir.slice(process.cwd().length)+"/"+s).replace(/\\/g,"/"))},resolveId(i){if(i.endsWith("master.css?direct"))return"\0"+i},transform(i,l){M(l,i)},transformIndexHtml(i){return i.replace(/(<head>)/,`$1<link rel="stylesheet" href="${n}">`)},async handleHotUpdate(i){M(i.file,await i.read())},generateBundle(){let i=this.emitFile({type:"asset",name:s,source:e.css.text});n="/"+this.getFileName(i)}}}0&&(module.exports={MasterCSSCompiler,MasterCSSVitePlugin,MasterCSSWebpackPlugin});
2
- //# sourceMappingURL=index.cjs.map
1
+ var xe=Object.create;var E=Object.defineProperty;var $e=Object.getOwnPropertyDescriptor;var Oe=Object.getOwnPropertyNames;var we=Object.getPrototypeOf,Ce=Object.prototype.hasOwnProperty;var Te=(r,e)=>{for(var t in e)E(r,t,{get:e[t],enumerable:!0})},H=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Oe(e))!Ce.call(r,n)&&n!==t&&E(r,n,{get:()=>e[n],enumerable:!(s=$e(e,n))||s.enumerable});return r};var m=(r,e,t)=>(t=r!=null?xe(we(r)):{},H(e||!r||!r.__esModule?E(t,"default",{value:r,enumerable:!0}):t,r)),Re=r=>H(E({},"__esModule",{value:!0}),r);var hr={};Te(hr,{default:()=>R,options:()=>k});module.exports=Re(hr);var A=m(require("upath"));var Ee={module:"master.css",config:"master.css.{ts,js,mjs,cjs}",sources:[],include:["**/*.{html,js,jsx,ts,tsx,svelte,astro,vue,md,mdx,pug,php}"],exclude:["**/node_modules/**","**/*.d.ts","**/*.test.*","node_modules","master.css.{js,ts,mjs,cjs}","dist","out","README.md"],fixedClasses:[],ignoredClasses:[]},k=Ee;var de=m(require("@master/css")),U=require("perf_hooks");var J=require("@master/css");function F({content:r},{config:e,classes:t}){r=ke(r);let s=[...new Set(Object.keys(e.semantics??J.semantics).concat(Object.keys(t)))],n=r.match(/\S+/g)??[],i=new Set;for(let l of n){i.add(P(l,s));let a=Z(l);if(a.size)for(let p of a)i.add(P(p,s))}return[...i].filter(l=>l&&!Se(l,s))}var P=(r,e)=>{let t=r,s=r.match(/(?:calc\(.*\)|\d+(?:%|ch|cm|em|ex|in|mm|pc|pt|px|rem|vh|vmax|vmin|vw|deg|grad|rad|turn|s)?)x(?:calc\(.*\)|\d+(?:%|ch|cm|em|ex|in|mm|pc|pt|px|rem|vh|vmax|vmin|vw|deg|grad|rad|turn|s)?)/g);return(s?.length?e.concat(s):e).find(n=>t.startsWith(n))?r=I(r,n=>n.replace(/^[^:@~(]*(?<!@>?)=/,"").replace(/(?:[([{\\:#=.]+|["'`].*)$/,"")):r=I(r,n=>n.replace(/^[^:@~(]*(?:["'`]|(?<!@>?)=)/,"").replace(/(?:[([{\\:#=.]+|["'`].*)$/,"")),t===r||!r?r:P(r,e)},K=r=>r.match(/((?<!\\)["'`])(?:\\\1|(?:(?!\1))[\S\s])*(?<!\\)\1/g),z=(r,e)=>(e?.forEach((t,s)=>{r=r.replace(t,`COMPLETE-STRING--${s}--`)}),r),I=(r,e)=>{let t=K(r);return r=z(r,t),r=e(r),t?.forEach((s,n)=>{r=r.replace(`COMPLETE-STRING--${n}--`,s)}),r},Z=r=>{let e=new Set,t=/((?<!\\)["'`])((?:\\\1|(?:(?!\1))[\S\s])*)((?<!\\)\1)/g,s;for(;(s=t.exec(r))!==null;){s.index===t.lastIndex&&t.lastIndex++,e.add(s[2]);let n=Z(s[2]);if(n.size)for(let i of n)e.add(i)}return e},ke=r=>I(r,e=>e.replace(/\/\*(?:(?!\*\/)[\S\s])*\*\//g,"").replace(/<!--(?:(?!-->)[\S\s])*-->/g,"").replace(/<style[^>]*>(?:(?!<\/style>)[\S\s])*<\/style>/g,"").replace(/import.*from\s*COMPLETE-STRING--\d+--/g,"").replace(/import\s*(?:COMPLETE-STRING--\d+--|\([^;\s]*\))/g,"").replace(/require\([^;\s]*\)/g,"")),Se=(r,e)=>{let t=K(r),s=z(r,t),n=/{(.*)}/,i;for(;(i=n.exec(s))!==null;)return i[1].split(";").find(a=>q(a,e))!==void 0;return q(s,e)||Ne(r)},q=(r,e)=>!r||!r.match(/(?:\S*\{\S*\})|(?:^[\w\-()]+:\S+)|(?:^[\w-]+\(\S+\))|(?:^[@~]\S+$)/)&&!r.match(/^(?:calc\(.*\)|\d+(?:%|ch|cm|em|ex|in|mm|pc|pt|px|rem|vh|vmax|vmin|vw|deg|grad|rad|turn|s)?)x(?:calc\(.*\)|\d+(?:%|ch|cm|em|ex|in|mm|pc|pt|px|rem|vh|vmax|vmin|vw|deg|grad|rad|turn|s)?)$/)&&!e.find(t=>r.startsWith(t))||r.match(/\*\*/)||r.match(/:\[/)||r.match(/\$\{/)||r.match(/\{\{/)||r.match(/\(\{[^}]*\}/)||r.match(/<\w+>|<\/\w+>/)||r.match(/;$/)||r.match(/^\w+:\/\//)||r.match(/^@(?:ts-[^\s]+|charset|import|namespace|media|supports|document|page|font-face|keyframes|counter-style|font-feature-values|property|layer)$/)||r.match(/^~\/.+.\w+$/)||r.match(/function\(|\(.*\)=>/),Ne=r=>{let e=[],t;for(let s=0;s<r.length;s++)switch(r[s]){case"(":case"[":case"{":e.push(r[s]);break;case")":case"]":case"}":if(t=e.pop(),r[s]===")"&&t!=="("||r[s]==="]"&&t!=="["||r[s]==="}"&&t!=="{")return!0;break}return e.length>0};var me=m(require("fs")),V=m(require("fast-glob")),B=m(require("minimatch")),be=m(require("techor"));var j=m(require("node:process"),1),pe=m(require("node:os"),1),L=m(require("node:tty"),1),je=Object.create,ue=Object.defineProperty,Ae=Object.getOwnPropertyDescriptor,Be=Object.getOwnPropertyNames,Me=Object.getPrototypeOf,Pe=Object.prototype.hasOwnProperty,Ie=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Fe=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Be(e))!Pe.call(r,n)&&n!==t&&ue(r,n,{get:()=>e[n],enumerable:!(s=Ae(e,n))||s.enumerable});return r},_e=(r,e,t)=>(t=r!=null?je(Me(r)):{},Fe(e||!r||!r.__esModule?ue(t,"default",{value:r,enumerable:!0}):t,r)),Ge=Ie((r,e)=>{"use strict";function t(s){var n=void 0;typeof s=="string"?n=[s]:n=s.raw;for(var i="",l=0;l<n.length;l++)i+=n[l].replace(/\\\n[ \t]*/g,"").replace(/\\`/g,"`"),l<(arguments.length<=1?0:arguments.length-1)&&(i+=arguments.length<=l+1?void 0:arguments[l+1]);var a=i.split(`
2
+ `),p=null;return a.forEach(function(u){var f=u.match(/^(\s+)\S+/);if(f){var x=f[1].length;p?p=Math.min(p,x):p=x}}),p!==null&&(i=a.map(function(u){return u[0]===" "?u.slice(p):u}).join(`
3
+ `)),i=i.trim(),i.replace(/\\n/g,`
4
+ `)}typeof e<"u"&&(e.exports=t)}),b=(r,e)=>{if(!r)throw new Error(e)},Le=r=>{let e={joined:!0,spacerNoNeighbour:" ",spacerNeighbour:"\u2502 ",keyNoNeighbour:"\u2514\u2500 ",keyNeighbour:"\u251C\u2500 ",separator:": ",renderFn:t=>["boolean","string","number"].includes(typeof t)?t:void 0,sortFn:null,breakCircularWith:" (circular ref.)",...r};return b(Object.keys(e).length===9,"Unexpected Option(s) provided"),b(typeof e.joined=="boolean",'Option "joined" has invalid format'),b(typeof e.spacerNoNeighbour=="string",'Option "spacerNoNeighbour" has invalid format'),b(typeof e.spacerNeighbour=="string",'Option "spacerNeighbour" has invalid format'),b(typeof e.keyNoNeighbour=="string",'Option "keyNoNeighbour" has invalid format'),b(typeof e.keyNeighbour=="string",'Option "keyNeighbour" has invalid format'),b(typeof e.separator=="string",'Option "separator" has invalid format'),b(typeof e.renderFn=="function",'Option "renderFn" has invalid format'),b(typeof e.sortFn=="function"||e.sortFn===null,'Option "sortFn" has invalid format'),b(typeof e.breakCircularWith=="string"||e.breakCircularWith===null,'Option "breakCircularWith" has invalid format'),e},ge=(r,e={})=>{let t=Le(e),s=[],n=t.renderFn(r);n!==void 0&&s.push(String(n));let i=u=>t.sortFn===null?u.reverse():u.sort((f,x)=>t.sortFn(x,f)),l=[],a=i(Object.keys(r)).map(u=>[u]),p=[r];for(;a.length!==0;){let u=a.pop(),f=p[u.length-1][u[u.length-1]],x=t.breakCircularWith!==null&&p.includes(f);l[u.length-1]=a.length!==0&&a[a.length-1].length===u.length;let ye=t.renderFn(f);s.push([l.slice(0,u.length-1).map(M=>M?t.spacerNeighbour:t.spacerNoNeighbour).join(""),l[u.length-1]?t.keyNeighbour:t.keyNoNeighbour,u[u.length-1],ye===void 0?"":`${t.separator}${f}`,x?t.breakCircularWith:""].join("")),f instanceof Object&&!Array.isArray(f)&&!x&&(a.push(...i(Object.keys(f)).map(M=>u.concat(M))),p[u.length]=f)}return t.joined===!0?s.join(`
5
+ `):s},Q=(r=0)=>e=>`\x1B[${e+r}m`,X=(r=0)=>e=>`\x1B[${38+r};5;${e}m`,ee=(r=0)=>(e,t,s)=>`\x1B[${38+r};2;${e};${t};${s}m`,c={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},vr=Object.keys(c.modifier),Ye=Object.keys(c.color),De=Object.keys(c.bgColor),yr=[...Ye,...De];function We(){let r=new Map;for(let[e,t]of Object.entries(c)){for(let[s,n]of Object.entries(t))c[s]={open:`\x1B[${n[0]}m`,close:`\x1B[${n[1]}m`},t[s]=c[s],r.set(n[0],n[1]);Object.defineProperty(c,e,{value:t,enumerable:!1})}return Object.defineProperty(c,"codes",{value:r,enumerable:!1}),c.color.close="\x1B[39m",c.bgColor.close="\x1B[49m",c.color.ansi=Q(),c.color.ansi256=X(),c.color.ansi16m=ee(),c.bgColor.ansi=Q(10),c.bgColor.ansi256=X(10),c.bgColor.ansi16m=ee(10),Object.defineProperties(c,{rgbToAnsi256:{value(e,t,s){return e===t&&t===s?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(s/255*5)},enumerable:!1},hexToRgb:{value(e){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[s]=t;s.length===3&&(s=[...s].map(i=>i+i).join(""));let n=Number.parseInt(s,16);return[n>>16&255,n>>8&255,n&255]},enumerable:!1},hexToAnsi256:{value:e=>c.rgbToAnsi256(...c.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,s,n;if(e>=232)t=((e-232)*10+8)/255,s=t,n=t;else{e-=16;let a=e%36;t=Math.floor(e/36)/5,s=Math.floor(a/6)/5,n=a%6/5}let i=Math.max(t,s,n)*2;if(i===0)return 30;let l=30+(Math.round(n)<<2|Math.round(s)<<1|Math.round(t));return i===2&&(l+=60),l},enumerable:!1},rgbToAnsi:{value:(e,t,s)=>c.ansi256ToAnsi(c.rgbToAnsi256(e,t,s)),enumerable:!1},hexToAnsi:{value:e=>c.ansi256ToAnsi(c.hexToAnsi256(e)),enumerable:!1}}),c}var Ue=We(),v=Ue;function d(r,e=globalThis.Deno?globalThis.Deno.args:j.default.argv){let t=r.startsWith("-")?"":r.length===1?"-":"--",s=e.indexOf(t+r),n=e.indexOf("--");return s!==-1&&(n===-1||s<n)}var{env:g}=j.default,S;d("no-color")||d("no-colors")||d("color=false")||d("color=never")?S=0:(d("color")||d("colors")||d("color=true")||d("color=always"))&&(S=1);function Ve(){if("FORCE_COLOR"in g)return g.FORCE_COLOR==="true"?1:g.FORCE_COLOR==="false"?0:g.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(g.FORCE_COLOR,10),3)}function He(r){return r===0?!1:{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}function qe(r,{streamIsTTY:e,sniffFlags:t=!0}={}){let s=Ve();s!==void 0&&(S=s);let n=t?S:s;if(n===0)return 0;if(t){if(d("color=16m")||d("color=full")||d("color=truecolor"))return 3;if(d("color=256"))return 2}if("TF_BUILD"in g&&"AGENT_NAME"in g)return 1;if(r&&!e&&n===void 0)return 0;let i=n||0;if(g.TERM==="dumb")return i;if(j.default.platform==="win32"){let l=pe.default.release().split(".");return Number(l[0])>=10&&Number(l[2])>=10586?Number(l[2])>=14931?3:2:1}if("CI"in g)return"GITHUB_ACTIONS"in g?3:["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(l=>l in g)||g.CI_NAME==="codeship"?1:i;if("TEAMCITY_VERSION"in g)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(g.TEAMCITY_VERSION)?1:0;if(g.COLORTERM==="truecolor"||g.TERM==="xterm-kitty")return 3;if("TERM_PROGRAM"in g){let l=Number.parseInt((g.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(g.TERM_PROGRAM){case"iTerm.app":return l>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(g.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(g.TERM)||"COLORTERM"in g?1:i}function re(r,e={}){let t=qe(r,{streamIsTTY:r&&r.isTTY,...e});return He(t)}var Je={stdout:re({isTTY:L.default.isatty(1)}),stderr:re({isTTY:L.default.isatty(2)})},Ke=Je;function ze(r,e,t){let s=r.indexOf(e);if(s===-1)return r;let n=e.length,i=0,l="";do l+=r.slice(i,s)+e+t,i=s+n,s=r.indexOf(e,i);while(s!==-1);return l+=r.slice(i),l}function Ze(r,e,t,s){let n=0,i="";do{let l=r[s-1]==="\r";i+=r.slice(n,l?s-1:s)+e+(l?`\r
6
+ `:`
7
+ `)+t,n=s+1,s=r.indexOf(`
8
+ `,n)}while(s!==-1);return i+=r.slice(n),i}var{stdout:te,stderr:se}=Ke,Y=Symbol("GENERATOR"),$=Symbol("STYLER"),C=Symbol("IS_EMPTY"),ne=["ansi","ansi","ansi256","ansi16m"],O=Object.create(null),Qe=(r,e={})=>{if(e.level&&!(Number.isInteger(e.level)&&e.level>=0&&e.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let t=te?te.level:0;r.level=e.level===void 0?t:e.level},Xe=r=>{let e=(...t)=>t.join(" ");return Qe(e,r),Object.setPrototypeOf(e,T.prototype),e};function T(r){return Xe(r)}Object.setPrototypeOf(T.prototype,Function.prototype);for(let[r,e]of Object.entries(v))O[r]={get(){let t=N(this,W(e.open,e.close,this[$]),this[C]);return Object.defineProperty(this,r,{value:t}),t}};O.visible={get(){let r=N(this,this[$],!0);return Object.defineProperty(this,"visible",{value:r}),r}};var D=(r,e,t,...s)=>r==="rgb"?e==="ansi16m"?v[t].ansi16m(...s):e==="ansi256"?v[t].ansi256(v.rgbToAnsi256(...s)):v[t].ansi(v.rgbToAnsi(...s)):r==="hex"?D("rgb",e,t,...v.hexToRgb(...s)):v[t][r](...s),er=["rgb","hex","ansi256"];for(let r of er){O[r]={get(){let{level:t}=this;return function(...s){let n=W(D(r,ne[t],"color",...s),v.color.close,this[$]);return N(this,n,this[C])}}};let e="bg"+r[0].toUpperCase()+r.slice(1);O[e]={get(){let{level:t}=this;return function(...s){let n=W(D(r,ne[t],"bgColor",...s),v.bgColor.close,this[$]);return N(this,n,this[C])}}}}var rr=Object.defineProperties(()=>{},{...O,level:{enumerable:!0,get(){return this[Y].level},set(r){this[Y].level=r}}}),W=(r,e,t)=>{let s,n;return t===void 0?(s=r,n=e):(s=t.openAll+r,n=e+t.closeAll),{open:r,close:e,openAll:s,closeAll:n,parent:t}},N=(r,e,t)=>{let s=(...n)=>tr(s,n.length===1?""+n[0]:n.join(" "));return Object.setPrototypeOf(s,rr),s[Y]=r,s[$]=e,s[C]=t,s},tr=(r,e)=>{if(r.level<=0||!e)return r[C]?"":e;let t=r[$];if(t===void 0)return e;let{openAll:s,closeAll:n}=t;if(e.includes("\x1B"))for(;t!==void 0;)e=ze(e,t.close,t.open),t=t.parent;let i=e.indexOf(`
9
+ `);return i!==-1&&(e=Ze(e,n,s,i)),s+e+n};Object.defineProperties(T.prototype,O);var sr=T(),xr=T({level:se?se.level:0}),o=sr;function y(r){return r.split(" ").map(e=>e.replace(/^(\d*\.?\d*)$/g,`${o.blue("$1")}`).replace(/^(\d*\.?\d*)(YB|ZB|EB|PB|TB|GB|MB|KB|B|mb|kb|bit|zs|as|fs|ps|ns|µs|ms|s|m|h|d|m|y)$/g,`${o.cyan("$1")}${o.magenta("$2")}`).replace(/^((?:[0-1]?[0-9]|[2][0-3]):[0-5][0-9]:[0-5][0-9] (?:AM|PM)?)$/g,`${o.dim("$1")}`).replace(/^\[(.*?)\]$/g,`${o.dim("[")}${o.magenta("$1")}${o.dim("]")}`).replace(/^`(.*?)`$/g,`${o.dim("`")}$1${o.dim("`")}`).replace(/^\((.*?)\)$/g,`${o.dim("(")}$1${o.dim(")")}`).replace(/^<(.*?)>$/g,`${o.dim("<")}${o.gray("$1")}${o.dim(">")}`).replace(/->/g,o.dim("\u2192")).replace(/<-/g,o.dim("\u2190")).replace(/^\$t$/g,`${o.dim(new Date().toLocaleTimeString())}`).replace(/^\*\*(.*?)\*\*$/g,`${o.bold.white("$1")}`).replace(/^~~(.*?)~~$/g,`${o.strikethrough("$1")}`).replace(/^__(.*?)__$/g,`${o.underline("$1")}`).replace(/^\.\.(.*?)\.\.$/g,`${o.dim("$1")}`).replace(/^!!(.*?)!!$/g,`${o.yellow("$1")}`).replace(/^\*(.*?)\*$/g,`${o.italic("$1")}`).replace(/^_(.*?)_$/g,`${o.italic("$1")}`).replace(/^\+(.*?)\+$/g,`${o.green("$1")}`).replace(/^-(.*?)-$/g,`${o.red("$1")}`)).join(" ")}function h(r,e){let t="";if(Array.isArray(r))for(let s=0;s<r.length;s++)t+=_(r[s])+_(e[s]);else t=[r,...e].map(s=>_(s)).join(" ");return y(t)}var _=r=>r?Array.isArray(r)?r.map(e=>{switch(typeof e){case"string":return`'${o.yellow(e)}'`;case"number":case"boolean":return o.blue(e);default:return e}}).join(o.gray(", ")):r:"",ie=(r,...e)=>{let t=o.green("+")+" "+h(r,e);return console.log(t),t},oe=(r,...e)=>{let t=o.bgRed.bold.white(" \u{1D5EB} ERROR ")+" "+h(r,e);return console.log(t),t},nr=(r,...e)=>{let t=o.bgYellow.bold.white(" \u26A0\uFE0F CONFLICT ")+" "+o.yellow(h(r,e));return console.log(t),t},ir=(r,...e)=>{let t=o.green("\u2713 ")+h(r,e);return console.log(t),t},G=(r,...e)=>{let t=o.red("-")+" "+h(r,e);return console.log(t),t},le=(r,...e)=>{let t=o.green("\u25CB ")+h(r,e);return console.log(t),t},ae=(r,...e)=>{let t=o.red("\u2717 ")+h(r,e);return console.log(t),t},ce=(r,...e)=>{let t=y("$t ")+h(r,e);return console.log(t),t},or=(r,...e)=>{let t=o.green("\u23FA Success ")+h(r,e);return console.log(t),t},lr=(r,...e)=>{let t=o.yellow("\u23FA Warn ")+h(r,e);return console.log(t),t},ar=(r,...e)=>{let t=o.bgGreen.bold.white(" \u2713 PASS ")+" "+h(r,e);return console.log(t),t},cr=r=>{console.log(ge(he(JSON.parse(JSON.stringify(r))),{spacerNeighbour:y("..\u2502..")+" ",keyNoNeighbour:y("..\u2514\u2500..")+" ",keyNeighbour:y("..\u251C\u2500..")+" ",separator:y("..:..")+" "}))};function he(r){for(let e in r){let t=r[e];Array.isArray(t)?r[e]=t.map(s=>y(`**${s}**`)).join(y("..,..")):typeof t=="object"?he(t):r[e]=y(`**${t}**`)}return r}var ur=(r,...e)=>{let t=o.red("\u23FA Fail ")+h(r,e);return console.log(t),t},gr=_e(Ge());function pr(r){let{message:e,stack:t}=typeof r=="string"?new Error(r):r,s={};return(0,gr.default)(t.replace(e,"").replace(/^Error: /,"")).split(`
10
+ `).forEach(n=>{s[n.split(" ").map(i=>i.replace(/^\((.+)\)$/,`${o.cyan("$1")}`).replace(/\./g,`${o.dim(".")}`).replace(/^at$/,l=>o.dim(l))).join(" ")]=null}),{message:e.trim().replace(/Error: /g,""),stackTree:s}}var fe=(r,...e)=>{if(r instanceof Error){let{message:t,stackTree:s}=pr(r);return console.log(""),console.log(o.bgRed.bold.white(" \u{1D5EB} ERROR ")+" "+o.bold.red(t)),console.log(ge(s,{spacerNeighbour:o.redBright.dim("\u2502\u2000\u2000"),keyNoNeighbour:o.redBright.dim("\u2514\u2500\u2000"),keyNeighbour:o.redBright.dim("\u251C\u2500 "),separator:o.redBright.dim(":\u2000")})),console.log(""),t}else{let t=h(r,e);return console.log(t),t}};Object.assign(fe,{a:ie,add:ie,d:G,del:G,delete:G,o:le,valid:le,x:ae,invalid:ae,i:ce,info:ce,e:oe,error:oe,success:or,fail:ur,warn:lr,pass:ar,conflict:nr,ok:ir,tree:cr,paint:y});var w=fe;var ve=m(require("stylelint")),R=class extends be.default{constructor(e){super(k,e)}css;extractions=new Set;get resolvedModuleId(){return"\0"+this.options.module}get moduleHMREvent(){return`HMR:${this.options.module}`}async init(){return this.extractions.clear(),console.log(""),this.css=new de.default({config:this.readConfig()}),await this.compile(),this}async compile(){if(this.options.fixedClasses?.length)for(let e of this.options.fixedClasses)this.css.insert(e);return await Promise.all(this.sources.map(async e=>{let t=me.default.readFileSync(A.default.resolve(this.options.cwd,e),{encoding:"utf-8"}).toString();await this.insert(e,t)})),this}extract(e,t){if(!e||!t||!this.checkSourcePath(e))return[];let s=[];for(let n of F({content:t,name:e},this.css))this.extractions.has(n)||(this.extractions.add(n),s.push(n));return s}async insert(e,t){let s=this.extract(e,t);if(!s.length)return!1;let n=U.performance.now(),i=[];await Promise.all(s.map(async a=>{let p=await this.createRules(a);p.length&&(this.css.insertRules(p),i.push(a))}));let l=Math.round((U.performance.now()-n)*100)/100;if(s.length&&(console.log(""),w`**${A.default.relative(this.options.cwd,e)}** ..${A.default.resolve(this.options.cwd,e)}..`,w`[extract] ${s.length} potential`),this.css.rules.length){let a=i.filter(p=>!s.includes(p));a.length&&w`[exclude] ${a.length} unknow ${a}`,w`[compile] +${i.length}+ valid inserted ${o.gray("in")} ${l}ms ${i}`,w`[virtual] ${this.css.rules.length} total ${o.gray("in")} ${this.options.module}`}return this.options.ignoredClasses?.length&&(s=s.filter(a=>{for(let p of this.options.ignoredClasses)if(typeof p=="string"){if(p===a)return!1}else if(p.test(a))return!1;return!0})),!0}async createRules(e){return(await Promise.all(this.css.create(e).map(async t=>(await ve.default.lint({code:t.text,cache:!1,config:{rules:{"color-no-invalid-hex":!0,"named-grid-areas-no-invalid":!0,"at-rule-no-unknown":!0,"function-no-unknown":!0,"media-feature-name-no-unknown":!0,"property-no-unknown":!0,"selector-pseudo-class-no-unknown":!0,"selector-pseudo-element-no-unknown":!0,"selector-type-no-unknown":!0,"unit-no-unknown":!0}}})).errored?null:t))).filter(t=>t)}get sources(){let{include:e,exclude:t,sources:s}=this.options,n=V.default.sync(e,{cwd:this.options.cwd,ignore:t});return s?.length&&n.push(...V.default.sync(s,{cwd:this.options.cwd})),n}checkSourcePath(e){let{include:t,exclude:s,sources:n}=this.options;for(let i of n)if((0,B.default)(e,i))return!0;for(let i of t)if(!(0,B.default)(e,i))return!1;for(let i of s)if((0,B.default)(e,i))return!1;return!0}get config(){return this.css.config}};0&&(module.exports={options});
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { default as MasterCSSCompiler } from './compiler';
2
- export { default as MasterCSSWebpackPlugin } from './webpack';
3
- export { default as MasterCSSVitePlugin } from './vite';
1
+ export { default } from './compiler';
2
+ export { default as options } from './options';
3
+ export type { Options, Source } from './options';
package/dist/index.mjs CHANGED
@@ -1,2 +1,10 @@
1
- var A=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,s)=>(typeof require<"u"?require:e)[s]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});import O from"path";import f from"chalk";import{defaultSemantics as j}from"@master/css";function b({content:t}){let e=t.match(/[^\s]+/g)??[],s=new Set;for(let r of e){let o=R(r);if(o.size)for(let n of o)s.add(n);else s.add($(r))}return[...s].filter(r=>r&&!D(r))}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)},R=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=R(r[2]);if(o.size)for(let n of o)e.add(n);else e.add($(r[2]))}return e},D=t=>!t||!t.match(/(?:^[\w-]+:[\w$#]+)|(?:^[@~][\w-]+$)/)&&!Object.keys(j).includes(t)||t.match(/\*\*/)||t.match(/:\[/)||t.match(/\$\{/)||t.match(/\{\{/)||t.match(/\(\{[^}]*\}/)||t.match(/<\w+>|<\/\w+>/);var H={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},T=H;import P,{configure as F,extend as q}from"@master/css";import{performance as E}from"perf_hooks";var d=class{constructor(e){this.options=e;this.options=q(T,e);let s;try{s=A(O.resolve(process.cwd(),e.config||"./master.css.js"))}catch{}this.css=new P(F(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 ${O.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.now();for(let n of e)this.css.findAndInsert(n);let r=Math.round((E.now()-s)*1e3),o=this.css.rules.map(n=>n.className);console.log(`[Master CSS] process ${f.green(e.length)} extractions in ${f.green(r)} \xB5s [${f.green(this.css.rules.length)} rules in ${f.green(O.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(o.length)} total valid classes: ${f.blue(o.join(" "))}`)}log(e,s){(this.options.debug===!0||Array.isArray(this.options.debug)&&this.options.debug.includes(e))&&console.log(s)}};import N from"path";var g="MasterCSSWebpackPlugin",M=class extends d{apply(e){let{webpack:s}=e,{Template:r,RuntimeGlobals:o,RuntimeModule:n}=s,{RawSource:S}=s.sources,{Compilation:C}=s,{options:i}=this,l=N.join(i.output.dir||"",i.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(o.publicPath),a.addRuntimeModule(m,new y(c)))};a.hooks.runtimeRequirementInTree.for(o.ensureChunkHandlers).tap(g,p),a.hooks.runtimeRequirementInTree.for(o.hmrDownloadUpdateHandlers).tap(g,p);class y 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*=\\'${x}\\'][rel=stylesheet]')`,"if (link) {",r.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:y}=e,m=[];for(let c of u){let h=c.resource,w=c._source?.source();y&&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 I from"path";import v from"fs";import _ from"path";function k(t,e,s){let r=_.dirname(t);v.existsSync(r)||v.mkdirSync(r,{recursive:!0}),v.writeFileSync(t,e,s)}function W(t){let e=new d(t),s=I.join(e.options.output.dir||"",e.options.output.name),r,o,n,S=!1,C=(i,l)=>{let x=e.extract({name:i,content:l});if(x.length){let a=e.css.text;e.insert(x);let u=e.css.text;if(u!==a&&r){k(o,u);let p=()=>{r.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(i){r=i},buildStart(){o=I.resolve(r?.config.cacheDir??process.cwd(),s),r&&(k(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){C(l,i)},transformIndexHtml(i){return i.replace(/(<head>)/,`$1<link rel="stylesheet" href="${n}">`)},async handleHotUpdate(i){C(i.file,await i.read())},generateBundle(){let i=this.emitFile({type:"asset",name:s,source:e.css.text});n="/"+this.getFileName(i)}}}export{d as MasterCSSCompiler,W as MasterCSSVitePlugin,M as MasterCSSWebpackPlugin};
2
- //# sourceMappingURL=index.mjs.map
1
+ import G from"upath";var ge={module:"master.css",config:"master.css.{ts,js,mjs,cjs}",sources:[],include:["**/*.{html,js,jsx,ts,tsx,svelte,astro,vue,md,mdx,pug,php}"],exclude:["**/node_modules/**","**/*.d.ts","**/*.test.*","node_modules","master.css.{js,ts,mjs,cjs}","dist","out","README.md"],fixedClasses:[],ignoredClasses:[]},S=ge;import Xe from"@master/css";import{performance as ae}from"perf_hooks";import{semantics as pe}from"@master/css";function A({content:r},{config:e,classes:t}){r=he(r);let s=[...new Set(Object.keys(e.semantics??pe).concat(Object.keys(t)))],n=r.match(/\S+/g)??[],i=new Set;for(let l of n){i.add(N(l,s));let a=U(l);if(a.size)for(let p of a)i.add(N(p,s))}return[...i].filter(l=>l&&!fe(l,s))}var N=(r,e)=>{let t=r,s=r.match(/(?:calc\(.*\)|\d+(?:%|ch|cm|em|ex|in|mm|pc|pt|px|rem|vh|vmax|vmin|vw|deg|grad|rad|turn|s)?)x(?:calc\(.*\)|\d+(?:%|ch|cm|em|ex|in|mm|pc|pt|px|rem|vh|vmax|vmin|vw|deg|grad|rad|turn|s)?)/g);return(s?.length?e.concat(s):e).find(n=>t.startsWith(n))?r=j(r,n=>n.replace(/^[^:@~(]*(?<!@>?)=/,"").replace(/(?:[([{\\:#=.]+|["'`].*)$/,"")):r=j(r,n=>n.replace(/^[^:@~(]*(?:["'`]|(?<!@>?)=)/,"").replace(/(?:[([{\\:#=.]+|["'`].*)$/,"")),t===r||!r?r:N(r,e)},D=r=>r.match(/((?<!\\)["'`])(?:\\\1|(?:(?!\1))[\S\s])*(?<!\\)\1/g),W=(r,e)=>(e?.forEach((t,s)=>{r=r.replace(t,`COMPLETE-STRING--${s}--`)}),r),j=(r,e)=>{let t=D(r);return r=W(r,t),r=e(r),t?.forEach((s,n)=>{r=r.replace(`COMPLETE-STRING--${n}--`,s)}),r},U=r=>{let e=new Set,t=/((?<!\\)["'`])((?:\\\1|(?:(?!\1))[\S\s])*)((?<!\\)\1)/g,s;for(;(s=t.exec(r))!==null;){s.index===t.lastIndex&&t.lastIndex++,e.add(s[2]);let n=U(s[2]);if(n.size)for(let i of n)e.add(i)}return e},he=r=>j(r,e=>e.replace(/\/\*(?:(?!\*\/)[\S\s])*\*\//g,"").replace(/<!--(?:(?!-->)[\S\s])*-->/g,"").replace(/<style[^>]*>(?:(?!<\/style>)[\S\s])*<\/style>/g,"").replace(/import.*from\s*COMPLETE-STRING--\d+--/g,"").replace(/import\s*(?:COMPLETE-STRING--\d+--|\([^;\s]*\))/g,"").replace(/require\([^;\s]*\)/g,"")),fe=(r,e)=>{let t=D(r),s=W(r,t),n=/{(.*)}/,i;for(;(i=n.exec(s))!==null;)return i[1].split(";").find(a=>Y(a,e))!==void 0;return Y(s,e)||de(r)},Y=(r,e)=>!r||!r.match(/(?:\S*\{\S*\})|(?:^[\w\-()]+:\S+)|(?:^[\w-]+\(\S+\))|(?:^[@~]\S+$)/)&&!r.match(/^(?:calc\(.*\)|\d+(?:%|ch|cm|em|ex|in|mm|pc|pt|px|rem|vh|vmax|vmin|vw|deg|grad|rad|turn|s)?)x(?:calc\(.*\)|\d+(?:%|ch|cm|em|ex|in|mm|pc|pt|px|rem|vh|vmax|vmin|vw|deg|grad|rad|turn|s)?)$/)&&!e.find(t=>r.startsWith(t))||r.match(/\*\*/)||r.match(/:\[/)||r.match(/\$\{/)||r.match(/\{\{/)||r.match(/\(\{[^}]*\}/)||r.match(/<\w+>|<\/\w+>/)||r.match(/;$/)||r.match(/^\w+:\/\//)||r.match(/^@(?:ts-[^\s]+|charset|import|namespace|media|supports|document|page|font-face|keyframes|counter-style|font-feature-values|property|layer)$/)||r.match(/^~\/.+.\w+$/)||r.match(/function\(|\(.*\)=>/),de=r=>{let e=[],t;for(let s=0;s<r.length;s++)switch(r[s]){case"(":case"[":case"{":e.push(r[s]);break;case")":case"]":case"}":if(t=e.pop(),r[s]===")"&&t!=="("||r[s]==="]"&&t!=="["||r[s]==="}"&&t!=="{")return!0;break}return e.length>0};import er from"fs";import ce from"fast-glob";import L from"minimatch";import rr from"techor";import _ from"node:process";import Ne from"node:os";import J from"node:tty";var me=Object.create,ne=Object.defineProperty,be=Object.getOwnPropertyDescriptor,ve=Object.getOwnPropertyNames,ye=Object.getPrototypeOf,xe=Object.prototype.hasOwnProperty,$e=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Oe=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ve(e))!xe.call(r,n)&&n!==t&&ne(r,n,{get:()=>e[n],enumerable:!(s=be(e,n))||s.enumerable});return r},we=(r,e,t)=>(t=r!=null?me(ye(r)):{},Oe(e||!r||!r.__esModule?ne(t,"default",{value:r,enumerable:!0}):t,r)),Ce=$e((r,e)=>{"use strict";function t(s){var n=void 0;typeof s=="string"?n=[s]:n=s.raw;for(var i="",l=0;l<n.length;l++)i+=n[l].replace(/\\\n[ \t]*/g,"").replace(/\\`/g,"`"),l<(arguments.length<=1?0:arguments.length-1)&&(i+=arguments.length<=l+1?void 0:arguments[l+1]);var a=i.split(`
2
+ `),p=null;return a.forEach(function(u){var f=u.match(/^(\s+)\S+/);if(f){var y=f[1].length;p?p=Math.min(p,y):p=y}}),p!==null&&(i=a.map(function(u){return u[0]===" "?u.slice(p):u}).join(`
3
+ `)),i=i.trim(),i.replace(/\\n/g,`
4
+ `)}typeof e<"u"&&(e.exports=t)}),m=(r,e)=>{if(!r)throw new Error(e)},Te=r=>{let e={joined:!0,spacerNoNeighbour:" ",spacerNeighbour:"\u2502 ",keyNoNeighbour:"\u2514\u2500 ",keyNeighbour:"\u251C\u2500 ",separator:": ",renderFn:t=>["boolean","string","number"].includes(typeof t)?t:void 0,sortFn:null,breakCircularWith:" (circular ref.)",...r};return m(Object.keys(e).length===9,"Unexpected Option(s) provided"),m(typeof e.joined=="boolean",'Option "joined" has invalid format'),m(typeof e.spacerNoNeighbour=="string",'Option "spacerNoNeighbour" has invalid format'),m(typeof e.spacerNeighbour=="string",'Option "spacerNeighbour" has invalid format'),m(typeof e.keyNoNeighbour=="string",'Option "keyNoNeighbour" has invalid format'),m(typeof e.keyNeighbour=="string",'Option "keyNeighbour" has invalid format'),m(typeof e.separator=="string",'Option "separator" has invalid format'),m(typeof e.renderFn=="function",'Option "renderFn" has invalid format'),m(typeof e.sortFn=="function"||e.sortFn===null,'Option "sortFn" has invalid format'),m(typeof e.breakCircularWith=="string"||e.breakCircularWith===null,'Option "breakCircularWith" has invalid format'),e},ie=(r,e={})=>{let t=Te(e),s=[],n=t.renderFn(r);n!==void 0&&s.push(String(n));let i=u=>t.sortFn===null?u.reverse():u.sort((f,y)=>t.sortFn(y,f)),l=[],a=i(Object.keys(r)).map(u=>[u]),p=[r];for(;a.length!==0;){let u=a.pop(),f=p[u.length-1][u[u.length-1]],y=t.breakCircularWith!==null&&p.includes(f);l[u.length-1]=a.length!==0&&a[a.length-1].length===u.length;let ue=t.renderFn(f);s.push([l.slice(0,u.length-1).map(k=>k?t.spacerNeighbour:t.spacerNoNeighbour).join(""),l[u.length-1]?t.keyNeighbour:t.keyNoNeighbour,u[u.length-1],ue===void 0?"":`${t.separator}${f}`,y?t.breakCircularWith:""].join("")),f instanceof Object&&!Array.isArray(f)&&!y&&(a.push(...i(Object.keys(f)).map(k=>u.concat(k))),p[u.length]=f)}return t.joined===!0?s.join(`
5
+ `):s},V=(r=0)=>e=>`\x1B[${e+r}m`,H=(r=0)=>e=>`\x1B[${38+r};5;${e}m`,q=(r=0)=>(e,t,s)=>`\x1B[${38+r};2;${e};${t};${s}m`,c={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},lr=Object.keys(c.modifier),Re=Object.keys(c.color),Ee=Object.keys(c.bgColor),ar=[...Re,...Ee];function ke(){let r=new Map;for(let[e,t]of Object.entries(c)){for(let[s,n]of Object.entries(t))c[s]={open:`\x1B[${n[0]}m`,close:`\x1B[${n[1]}m`},t[s]=c[s],r.set(n[0],n[1]);Object.defineProperty(c,e,{value:t,enumerable:!1})}return Object.defineProperty(c,"codes",{value:r,enumerable:!1}),c.color.close="\x1B[39m",c.bgColor.close="\x1B[49m",c.color.ansi=V(),c.color.ansi256=H(),c.color.ansi16m=q(),c.bgColor.ansi=V(10),c.bgColor.ansi256=H(10),c.bgColor.ansi16m=q(10),Object.defineProperties(c,{rgbToAnsi256:{value(e,t,s){return e===t&&t===s?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(s/255*5)},enumerable:!1},hexToRgb:{value(e){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[s]=t;s.length===3&&(s=[...s].map(i=>i+i).join(""));let n=Number.parseInt(s,16);return[n>>16&255,n>>8&255,n&255]},enumerable:!1},hexToAnsi256:{value:e=>c.rgbToAnsi256(...c.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,s,n;if(e>=232)t=((e-232)*10+8)/255,s=t,n=t;else{e-=16;let a=e%36;t=Math.floor(e/36)/5,s=Math.floor(a/6)/5,n=a%6/5}let i=Math.max(t,s,n)*2;if(i===0)return 30;let l=30+(Math.round(n)<<2|Math.round(s)<<1|Math.round(t));return i===2&&(l+=60),l},enumerable:!1},rgbToAnsi:{value:(e,t,s)=>c.ansi256ToAnsi(c.rgbToAnsi256(e,t,s)),enumerable:!1},hexToAnsi:{value:e=>c.ansi256ToAnsi(c.hexToAnsi256(e)),enumerable:!1}}),c}var Se=ke(),b=Se;function d(r,e=globalThis.Deno?globalThis.Deno.args:_.argv){let t=r.startsWith("-")?"":r.length===1?"-":"--",s=e.indexOf(t+r),n=e.indexOf("--");return s!==-1&&(n===-1||s<n)}var{env:g}=_,T;d("no-color")||d("no-colors")||d("color=false")||d("color=never")?T=0:(d("color")||d("colors")||d("color=true")||d("color=always"))&&(T=1);function je(){if("FORCE_COLOR"in g)return g.FORCE_COLOR==="true"?1:g.FORCE_COLOR==="false"?0:g.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(g.FORCE_COLOR,10),3)}function Ae(r){return r===0?!1:{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}function Be(r,{streamIsTTY:e,sniffFlags:t=!0}={}){let s=je();s!==void 0&&(T=s);let n=t?T:s;if(n===0)return 0;if(t){if(d("color=16m")||d("color=full")||d("color=truecolor"))return 3;if(d("color=256"))return 2}if("TF_BUILD"in g&&"AGENT_NAME"in g)return 1;if(r&&!e&&n===void 0)return 0;let i=n||0;if(g.TERM==="dumb")return i;if(_.platform==="win32"){let l=Ne.release().split(".");return Number(l[0])>=10&&Number(l[2])>=10586?Number(l[2])>=14931?3:2:1}if("CI"in g)return"GITHUB_ACTIONS"in g?3:["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(l=>l in g)||g.CI_NAME==="codeship"?1:i;if("TEAMCITY_VERSION"in g)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(g.TEAMCITY_VERSION)?1:0;if(g.COLORTERM==="truecolor"||g.TERM==="xterm-kitty")return 3;if("TERM_PROGRAM"in g){let l=Number.parseInt((g.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(g.TERM_PROGRAM){case"iTerm.app":return l>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(g.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(g.TERM)||"COLORTERM"in g?1:i}function K(r,e={}){let t=Be(r,{streamIsTTY:r&&r.isTTY,...e});return Ae(t)}var Me={stdout:K({isTTY:J.isatty(1)}),stderr:K({isTTY:J.isatty(2)})},Pe=Me;function Ie(r,e,t){let s=r.indexOf(e);if(s===-1)return r;let n=e.length,i=0,l="";do l+=r.slice(i,s)+e+t,i=s+n,s=r.indexOf(e,i);while(s!==-1);return l+=r.slice(i),l}function Fe(r,e,t,s){let n=0,i="";do{let l=r[s-1]==="\r";i+=r.slice(n,l?s-1:s)+e+(l?`\r
6
+ `:`
7
+ `)+t,n=s+1,s=r.indexOf(`
8
+ `,n)}while(s!==-1);return i+=r.slice(n),i}var{stdout:z,stderr:Z}=Pe,P=Symbol("GENERATOR"),x=Symbol("STYLER"),w=Symbol("IS_EMPTY"),Q=["ansi","ansi","ansi256","ansi16m"],$=Object.create(null),_e=(r,e={})=>{if(e.level&&!(Number.isInteger(e.level)&&e.level>=0&&e.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let t=z?z.level:0;r.level=e.level===void 0?t:e.level},Ge=r=>{let e=(...t)=>t.join(" ");return _e(e,r),Object.setPrototypeOf(e,C.prototype),e};function C(r){return Ge(r)}Object.setPrototypeOf(C.prototype,Function.prototype);for(let[r,e]of Object.entries(b))$[r]={get(){let t=R(this,F(e.open,e.close,this[x]),this[w]);return Object.defineProperty(this,r,{value:t}),t}};$.visible={get(){let r=R(this,this[x],!0);return Object.defineProperty(this,"visible",{value:r}),r}};var I=(r,e,t,...s)=>r==="rgb"?e==="ansi16m"?b[t].ansi16m(...s):e==="ansi256"?b[t].ansi256(b.rgbToAnsi256(...s)):b[t].ansi(b.rgbToAnsi(...s)):r==="hex"?I("rgb",e,t,...b.hexToRgb(...s)):b[t][r](...s),Le=["rgb","hex","ansi256"];for(let r of Le){$[r]={get(){let{level:t}=this;return function(...s){let n=F(I(r,Q[t],"color",...s),b.color.close,this[x]);return R(this,n,this[w])}}};let e="bg"+r[0].toUpperCase()+r.slice(1);$[e]={get(){let{level:t}=this;return function(...s){let n=F(I(r,Q[t],"bgColor",...s),b.bgColor.close,this[x]);return R(this,n,this[w])}}}}var Ye=Object.defineProperties(()=>{},{...$,level:{enumerable:!0,get(){return this[P].level},set(r){this[P].level=r}}}),F=(r,e,t)=>{let s,n;return t===void 0?(s=r,n=e):(s=t.openAll+r,n=e+t.closeAll),{open:r,close:e,openAll:s,closeAll:n,parent:t}},R=(r,e,t)=>{let s=(...n)=>De(s,n.length===1?""+n[0]:n.join(" "));return Object.setPrototypeOf(s,Ye),s[P]=r,s[x]=e,s[w]=t,s},De=(r,e)=>{if(r.level<=0||!e)return r[w]?"":e;let t=r[x];if(t===void 0)return e;let{openAll:s,closeAll:n}=t;if(e.includes("\x1B"))for(;t!==void 0;)e=Ie(e,t.close,t.open),t=t.parent;let i=e.indexOf(`
9
+ `);return i!==-1&&(e=Fe(e,n,s,i)),s+e+n};Object.defineProperties(C.prototype,$);var We=C(),pr=C({level:Z?Z.level:0}),o=We;function v(r){return r.split(" ").map(e=>e.replace(/^(\d*\.?\d*)$/g,`${o.blue("$1")}`).replace(/^(\d*\.?\d*)(YB|ZB|EB|PB|TB|GB|MB|KB|B|mb|kb|bit|zs|as|fs|ps|ns|µs|ms|s|m|h|d|m|y)$/g,`${o.cyan("$1")}${o.magenta("$2")}`).replace(/^((?:[0-1]?[0-9]|[2][0-3]):[0-5][0-9]:[0-5][0-9] (?:AM|PM)?)$/g,`${o.dim("$1")}`).replace(/^\[(.*?)\]$/g,`${o.dim("[")}${o.magenta("$1")}${o.dim("]")}`).replace(/^`(.*?)`$/g,`${o.dim("`")}$1${o.dim("`")}`).replace(/^\((.*?)\)$/g,`${o.dim("(")}$1${o.dim(")")}`).replace(/^<(.*?)>$/g,`${o.dim("<")}${o.gray("$1")}${o.dim(">")}`).replace(/->/g,o.dim("\u2192")).replace(/<-/g,o.dim("\u2190")).replace(/^\$t$/g,`${o.dim(new Date().toLocaleTimeString())}`).replace(/^\*\*(.*?)\*\*$/g,`${o.bold.white("$1")}`).replace(/^~~(.*?)~~$/g,`${o.strikethrough("$1")}`).replace(/^__(.*?)__$/g,`${o.underline("$1")}`).replace(/^\.\.(.*?)\.\.$/g,`${o.dim("$1")}`).replace(/^!!(.*?)!!$/g,`${o.yellow("$1")}`).replace(/^\*(.*?)\*$/g,`${o.italic("$1")}`).replace(/^_(.*?)_$/g,`${o.italic("$1")}`).replace(/^\+(.*?)\+$/g,`${o.green("$1")}`).replace(/^-(.*?)-$/g,`${o.red("$1")}`)).join(" ")}function h(r,e){let t="";if(Array.isArray(r))for(let s=0;s<r.length;s++)t+=B(r[s])+B(e[s]);else t=[r,...e].map(s=>B(s)).join(" ");return v(t)}var B=r=>r?Array.isArray(r)?r.map(e=>{switch(typeof e){case"string":return`'${o.yellow(e)}'`;case"number":case"boolean":return o.blue(e);default:return e}}).join(o.gray(", ")):r:"",X=(r,...e)=>{let t=o.green("+")+" "+h(r,e);return console.log(t),t},ee=(r,...e)=>{let t=o.bgRed.bold.white(" \u{1D5EB} ERROR ")+" "+h(r,e);return console.log(t),t},Ue=(r,...e)=>{let t=o.bgYellow.bold.white(" \u26A0\uFE0F CONFLICT ")+" "+o.yellow(h(r,e));return console.log(t),t},Ve=(r,...e)=>{let t=o.green("\u2713 ")+h(r,e);return console.log(t),t},M=(r,...e)=>{let t=o.red("-")+" "+h(r,e);return console.log(t),t},re=(r,...e)=>{let t=o.green("\u25CB ")+h(r,e);return console.log(t),t},te=(r,...e)=>{let t=o.red("\u2717 ")+h(r,e);return console.log(t),t},se=(r,...e)=>{let t=v("$t ")+h(r,e);return console.log(t),t},He=(r,...e)=>{let t=o.green("\u23FA Success ")+h(r,e);return console.log(t),t},qe=(r,...e)=>{let t=o.yellow("\u23FA Warn ")+h(r,e);return console.log(t),t},Je=(r,...e)=>{let t=o.bgGreen.bold.white(" \u2713 PASS ")+" "+h(r,e);return console.log(t),t},Ke=r=>{console.log(ie(oe(JSON.parse(JSON.stringify(r))),{spacerNeighbour:v("..\u2502..")+" ",keyNoNeighbour:v("..\u2514\u2500..")+" ",keyNeighbour:v("..\u251C\u2500..")+" ",separator:v("..:..")+" "}))};function oe(r){for(let e in r){let t=r[e];Array.isArray(t)?r[e]=t.map(s=>v(`**${s}**`)).join(v("..,..")):typeof t=="object"?oe(t):r[e]=v(`**${t}**`)}return r}var ze=(r,...e)=>{let t=o.red("\u23FA Fail ")+h(r,e);return console.log(t),t},Ze=we(Ce());function Qe(r){let{message:e,stack:t}=typeof r=="string"?new Error(r):r,s={};return(0,Ze.default)(t.replace(e,"").replace(/^Error: /,"")).split(`
10
+ `).forEach(n=>{s[n.split(" ").map(i=>i.replace(/^\((.+)\)$/,`${o.cyan("$1")}`).replace(/\./g,`${o.dim(".")}`).replace(/^at$/,l=>o.dim(l))).join(" ")]=null}),{message:e.trim().replace(/Error: /g,""),stackTree:s}}var le=(r,...e)=>{if(r instanceof Error){let{message:t,stackTree:s}=Qe(r);return console.log(""),console.log(o.bgRed.bold.white(" \u{1D5EB} ERROR ")+" "+o.bold.red(t)),console.log(ie(s,{spacerNeighbour:o.redBright.dim("\u2502\u2000\u2000"),keyNoNeighbour:o.redBright.dim("\u2514\u2500\u2000"),keyNeighbour:o.redBright.dim("\u251C\u2500 "),separator:o.redBright.dim(":\u2000")})),console.log(""),t}else{let t=h(r,e);return console.log(t),t}};Object.assign(le,{a:X,add:X,d:M,del:M,delete:M,o:re,valid:re,x:te,invalid:te,i:se,info:se,e:ee,error:ee,success:He,fail:ze,warn:qe,pass:Je,conflict:Ue,ok:Ve,tree:Ke,paint:v});var O=le;import tr from"stylelint";var E=class extends rr{constructor(e){super(S,e)}css;extractions=new Set;get resolvedModuleId(){return"\0"+this.options.module}get moduleHMREvent(){return`HMR:${this.options.module}`}async init(){return this.extractions.clear(),console.log(""),this.css=new Xe({config:this.readConfig()}),await this.compile(),this}async compile(){if(this.options.fixedClasses?.length)for(let e of this.options.fixedClasses)this.css.insert(e);return await Promise.all(this.sources.map(async e=>{let t=er.readFileSync(G.resolve(this.options.cwd,e),{encoding:"utf-8"}).toString();await this.insert(e,t)})),this}extract(e,t){if(!e||!t||!this.checkSourcePath(e))return[];let s=[];for(let n of A({content:t,name:e},this.css))this.extractions.has(n)||(this.extractions.add(n),s.push(n));return s}async insert(e,t){let s=this.extract(e,t);if(!s.length)return!1;let n=ae.now(),i=[];await Promise.all(s.map(async a=>{let p=await this.createRules(a);p.length&&(this.css.insertRules(p),i.push(a))}));let l=Math.round((ae.now()-n)*100)/100;if(s.length&&(console.log(""),O`**${G.relative(this.options.cwd,e)}** ..${G.resolve(this.options.cwd,e)}..`,O`[extract] ${s.length} potential`),this.css.rules.length){let a=i.filter(p=>!s.includes(p));a.length&&O`[exclude] ${a.length} unknow ${a}`,O`[compile] +${i.length}+ valid inserted ${o.gray("in")} ${l}ms ${i}`,O`[virtual] ${this.css.rules.length} total ${o.gray("in")} ${this.options.module}`}return this.options.ignoredClasses?.length&&(s=s.filter(a=>{for(let p of this.options.ignoredClasses)if(typeof p=="string"){if(p===a)return!1}else if(p.test(a))return!1;return!0})),!0}async createRules(e){return(await Promise.all(this.css.create(e).map(async t=>(await tr.lint({code:t.text,cache:!1,config:{rules:{"color-no-invalid-hex":!0,"named-grid-areas-no-invalid":!0,"at-rule-no-unknown":!0,"function-no-unknown":!0,"media-feature-name-no-unknown":!0,"property-no-unknown":!0,"selector-pseudo-class-no-unknown":!0,"selector-pseudo-element-no-unknown":!0,"selector-type-no-unknown":!0,"unit-no-unknown":!0}}})).errored?null:t))).filter(t=>t)}get sources(){let{include:e,exclude:t,sources:s}=this.options,n=ce.sync(e,{cwd:this.options.cwd,ignore:t});return s?.length&&n.push(...ce.sync(s,{cwd:this.options.cwd})),n}checkSourcePath(e){let{include:t,exclude:s,sources:n}=this.options;for(let i of n)if(L(e,i))return!0;for(let i of t)if(!L(e,i))return!1;for(let i of s)if(L(e,i))return!1;return!0}get config(){return this.css.config}};export{E as default,S as options};
@@ -1,16 +1,17 @@
1
- declare const defaultOptions: MasterCSSCompilerOptions;
2
- export declare type MasterCSSCompilerSource = {
1
+ import { Config } from '@master/css';
2
+ import type { Pattern as FastGlobPattern } from 'fast-glob';
3
+ import type { Options as TechorOptions } from 'techor';
4
+ declare const options: Options;
5
+ export declare type Source = {
3
6
  name: string;
4
7
  content: string;
5
8
  };
6
- export interface MasterCSSCompilerOptions {
7
- output?: {
8
- name: string;
9
- dir: string;
10
- };
11
- accept?: (source: MasterCSSCompilerSource) => boolean;
12
- extract?: (source: MasterCSSCompilerSource) => string[];
13
- config?: string;
14
- debug?: string[] | boolean;
9
+ export interface Options extends TechorOptions<Config> {
10
+ module?: string;
11
+ sources?: FastGlobPattern[];
12
+ include?: FastGlobPattern[];
13
+ exclude?: FastGlobPattern[];
14
+ fixedClasses?: string[];
15
+ ignoredClasses?: string[] | RegExp[];
15
16
  }
16
- export default defaultOptions;
17
+ export default options;
package/package.json CHANGED
@@ -1,147 +1 @@
1
- {
2
- "name": "@master/css-compiler",
3
- "license": "MIT",
4
- "description": "Compile Master CSS ahead of time with zero-configuration integration with build tools",
5
- "author": "Aoyue Design LLC.",
6
- "funding": "https://docs.master.co/css/donate",
7
- "homepage": "https://css.master.co",
8
- "repository": {
9
- "type": "git",
10
- "url": "https://github.com/master-co/css-compiler.git"
11
- },
12
- "keywords": [
13
- "webpack",
14
- "plugin",
15
- "integration",
16
- "vite",
17
- "parcel",
18
- "build tools",
19
- "css",
20
- "mastercss",
21
- "vite-plugin"
22
- ],
23
- "sideEffects": false,
24
- "scripts": {
25
- "build:cjs": "esbuild src/index.ts --bundle --outfile=dist/index.cjs --format=cjs --platform=node --external:@master/css --external:chalk",
26
- "build:esm": "esbuild src/index.ts --bundle --outfile=dist/index.mjs --format=esm --platform=node --external:@master/css --external:chalk",
27
- "dev:cjs": "npm run build:cjs -- --watch",
28
- "dev:esm": "npm run build:esm -- --watch",
29
- "prod": "rm -rf dist && npm run build:cjs -- --minify --sourcemap && npm run build:esm -- --minify --sourcemap && tsc --emitDeclarationOnly",
30
- "test": "jest",
31
- "lint": "eslint ./src"
32
- },
33
- "main": "./dist/index.cjs",
34
- "jsnext:main": "./dist/index.mjs",
35
- "browser": "./dist/index.browser.js",
36
- "esnext": "./dist/index.mjs",
37
- "module": "./dist/index.mjs",
38
- "types": "./dist/index.d.ts",
39
- "exports": {
40
- ".": {
41
- "require": "./dist/index.cjs",
42
- "import": "./dist/index.mjs",
43
- "types": "./dist/index.d.ts"
44
- }
45
- },
46
- "jest": {
47
- "testEnvironment": "node",
48
- "transform": {
49
- "^.+\\.(t|j)sx?$": "@swc/jest"
50
- },
51
- "testMatch": [
52
- "<rootDir>/tests/*.ts",
53
- "<rootDir>/src/**/*.test.ts"
54
- ]
55
- },
56
- "private": false,
57
- "publishConfig": {
58
- "access": "public"
59
- },
60
- "engines": {
61
- "node": ">=14"
62
- },
63
- "release": {
64
- "plugins": [
65
- [
66
- "@semantic-release/commit-analyzer",
67
- {
68
- "preset": "angular",
69
- "releaseRules": [
70
- {
71
- "type": "docs",
72
- "scope": "README",
73
- "release": "patch"
74
- },
75
- {
76
- "type": "refactor",
77
- "release": "patch"
78
- },
79
- {
80
- "type": "style",
81
- "release": "patch"
82
- }
83
- ],
84
- "parserOpts": {
85
- "noteKeywords": [
86
- "BREAKING CHANGE",
87
- "BREAKING CHANGES"
88
- ]
89
- }
90
- }
91
- ],
92
- "@semantic-release/release-notes-generator",
93
- [
94
- "@semantic-release/exec",
95
- {
96
- "prepareCmd": "npm run prod"
97
- }
98
- ],
99
- [
100
- "@semantic-release/github"
101
- ],
102
- [
103
- "@semantic-release/npm"
104
- ]
105
- ],
106
- "branches": [
107
- "+([0-9])?(.{+([0-9]),x}).x",
108
- "main",
109
- "next",
110
- "next-major",
111
- {
112
- "name": "beta",
113
- "prerelease": true
114
- },
115
- {
116
- "name": "alpha",
117
- "prerelease": true
118
- }
119
- ]
120
- },
121
- "files": [
122
- "dist"
123
- ],
124
- "devDependencies": {
125
- "@semantic-release/exec": "^6.0.3",
126
- "@swc/core": "^1.3.9",
127
- "@swc/jest": "^0.2.23",
128
- "@types/jest": "^29.2.0",
129
- "@types/node": "^18.11.0",
130
- "@types/webpack": "^5.28.0",
131
- "@typescript-eslint/eslint-plugin": "^5.40.1",
132
- "@typescript-eslint/parser": "^5.40.1",
133
- "esbuild": "^0.15.10",
134
- "eslint": "^8.25.0",
135
- "jest": "^29.2.2",
136
- "semantic-release": "^19.0.5",
137
- "typescript": "^4.8.4",
138
- "vite": "^3.1.8"
139
- },
140
- "peerDependencies": {
141
- "@master/css": "^2.0.0-beta.8"
142
- },
143
- "dependencies": {
144
- "chalk": "^5.1.2"
145
- },
146
- "version": "2.0.0-beta.10"
147
- }
1
+ {"name":"@master/css-compiler","scripts":{"build":"aron pack --platform=node","dev":"npm run build -- --watch","lint":"eslint ./src","test":"jest"},"license":"MIT","description":"The ahead-of-time compiler of Master CSS","author":"Aoyue Design LLC.","funding":"https://docs.master.co/css/donate","homepage":"https://css.master.co","bugs":{"url":"https://github.com/master-co/css/issues"},"repository":{"type":"git","url":"https://github.com/master-co/css.git","directory":"packages/compiler"},"keywords":["webpack","plugin","integration","vite","parcel","build tools","css","mastercss","vite-plugin"],"sideEffects":false,"main":"./dist/index.cjs","jsnext:main":"./dist/index.mjs","esnext":"./dist/index.mjs","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"require":"./dist/index.cjs","import":"./dist/index.mjs","types":"./dist/index.d.ts"}},"files":["dist"],"publishConfig":{"access":"public"},"dependencies":{"@master/css":"^2.0.0-beta.100","fast-glob":"^3.2.12","minimatch":"^5.1.1","stylelint":"^14.16.0","techor":"^1.0.5","upath":"^2.0.1"},"version":"2.0.0-beta.100"}
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- The MIT License
2
-
3
- Copyright (c) Aoyue Design LLC.
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
@@ -1,7 +0,0 @@
1
- {
2
- "version": 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, { 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?: 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 } 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,oBCD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ME,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
- "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
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 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, { 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?: 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 } 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": "6PAAA,OAAOA,MAAU,OACjB,OAAOC,MAAW,QCDlB,OAAS,oBAAAC,MAAwB,cAGlB,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,C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AQ,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", "configure", "extend", "performance", "MasterCSSCompiler", "options", "extend", "options_default", "userConfig", "__require", "path", "MasterCSS", "configure", "name", "content", "eachExtractions", "eachNewExtraction", "extractions", "p1", "performance", "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
- }
@@ -1,2 +0,0 @@
1
- import type { MasterCSSCompilerSource } from './index';
2
- export default function extract({ content }: MasterCSSCompilerSource): string[];
@@ -1,4 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import fs from 'fs';
4
- export default function writeFile(filePath: string, data: string | NodeJS.ArrayBufferView, options?: fs.WriteFileOptions): void;
package/dist/vite.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import type { MasterCSSCompilerOptions } from './options';
2
- import type { PluginOption } from 'vite';
3
- export default function (options?: MasterCSSCompilerOptions): PluginOption;
package/dist/webpack.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import MasterCSSCompiler from './compiler';
2
- import type { Compiler } from 'webpack';
3
- export default class MasterCSSWebpackPlugin extends MasterCSSCompiler {
4
- apply(compiler: Compiler): void;
5
- }
package/readme.md DELETED
@@ -1,80 +0,0 @@
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
- [![MIT License](https://flat.badgen.net/github/license/master-co/css?color=yellow)](https://github.com/master-co/css-compiler/blob/main/LICENSE)
13
- [![Latest Release](https://flat.badgen.net/npm/v/@master/css-compiler?icon=npm&label&color=yellow)](https://www.npmjs.com/package/@master/css-compiler)
14
- [![Documentation](https://flat.badgen.net/badge/icon/Documentation?icon=awesome&label&color=yellow)](https://css.master.co)
15
- [![Github](https://flat.badgen.net/badge/icon/master-co%2Fcss-compiler?icon=github&label&color=yellow)](https://github.com/master-co/css)
16
- [![Discord](https://flat.badgen.net/badge/icon/discord?icon=discord&label&color=yellow)](https://discord.gg/sZNKpAAAw6)
17
- [![CI](https://flat.badgen.net/github/status/master-co/css-compiler/main/ci/circleci?icon=circleci)](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