@master/css-compiler 2.0.0-beta.12 → 2.0.0-beta.120

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,158 @@
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()
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.*',
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
+ classes: {
94
+ // whitelist of class names for unpredictable dynamics
95
+ fixed: [],
96
+ // blacklist of class names to exclude accidentally captured
97
+ ignored: [] // or RegExp[]
98
+ },
99
+ cwd: process.cwd()
100
+ }
101
+ ```
30
102
 
31
- # Usage
103
+ ## Methods
32
104
 
33
- ## `webpack.config.js`
34
- ```js
35
- const { MasterCSSWebpackPlugin } = require('@master/css-compiler')
105
+ ```ts
106
+ // Reload the compiler and MasterCSS
107
+ refresh(): this
108
+ ```
36
109
 
37
- module.exports = {
38
- plugins: [
39
- new MasterCSSWebpackPlugin()
40
- ]
41
- };
110
+ ```ts
111
+ // Scan sources, extract class names, and generate CSS rules
112
+ compile()
42
113
  ```
43
114
 
44
- ## `vite.config.js`
45
- ```js
46
- import { MasterCSSVitePlugin } from '@master/css-compiler'
115
+ ```ts
116
+ // Extract potential class names from the given file content
117
+ extract(name: string, content: string): string[]
118
+ ```
47
119
 
48
- export default defineConfig({
49
- plugins: [
50
- MasterCSSVitePlugin()
51
- ]
52
- })
120
+ ```ts
121
+ // `extract(name, content)`, insert extractions, and generate CSS rules
122
+ insert(name: string, content: string): boolean
53
123
  ```
54
124
 
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
- }
125
+ ```ts
126
+ // Read file source paths by `options.include` and `options.exclude`
127
+ get sources(): string[]
128
+ ```
72
129
 
73
- module.exports = nextConfig
130
+ ```ts
131
+ // Check source file path by `options.include` and `options.exclude`
132
+ checkSourcePath(name: string): boolean
74
133
  ```
75
134
 
76
- ---
135
+ ```ts
136
+ // Read user config file by `options.config`
137
+ readConfig(): Config
138
+ ```
77
139
 
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
140
+ ```ts
141
+ // Get user config path
142
+ get configPath(): string
143
+ ```
144
+
145
+ ```ts
146
+ // Get resolved user config path
147
+ get resolvedConfigPath(): string
148
+ ```
149
+
150
+ ## Properties
151
+
152
+ ```ts
153
+ export default class MasterCSSCompiler {
154
+ css: MasterCSS
155
+ extractions = new Set<string>()
156
+ ...
157
+ }
158
+ ```
@@ -0,0 +1,10 @@
1
+ var me=Object.create;var C=Object.defineProperty;var be=Object.getOwnPropertyDescriptor;var ve=Object.getOwnPropertyNames;var ye=Object.getPrototypeOf,$e=Object.prototype.hasOwnProperty;var Oe=(r,t)=>{for(var e in t)C(r,e,{get:t[e],enumerable:!0})},U=(r,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ve(t))!$e.call(r,n)&&n!==e&&C(r,n,{get:()=>t[n],enumerable:!(o=be(t,n))||o.enumerable});return r};var d=(r,t,e)=>(e=r!=null?me(ye(r)):{},U(t||!r||!r.__esModule?C(e,"default",{value:r,enumerable:!0}):e,r)),we=r=>U(C({},"__esModule",{value:!0}),r);var it={};Oe(it,{MasterCSSCompiler:()=>V});module.exports=we(it);var _=d(require("upath")),L=d(require("./options")),Y=d(require("@master/css")),G=require("perf_hooks"),ge=d(require("./extract")),he=d(require("fs")),D=d(require("fast-glob")),B=d(require("minimatch")),fe=d(require("techor"));var k=d(require("node:process"),1),se=d(require("node:os"),1),P=d(require("node:tty"),1),xe=Object.create,ie=Object.defineProperty,Re=Object.getOwnPropertyDescriptor,Te=Object.getOwnPropertyNames,Ce=Object.getPrototypeOf,Ee=Object.prototype.hasOwnProperty,Ne=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),ke=(r,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Te(t))!Ee.call(r,n)&&n!==e&&ie(r,n,{get:()=>t[n],enumerable:!(o=Re(t,n))||o.enumerable});return r},Be=(r,t,e)=>(e=r!=null?xe(Ce(r)):{},ke(t||!r||!r.r?ie(e,"default",{value:r,enumerable:!0}):e,r)),je=Ne((r,t)=>{"use strict";function e(o){var n=void 0;typeof o=="string"?n=[o]:n=o.raw;for(var l="",s=0;s<n.length;s++)l+=n[s].replace(/\\\n[ \t]*/g,"").replace(/\\`/g,"`"),s<(arguments.length<=1?0:arguments.length-1)&&(l+=arguments.length<=s+1?void 0:arguments[s+1]);var h=l.split(`
2
+ `),c=null;return h.forEach(function(a){var p=a.match(/^(\s+)\S+/);if(p){var O=p[1].length;c?c=Math.min(c,O):c=O}}),c!==null&&(l=h.map(function(a){return a[0]===" "?a.slice(c):a}).join(`
3
+ `)),l=l.trim(),l.replace(/\\n/g,`
4
+ `)}typeof t<"u"&&(t.exports=e)}),b=(r,t)=>{if(!r)throw new Error(t)},Ae=r=>{let t={joined:!0,spacerNoNeighbour:" ",spacerNeighbour:"\u2502 ",keyNoNeighbour:"\u2514\u2500 ",keyNeighbour:"\u251C\u2500 ",separator:": ",renderFn:e=>["boolean","string","number"].includes(typeof e)?e:void 0,sortFn:null,breakCircularWith:" (circular ref.)",...r};return b(Object.keys(t).length===9,"Unexpected Option(s) provided"),b(typeof t.joined=="boolean",'Option "joined" has invalid format'),b(typeof t.spacerNoNeighbour=="string",'Option "spacerNoNeighbour" has invalid format'),b(typeof t.spacerNeighbour=="string",'Option "spacerNeighbour" has invalid format'),b(typeof t.keyNoNeighbour=="string",'Option "keyNoNeighbour" has invalid format'),b(typeof t.keyNeighbour=="string",'Option "keyNeighbour" has invalid format'),b(typeof t.separator=="string",'Option "separator" has invalid format'),b(typeof t.renderFn=="function",'Option "renderFn" has invalid format'),b(typeof t.sortFn=="function"||t.sortFn===null,'Option "sortFn" has invalid format'),b(typeof t.breakCircularWith=="string"||t.breakCircularWith===null,'Option "breakCircularWith" has invalid format'),t},le=(r,t={})=>{let e=Ae(t),o=[],n=e.renderFn(r);n!==void 0&&o.push(String(n));let l=a=>e.sortFn===null?a.reverse():a.sort((p,O)=>e.sortFn(O,p)),s=[],h=l(Object.keys(r)).map(a=>[a]),c=[r];for(;h.length!==0;){let a=h.pop(),p=c[a.length-1][a[a.length-1]],O=e.breakCircularWith!==null&&c.includes(p);s[a.length-1]=h.length!==0&&h[h.length-1].length===a.length;let pe=e.renderFn(p);o.push([s.slice(0,a.length-1).map(j=>j?e.spacerNeighbour:e.spacerNoNeighbour).join(""),s[a.length-1]?e.keyNeighbour:e.keyNoNeighbour,a[a.length-1],pe===void 0?"":`${e.separator}${p}`,O?e.breakCircularWith:""].join("")),p instanceof Object&&!Array.isArray(p)&&!O&&(h.push(...l(Object.keys(p)).map(j=>a.concat(j))),c[a.length]=p)}return e.joined===!0?o.join(`
5
+ `):o},z=(r=0)=>t=>`\x1B[${t+r}m`,J=(r=0)=>t=>`\x1B[${38+r};5;${t}m`,K=(r=0)=>(t,e,o)=>`\x1B[${38+r};2;${t};${e};${o}m`,u={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]}},st=Object.keys(u.modifier),Me=Object.keys(u.color),Pe=Object.keys(u.bgColor),at=[...Me,...Pe];function Fe(){let r=new Map;for(let[t,e]of Object.entries(u)){for(let[o,n]of Object.entries(e))u[o]={open:`\x1B[${n[0]}m`,close:`\x1B[${n[1]}m`},e[o]=u[o],r.set(n[0],n[1]);Object.defineProperty(u,t,{value:e,enumerable:!1})}return Object.defineProperty(u,"codes",{value:r,enumerable:!1}),u.color.close="\x1B[39m",u.bgColor.close="\x1B[49m",u.color.ansi=z(),u.color.ansi256=J(),u.color.ansi16m=K(),u.bgColor.ansi=z(10),u.bgColor.ansi256=J(10),u.bgColor.ansi16m=K(10),Object.defineProperties(u,{rgbToAnsi256:{value(t,e,o){return t===e&&e===o?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(e/255*5)+Math.round(o/255*5)},enumerable:!1},hexToRgb:{value(t){let e=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!e)return[0,0,0];let[o]=e;o.length===3&&(o=[...o].map(l=>l+l).join(""));let n=Number.parseInt(o,16);return[n>>16&255,n>>8&255,n&255]},enumerable:!1},hexToAnsi256:{value:t=>u.rgbToAnsi256(...u.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let e,o,n;if(t>=232)e=((t-232)*10+8)/255,o=e,n=e;else{t-=16;let h=t%36;e=Math.floor(t/36)/5,o=Math.floor(h/6)/5,n=h%6/5}let l=Math.max(e,o,n)*2;if(l===0)return 30;let s=30+(Math.round(n)<<2|Math.round(o)<<1|Math.round(e));return l===2&&(s+=60),s},enumerable:!1},rgbToAnsi:{value:(t,e,o)=>u.ansi256ToAnsi(u.rgbToAnsi256(t,e,o)),enumerable:!1},hexToAnsi:{value:t=>u.ansi256ToAnsi(u.hexToAnsi256(t)),enumerable:!1}}),u}var Ie=Fe(),v=Ie;function m(r,t=globalThis.Deno?globalThis.Deno.args:k.default.argv){let e=r.startsWith("-")?"":r.length===1?"-":"--",o=t.indexOf(e+r),n=t.indexOf("--");return o!==-1&&(n===-1||o<n)}var{env:g}=k.default,E;m("no-color")||m("no-colors")||m("color=false")||m("color=never")?E=0:(m("color")||m("colors")||m("color=true")||m("color=always"))&&(E=1);function Se(){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 _e(r){return r===0?!1:{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}function Le(r,{streamIsTTY:t,sniffFlags:e=!0}={}){let o=Se();o!==void 0&&(E=o);let n=e?E:o;if(n===0)return 0;if(e){if(m("color=16m")||m("color=full")||m("color=truecolor"))return 3;if(m("color=256"))return 2}if("TF_BUILD"in g&&"AGENT_NAME"in g)return 1;if(r&&!t&&n===void 0)return 0;let l=n||0;if(g.TERM==="dumb")return l;if(k.default.platform==="win32"){let s=se.default.release().split(".");return Number(s[0])>=10&&Number(s[2])>=10586?Number(s[2])>=14931?3:2:1}if("CI"in g)return"GITHUB_ACTIONS"in g?3:["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(s=>s in g)||g.CI_NAME==="codeship"?1:l;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 s=Number.parseInt((g.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(g.TERM_PROGRAM){case"iTerm.app":return s>=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:l}function Z(r,t={}){let e=Le(r,{streamIsTTY:r&&r.isTTY,...t});return _e(e)}var Ye={stdout:Z({isTTY:P.default.isatty(1)}),stderr:Z({isTTY:P.default.isatty(2)})},Ge=Ye;function De(r,t,e){let o=r.indexOf(t);if(o===-1)return r;let n=t.length,l=0,s="";do s+=r.slice(l,o)+t+e,l=o+n,o=r.indexOf(t,l);while(o!==-1);return s+=r.slice(l),s}function We(r,t,e,o){let n=0,l="";do{let s=r[o-1]==="\r";l+=r.slice(n,s?o-1:o)+t+(s?`\r
6
+ `:`
7
+ `)+e,n=o+1,o=r.indexOf(`
8
+ `,n)}while(o!==-1);return l+=r.slice(n),l}var{stdout:H,stderr:X}=Ge,F=Symbol("GENERATOR"),w=Symbol("STYLER"),R=Symbol("IS_EMPTY"),q=["ansi","ansi","ansi256","ansi16m"],x=Object.create(null),Ve=(r,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let e=H?H.level:0;r.level=t.level===void 0?e:t.level},Ue=r=>{let t=(...e)=>e.join(" ");return Ve(t,r),Object.setPrototypeOf(t,T.prototype),t};function T(r){return Ue(r)}Object.setPrototypeOf(T.prototype,Function.prototype);for(let[r,t]of Object.entries(v))x[r]={get(){let e=N(this,S(t.open,t.close,this[w]),this[R]);return Object.defineProperty(this,r,{value:e}),e}};x.visible={get(){let r=N(this,this[w],!0);return Object.defineProperty(this,"visible",{value:r}),r}};var I=(r,t,e,...o)=>r==="rgb"?t==="ansi16m"?v[e].ansi16m(...o):t==="ansi256"?v[e].ansi256(v.rgbToAnsi256(...o)):v[e].ansi(v.rgbToAnsi(...o)):r==="hex"?I("rgb",t,e,...v.hexToRgb(...o)):v[e][r](...o),ze=["rgb","hex","ansi256"];for(let r of ze){x[r]={get(){let{level:e}=this;return function(...o){let n=S(I(r,q[e],"color",...o),v.color.close,this[w]);return N(this,n,this[R])}}};let t="bg"+r[0].toUpperCase()+r.slice(1);x[t]={get(){let{level:e}=this;return function(...o){let n=S(I(r,q[e],"bgColor",...o),v.bgColor.close,this[w]);return N(this,n,this[R])}}}}var Je=Object.defineProperties(()=>{},{...x,level:{enumerable:!0,get(){return this[F].level},set(r){this[F].level=r}}}),S=(r,t,e)=>{let o,n;return e===void 0?(o=r,n=t):(o=e.openAll+r,n=t+e.closeAll),{open:r,close:t,openAll:o,closeAll:n,parent:e}},N=(r,t,e)=>{let o=(...n)=>Ke(o,n.length===1?""+n[0]:n.join(" "));return Object.setPrototypeOf(o,Je),o[F]=r,o[w]=t,o[R]=e,o},Ke=(r,t)=>{if(r.level<=0||!t)return r[R]?"":t;let e=r[w];if(e===void 0)return t;let{openAll:o,closeAll:n}=e;if(t.includes("\x1B"))for(;e!==void 0;)t=De(t,e.close,e.open),e=e.parent;let l=t.indexOf(`
9
+ `);return l!==-1&&(t=We(t,n,o,l)),o+t+n};Object.defineProperties(T.prototype,x);var Ze=T(),ct=T({level:X?X.level:0}),i=Ze;function y(r){return r.split(" ").map(t=>t.replace(/^(\d*\.?\d*)$/g,`${i.blue("$1")}`).replace(/^(\d*\.?\d*)(YB|ZB|EB|PB|TB|GB|MB|KB|B|mb|kb|kB|bit|zs|as|fs|ps|ns|µs|ms|s|m|h|d|m|y)$/g,`${i.cyan("$1")}${i.magenta("$2")}`).replace(/^((?:[0-1]?[0-9]|[2][0-3]):[0-5][0-9]:[0-5][0-9] (?:AM|PM)?)$/g,`${i.dim("$1")}`).replace(/^\[(.*?)\]$/g,`${i.dim("[")}${i.magenta("$1")}${i.dim("]")}`).replace(/^`(.*?)`$/g,`${i.dim("`")}$1${i.dim("`")}`).replace(/^\((.*?)\)$/g,`${i.dim("(")}$1${i.dim(")")}`).replace(/^<(.*?)>$/g,`${i.dim("<")}${i.gray("$1")}${i.dim(">")}`).replace(/->/g,i.dim("\u2192")).replace(/<-/g,i.dim("\u2190")).replace(/^\$t$/g,`${i.dim(new Date().toLocaleTimeString())}`).replace(/^\*\*(.*?)\*\*$/g,`${i.bold.white("$1")}`).replace(/^~~(.*?)~~$/g,`${i.strikethrough("$1")}`).replace(/^__(.*?)__$/g,`${i.underline("$1")}`).replace(/^\.\.(.*?)\.\.$/g,`${i.dim("$1")}`).replace(/^!!(.*?)!!$/g,`${i.yellow("$1")}`).replace(/^\*(.*?)\*$/g,`${i.italic("$1")}`).replace(/^_(.*?)_$/g,`${i.italic("$1")}`).replace(/^\+(.*?)\+$/g,`${i.green("$1")}`).replace(/^-(.*?)-$/g,`${i.red("$1")}`)).join(" ")}function f(r,t){let e="";if(Array.isArray(r))for(let o=0;o<r.length;o++)e+=A(r[o])+A(t[o]);else e=[r,...t].map(o=>A(o)).join(" ");return y(e)}var A=r=>r?Array.isArray(r)?r.map(t=>{switch(typeof t){case"string":return`'${i.yellow(t)}'`;case"number":case"boolean":return i.blue(t);default:return t}}).join(i.gray(", ")):r:"",Q=(r,...t)=>{let e=i.green("+")+" "+f(r,t);return console.log(e),e},ee=(r,...t)=>{let e=i.bgRed.bold.white(" \u{1D5EB} ERROR ")+" "+f(r,t);return console.log(e),e},He=(r,...t)=>{let e=i.bgYellow.bold.white(" \u26A0\uFE0F CONFLICT ")+" "+i.yellow(f(r,t));return console.log(e),e},Xe=(r,...t)=>{let e=i.green("\u2713 ")+f(r,t);return console.log(e),e},M=(r,...t)=>{let e=i.red("-")+" "+f(r,t);return console.log(e),e},te=(r,...t)=>{let e=i.green("\u25CB ")+f(r,t);return console.log(e),e},re=(r,...t)=>{let e=i.red("\u2717 ")+f(r,t);return console.log(e),e},oe=(r,...t)=>{let e=i.cyan("\u{1D4F2}")+" "+f(r,t);return console.log(e),e},qe=(r,...t)=>{let e=i.green("\u23FA Success ")+f(r,t);return console.log(e),e},Qe=(r,...t)=>{let e=i.yellow("\u23FA Warn ")+f(r,t);return console.log(e),e},et=(r,...t)=>{let e=i.bgGreen.bold.white(" \u2713 PASS ")+" "+f(r,t);return console.log(e),e},tt=r=>{let t=le(ce(ae(JSON.parse(JSON.stringify(r)))),{spacerNeighbour:y("..\u2502..")+" ",keyNoNeighbour:y("..\u2514\u2500..")+" ",keyNeighbour:y("..\u251C\u2500..")+" ",separator:y("..:..")+" "});return console.log(t),t};function ae(r){for(let t in r){let e=r[t];typeof e=="object"?e!==null&&!Object.keys(e).length?delete r[t]:r[t]=ae(e):e===void 0&&delete r[t]}return r}function ce(r){for(let t in r){let e=r[t];Array.isArray(e)?r[t]=e.map(o=>y(`**${o}**`)).join(y("..,..")):typeof e=="object"?ce(e):r[t]=y(`**${e}**`)}return r}var rt=(r,...t)=>{let e=i.red("\u23FA Fail ")+f(r,t);return console.log(e),e},ne=(r,...t)=>{let e=y("$t ")+f(r,t);return console.log(e),e},ot=Be(je());function nt(r){let{message:t,stack:e}=typeof r=="string"?new Error(r):r,o={};return(0,ot.default)(e.replace(t,"").replace(/^Error: /,"")).split(`
10
+ `).forEach(n=>{o[n.split(" ").map(l=>l.replace(/^\((.+)\)$/,`${i.cyan("$1")}`).replace(/\./g,`${i.dim(".")}`).replace(/^at$/,s=>i.dim(s))).join(" ")]=null}),{message:t.trim().replace(/Error: /g,""),stackTree:o}}var ue=(r,...t)=>{if(r instanceof Error){let{message:e,stackTree:o}=nt(r);return console.log(""),console.log(i.bgRed.bold.white(" \u{1D5EB} ERROR ")+" "+i.bold.red(e)),console.log(le(o,{spacerNeighbour:i.redBright.dim("\u2502\u2000\u2000"),keyNoNeighbour:i.redBright.dim("\u2514\u2500\u2000"),keyNeighbour:i.redBright.dim("\u251C\u2500 "),separator:i.redBright.dim(":\u2000")})),console.log(""),e}else{let e=f(r,t);return console.log(e),e}};Object.assign(ue,{a:Q,add:Q,d:M,del:M,delete:M,o:te,valid:te,x:re,invalid:re,i:oe,info:oe,e:ee,error:ee,t:ne,timestamp:ne,success:qe,fail:rt,warn:Qe,pass:et,conflict:He,ok:Xe,tree:tt,paint:y});var $=ue;var de=d(require("stylelint")),W=d(require("to-extend")),V=class extends fe.default{constructor(e){super(L.default,e);this.customOptions=e;let o=this.readConfig(null);this.options=(0,W.default)(this.options,o?.compilerOptions,e),this.css=o?.css??new Y.default(o?.config)}css;extractions=new Set;validExtractions=new Set;invalidExtractions=new Set;logConfigFound=e=>$.ok`**${e}** definition file found`;logConfigNotFound=e=>$.i`No **${e}** definition file found`;get resolvedModuleId(){return"\0"+this.options.module}get moduleHMREvent(){return`HMR:${this.options.module}`}async refresh(){this.extractions.clear(),this.validExtractions.clear(),this.invalidExtractions.clear(),console.log("");let e=this.readConfig(null);return this.css=new Y.default(e?.config),this.options=(0,W.default)({cwd:this.options.cwd},L.default,e?.compilerOptions,this.customOptions),await this.compile(),this}async compile(){if(this.options.classes?.fixed?.length)for(let e of this.options.classes.fixed)this.css.insert(e);return await Promise.all(this.sources.map(async e=>{let o=he.default.readFileSync(_.default.resolve(this.options.cwd,e),{encoding:"utf-8"}).toString();await this.insert(e,o)})),this}extract(e,o){if(!e||!o||!this.checkSourcePath(e))return[];let n=[];for(let l of(0,ge.default)({content:o,name:e},this.css))this.extractions.has(l)||(this.extractions.add(l),n.push(l));return n}async insert(e,o){let n=this.extract(e,o);if(!n.length)return!1;this.invalidExtractions.size&&(n=n.filter(c=>!this.invalidExtractions.has(c))),this.validExtractions.size&&(n=n.filter(c=>!this.validExtractions.has(c))),this.options.classes?.ignored?.length&&(n=n.filter(c=>{for(let a of this.options.classes.ignored)if(typeof a=="string"){if(a===c)return!1}else if(a.test(c))return!1;return!0}));let l=G.performance.now(),s=[];await Promise.all(n.map(async c=>{let a=await this.createRules(c);a.length?(this.css.insertRules(a),s.push(c),this.validExtractions.add(c)):this.invalidExtractions.add(c)}));let h=Math.round((G.performance.now()-l)*100)/100;if(n.length&&(console.log(""),$`**${_.default.relative(this.options.cwd,e)}**`,$`[extract] ${n.length} potential`),this.css.rules.length){let c=s.filter(a=>!n.includes(a));c.length&&$`[exclude] ${c.length} unknown ${c}`,$`[compile] +${s.length}+ valid inserted ${i.gray("in")} ${h}ms ${s}`,$`[virtual] ${this.css.rules.length} total ${i.gray("in")} ${this.options.module}`}return!0}async createRules(e){return(await Promise.all(this.css.create(e).map(async n=>(await de.default.lint({code:n.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:n))).filter(n=>n)}get sources(){let{include:e,exclude:o,sources:n}=this.options,l=D.default.sync(e,{cwd:this.options.cwd,ignore:o});return n?.length&&l.push(...D.default.sync(n,{cwd:this.options.cwd})),l}checkSourcePath(e){let{include:o,exclude:n,sources:l}=this.options;for(let s of l)if((0,B.default)(e,s))return!0;for(let s of o)if(!(0,B.default)(e,s))return!1;for(let s of n)if((0,B.default)(e,s))return!1;return!0}get config(){return this.css.config}};0&&(module.exports={MasterCSSCompiler});
@@ -0,0 +1 @@
1
+ var l=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var v=(r,e)=>{for(var t in e)l(r,t,{get:e[t],enumerable:!0})},C=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of w(e))!E.call(r,a)&&a!==t&&l(r,a,{get:()=>e[a],enumerable:!(s=x(e,a))||s.enumerable});return r};var k=r=>C(l({},"__esModule",{value:!0}),r);var R={};v(R,{default:()=>d});module.exports=k(R);var u=require("@master/css");function d({content:r},{config:e,classes:t}){r=y(r);let s=[...new Set(Object.keys(e.semantics??u.semantics).concat(Object.keys(t)))],a=r.match(/\S+/g)??[],c=new Set;for(let i of a){c.add(g(i,s));let m=f(i);if(m.size)for(let S of m)c.add(g(S,s))}return[...c].filter(i=>i&&!$(i,s))}var g=(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(a=>t.startsWith(a))?r=p(r,a=>a.replace(/^[^:@~(]*(?<!@>?)=/,"").replace(/(?:[([{\\:#=.]+|["'`].*)$/,"")):r=p(r,a=>a.replace(/^[^:@~(]*(?:["'`]|(?<!@>?)=)/,"").replace(/(?:[([{\\:#=.]+|["'`].*)$/,"")),t===r||!r?r:g(r,e)},h=r=>r.match(/((?<!\\)["'`])(?:\\\1|(?:(?!\1))[\S\s])*(?<!\\)\1/g),o=(r,e)=>(e?.forEach((t,s)=>{r=r.replace(t,`COMPLETE-STRING--${s}--`)}),r),p=(r,e)=>{let t=h(r);return r=o(r,t),r=e(r),t?.forEach((s,a)=>{r=r.replace(`COMPLETE-STRING--${a}--`,s)}),r},f=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 a=f(s[2]);if(a.size)for(let c of a)e.add(c)}return e},y=r=>p(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|import)\([^;\s]*\)/g,"").replace(/(?:@.*\n)+(?:export|function|class)/g,"")),$=(r,e)=>{let t=h(r),s=o(r,t),a=/{(.*)}/,c;for(;(c=a.exec(s))!==null;)return c[1].split(";").find(m=>n(m,e))!==void 0;return n(s,e)||T(r)},n=(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\(|\(.*\)=>/)||r.match(/^\$\(.*/),T=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};0&&(module.exports={});
@@ -0,0 +1 @@
1
+ var n=Object.create;var r=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var m=Object.getPrototypeOf,u=Object.prototype.hasOwnProperty;var S=(o,t)=>{for(var e in t)r(o,e,{get:t[e],enumerable:!0})},a=(o,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let p of l(t))!u.call(o,p)&&p!==e&&r(o,p,{get:()=>t[p],enumerable:!(s=x(t,p))||s.enumerable});return o};var c=(o,t,e)=>(e=o!=null?n(m(o)):{},a(t||!o||!o.__esModule?r(e,"default",{value:o,enumerable:!0}):e,o)),d=o=>a(r({},"__esModule",{value:!0}),o);var y={};S(y,{MasterCSSCompiler:()=>f,default:()=>C,options:()=>i.default});module.exports=d(y);var i=c(require("./options")),f={},C=f;0&&(module.exports={MasterCSSCompiler,options});
@@ -0,0 +1 @@
1
+ var m=Object.create;var p=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var C=Object.getPrototypeOf,n=Object.prototype.hasOwnProperty;var u=(o,e)=>{for(var r in e)p(o,r,{get:e[r],enumerable:!0})},f=(o,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of l(e))!n.call(o,t)&&t!==r&&p(o,t,{get:()=>e[t],enumerable:!(a=S(e,t))||a.enumerable});return o};var x=(o,e,r)=>(r=o!=null?m(C(o)):{},f(e||!o||!o.__esModule?p(r,"default",{value:o,enumerable:!0}):r,o)),d=o=>f(p({},"__esModule",{value:!0}),o);var M={};u(M,{MasterCSSCompiler:()=>s.MasterCSSCompiler,default:()=>s.MasterCSSCompiler,options:()=>i.default});module.exports=d(M);var i=x(require("./options")),s=require("./compiler");0&&(module.exports={MasterCSSCompiler,options});
@@ -0,0 +1 @@
1
+ var r=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var d=(e,t)=>{for(var o in t)r(e,o,{get:t[o],enumerable:!0})},l=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of a(t))!c.call(e,s)&&s!==o&&r(e,s,{get:()=>t[s],enumerable:!(n=i(t,s))||n.enumerable});return e};var p=e=>l(r({},"__esModule",{value:!0}),e);var g={};d(g,{default:()=>u});module.exports=p(g);var m={module:"master.css",config:"master.css.*",sources:[],include:["**/*.{html,js,jsx,ts,tsx,svelte,astro,vue,md,mdx,pug,php}"],exclude:["**/node_modules/**","**/*.d.ts","**/*.test.*","**/*.config.*","node_modules","master.css.*","dist","out","styles","public","README.md"],classes:{fixed:[],ignored:[]}},u=m;0&&(module.exports={});
@@ -1,11 +1,24 @@
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 declare class MasterCSSCompiler extends Techor<Options, Config> {
6
+ protected customOptions?: 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
+ validExtractions: Set<string>;
10
+ invalidExtractions: Set<string>;
11
+ logConfigFound: (configPath: string) => void;
12
+ logConfigNotFound: (configPath: string) => void;
13
+ get resolvedModuleId(): string;
14
+ get moduleHMREvent(): string;
15
+ constructor(customOptions?: Options);
16
+ refresh(): Promise<this>;
17
+ compile(): Promise<this>;
18
+ extract(name: string, content: string): string[];
19
+ insert(name: string, content: string): Promise<boolean>;
20
+ createRules(extraction: string): Promise<Rule[]>;
21
+ get sources(): string[];
22
+ checkSourcePath(name: string): boolean;
23
+ get config(): Config;
11
24
  }
@@ -0,0 +1,10 @@
1
+ import ee from"upath";import{default as te}from"./options";import re from"@master/css";import{performance as oe}from"perf_hooks";import Ue from"./extract";import ze from"fs";import ne from"fast-glob";import P from"minimatch";import Je from"techor";import M from"node:process";import we from"node:os";import _ from"node:tty";var ae=Object.create,Z=Object.defineProperty,ce=Object.getOwnPropertyDescriptor,ue=Object.getOwnPropertyNames,ge=Object.getPrototypeOf,he=Object.prototype.hasOwnProperty,fe=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),de=(r,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ue(t))!he.call(r,n)&&n!==e&&Z(r,n,{get:()=>t[n],enumerable:!(o=ce(t,n))||o.enumerable});return r},pe=(r,t,e)=>(e=r!=null?ae(ge(r)):{},de(t||!r||!r.r?Z(e,"default",{value:r,enumerable:!0}):e,r)),me=fe((r,t)=>{"use strict";function e(o){var n=void 0;typeof o=="string"?n=[o]:n=o.raw;for(var l="",s=0;s<n.length;s++)l+=n[s].replace(/\\\n[ \t]*/g,"").replace(/\\`/g,"`"),s<(arguments.length<=1?0:arguments.length-1)&&(l+=arguments.length<=s+1?void 0:arguments[s+1]);var h=l.split(`
2
+ `),c=null;return h.forEach(function(a){var d=a.match(/^(\s+)\S+/);if(d){var $=d[1].length;c?c=Math.min(c,$):c=$}}),c!==null&&(l=h.map(function(a){return a[0]===" "?a.slice(c):a}).join(`
3
+ `)),l=l.trim(),l.replace(/\\n/g,`
4
+ `)}typeof t<"u"&&(t.exports=e)}),m=(r,t)=>{if(!r)throw new Error(t)},be=r=>{let t={joined:!0,spacerNoNeighbour:" ",spacerNeighbour:"\u2502 ",keyNoNeighbour:"\u2514\u2500 ",keyNeighbour:"\u251C\u2500 ",separator:": ",renderFn:e=>["boolean","string","number"].includes(typeof e)?e:void 0,sortFn:null,breakCircularWith:" (circular ref.)",...r};return m(Object.keys(t).length===9,"Unexpected Option(s) provided"),m(typeof t.joined=="boolean",'Option "joined" has invalid format'),m(typeof t.spacerNoNeighbour=="string",'Option "spacerNoNeighbour" has invalid format'),m(typeof t.spacerNeighbour=="string",'Option "spacerNeighbour" has invalid format'),m(typeof t.keyNoNeighbour=="string",'Option "keyNoNeighbour" has invalid format'),m(typeof t.keyNeighbour=="string",'Option "keyNeighbour" has invalid format'),m(typeof t.separator=="string",'Option "separator" has invalid format'),m(typeof t.renderFn=="function",'Option "renderFn" has invalid format'),m(typeof t.sortFn=="function"||t.sortFn===null,'Option "sortFn" has invalid format'),m(typeof t.breakCircularWith=="string"||t.breakCircularWith===null,'Option "breakCircularWith" has invalid format'),t},H=(r,t={})=>{let e=be(t),o=[],n=e.renderFn(r);n!==void 0&&o.push(String(n));let l=a=>e.sortFn===null?a.reverse():a.sort((d,$)=>e.sortFn($,d)),s=[],h=l(Object.keys(r)).map(a=>[a]),c=[r];for(;h.length!==0;){let a=h.pop(),d=c[a.length-1][a[a.length-1]],$=e.breakCircularWith!==null&&c.includes(d);s[a.length-1]=h.length!==0&&h[h.length-1].length===a.length;let se=e.renderFn(d);o.push([s.slice(0,a.length-1).map(E=>E?e.spacerNeighbour:e.spacerNoNeighbour).join(""),s[a.length-1]?e.keyNeighbour:e.keyNoNeighbour,a[a.length-1],se===void 0?"":`${e.separator}${d}`,$?e.breakCircularWith:""].join("")),d instanceof Object&&!Array.isArray(d)&&!$&&(h.push(...l(Object.keys(d)).map(E=>a.concat(E))),c[a.length]=d)}return e.joined===!0?o.join(`
5
+ `):o},F=(r=0)=>t=>`\x1B[${t+r}m`,I=(r=0)=>t=>`\x1B[${38+r};5;${t}m`,S=(r=0)=>(t,e,o)=>`\x1B[${38+r};2;${t};${e};${o}m`,u={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]}},Ze=Object.keys(u.modifier),ve=Object.keys(u.color),ye=Object.keys(u.bgColor),He=[...ve,...ye];function $e(){let r=new Map;for(let[t,e]of Object.entries(u)){for(let[o,n]of Object.entries(e))u[o]={open:`\x1B[${n[0]}m`,close:`\x1B[${n[1]}m`},e[o]=u[o],r.set(n[0],n[1]);Object.defineProperty(u,t,{value:e,enumerable:!1})}return Object.defineProperty(u,"codes",{value:r,enumerable:!1}),u.color.close="\x1B[39m",u.bgColor.close="\x1B[49m",u.color.ansi=F(),u.color.ansi256=I(),u.color.ansi16m=S(),u.bgColor.ansi=F(10),u.bgColor.ansi256=I(10),u.bgColor.ansi16m=S(10),Object.defineProperties(u,{rgbToAnsi256:{value(t,e,o){return t===e&&e===o?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(e/255*5)+Math.round(o/255*5)},enumerable:!1},hexToRgb:{value(t){let e=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!e)return[0,0,0];let[o]=e;o.length===3&&(o=[...o].map(l=>l+l).join(""));let n=Number.parseInt(o,16);return[n>>16&255,n>>8&255,n&255]},enumerable:!1},hexToAnsi256:{value:t=>u.rgbToAnsi256(...u.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let e,o,n;if(t>=232)e=((t-232)*10+8)/255,o=e,n=e;else{t-=16;let h=t%36;e=Math.floor(t/36)/5,o=Math.floor(h/6)/5,n=h%6/5}let l=Math.max(e,o,n)*2;if(l===0)return 30;let s=30+(Math.round(n)<<2|Math.round(o)<<1|Math.round(e));return l===2&&(s+=60),s},enumerable:!1},rgbToAnsi:{value:(t,e,o)=>u.ansi256ToAnsi(u.rgbToAnsi256(t,e,o)),enumerable:!1},hexToAnsi:{value:t=>u.ansi256ToAnsi(u.hexToAnsi256(t)),enumerable:!1}}),u}var Oe=$e(),b=Oe;function p(r,t=globalThis.Deno?globalThis.Deno.args:M.argv){let e=r.startsWith("-")?"":r.length===1?"-":"--",o=t.indexOf(e+r),n=t.indexOf("--");return o!==-1&&(n===-1||o<n)}var{env:g}=M,T;p("no-color")||p("no-colors")||p("color=false")||p("color=never")?T=0:(p("color")||p("colors")||p("color=true")||p("color=always"))&&(T=1);function xe(){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 Re(r){return r===0?!1:{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}function Te(r,{streamIsTTY:t,sniffFlags:e=!0}={}){let o=xe();o!==void 0&&(T=o);let n=e?T:o;if(n===0)return 0;if(e){if(p("color=16m")||p("color=full")||p("color=truecolor"))return 3;if(p("color=256"))return 2}if("TF_BUILD"in g&&"AGENT_NAME"in g)return 1;if(r&&!t&&n===void 0)return 0;let l=n||0;if(g.TERM==="dumb")return l;if(M.platform==="win32"){let s=we.release().split(".");return Number(s[0])>=10&&Number(s[2])>=10586?Number(s[2])>=14931?3:2:1}if("CI"in g)return"GITHUB_ACTIONS"in g?3:["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(s=>s in g)||g.CI_NAME==="codeship"?1:l;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 s=Number.parseInt((g.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(g.TERM_PROGRAM){case"iTerm.app":return s>=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:l}function L(r,t={}){let e=Te(r,{streamIsTTY:r&&r.isTTY,...t});return Re(e)}var Ce={stdout:L({isTTY:_.isatty(1)}),stderr:L({isTTY:_.isatty(2)})},Ee=Ce;function Ne(r,t,e){let o=r.indexOf(t);if(o===-1)return r;let n=t.length,l=0,s="";do s+=r.slice(l,o)+t+e,l=o+n,o=r.indexOf(t,l);while(o!==-1);return s+=r.slice(l),s}function ke(r,t,e,o){let n=0,l="";do{let s=r[o-1]==="\r";l+=r.slice(n,s?o-1:o)+t+(s?`\r
6
+ `:`
7
+ `)+e,n=o+1,o=r.indexOf(`
8
+ `,n)}while(o!==-1);return l+=r.slice(n),l}var{stdout:Y,stderr:G}=Ee,B=Symbol("GENERATOR"),O=Symbol("STYLER"),x=Symbol("IS_EMPTY"),D=["ansi","ansi","ansi256","ansi16m"],w=Object.create(null),Be=(r,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let e=Y?Y.level:0;r.level=t.level===void 0?e:t.level},je=r=>{let t=(...e)=>e.join(" ");return Be(t,r),Object.setPrototypeOf(t,R.prototype),t};function R(r){return je(r)}Object.setPrototypeOf(R.prototype,Function.prototype);for(let[r,t]of Object.entries(b))w[r]={get(){let e=C(this,A(t.open,t.close,this[O]),this[x]);return Object.defineProperty(this,r,{value:e}),e}};w.visible={get(){let r=C(this,this[O],!0);return Object.defineProperty(this,"visible",{value:r}),r}};var j=(r,t,e,...o)=>r==="rgb"?t==="ansi16m"?b[e].ansi16m(...o):t==="ansi256"?b[e].ansi256(b.rgbToAnsi256(...o)):b[e].ansi(b.rgbToAnsi(...o)):r==="hex"?j("rgb",t,e,...b.hexToRgb(...o)):b[e][r](...o),Ae=["rgb","hex","ansi256"];for(let r of Ae){w[r]={get(){let{level:e}=this;return function(...o){let n=A(j(r,D[e],"color",...o),b.color.close,this[O]);return C(this,n,this[x])}}};let t="bg"+r[0].toUpperCase()+r.slice(1);w[t]={get(){let{level:e}=this;return function(...o){let n=A(j(r,D[e],"bgColor",...o),b.bgColor.close,this[O]);return C(this,n,this[x])}}}}var Me=Object.defineProperties(()=>{},{...w,level:{enumerable:!0,get(){return this[B].level},set(r){this[B].level=r}}}),A=(r,t,e)=>{let o,n;return e===void 0?(o=r,n=t):(o=e.openAll+r,n=t+e.closeAll),{open:r,close:t,openAll:o,closeAll:n,parent:e}},C=(r,t,e)=>{let o=(...n)=>Pe(o,n.length===1?""+n[0]:n.join(" "));return Object.setPrototypeOf(o,Me),o[B]=r,o[O]=t,o[x]=e,o},Pe=(r,t)=>{if(r.level<=0||!t)return r[x]?"":t;let e=r[O];if(e===void 0)return t;let{openAll:o,closeAll:n}=e;if(t.includes("\x1B"))for(;e!==void 0;)t=Ne(t,e.close,e.open),e=e.parent;let l=t.indexOf(`
9
+ `);return l!==-1&&(t=ke(t,n,o,l)),o+t+n};Object.defineProperties(R.prototype,w);var Fe=R(),et=R({level:G?G.level:0}),i=Fe;function v(r){return r.split(" ").map(t=>t.replace(/^(\d*\.?\d*)$/g,`${i.blue("$1")}`).replace(/^(\d*\.?\d*)(YB|ZB|EB|PB|TB|GB|MB|KB|B|mb|kb|kB|bit|zs|as|fs|ps|ns|µs|ms|s|m|h|d|m|y)$/g,`${i.cyan("$1")}${i.magenta("$2")}`).replace(/^((?:[0-1]?[0-9]|[2][0-3]):[0-5][0-9]:[0-5][0-9] (?:AM|PM)?)$/g,`${i.dim("$1")}`).replace(/^\[(.*?)\]$/g,`${i.dim("[")}${i.magenta("$1")}${i.dim("]")}`).replace(/^`(.*?)`$/g,`${i.dim("`")}$1${i.dim("`")}`).replace(/^\((.*?)\)$/g,`${i.dim("(")}$1${i.dim(")")}`).replace(/^<(.*?)>$/g,`${i.dim("<")}${i.gray("$1")}${i.dim(">")}`).replace(/->/g,i.dim("\u2192")).replace(/<-/g,i.dim("\u2190")).replace(/^\$t$/g,`${i.dim(new Date().toLocaleTimeString())}`).replace(/^\*\*(.*?)\*\*$/g,`${i.bold.white("$1")}`).replace(/^~~(.*?)~~$/g,`${i.strikethrough("$1")}`).replace(/^__(.*?)__$/g,`${i.underline("$1")}`).replace(/^\.\.(.*?)\.\.$/g,`${i.dim("$1")}`).replace(/^!!(.*?)!!$/g,`${i.yellow("$1")}`).replace(/^\*(.*?)\*$/g,`${i.italic("$1")}`).replace(/^_(.*?)_$/g,`${i.italic("$1")}`).replace(/^\+(.*?)\+$/g,`${i.green("$1")}`).replace(/^-(.*?)-$/g,`${i.red("$1")}`)).join(" ")}function f(r,t){let e="";if(Array.isArray(r))for(let o=0;o<r.length;o++)e+=N(r[o])+N(t[o]);else e=[r,...t].map(o=>N(o)).join(" ");return v(e)}var N=r=>r?Array.isArray(r)?r.map(t=>{switch(typeof t){case"string":return`'${i.yellow(t)}'`;case"number":case"boolean":return i.blue(t);default:return t}}).join(i.gray(", ")):r:"",W=(r,...t)=>{let e=i.green("+")+" "+f(r,t);return console.log(e),e},V=(r,...t)=>{let e=i.bgRed.bold.white(" \u{1D5EB} ERROR ")+" "+f(r,t);return console.log(e),e},Ie=(r,...t)=>{let e=i.bgYellow.bold.white(" \u26A0\uFE0F CONFLICT ")+" "+i.yellow(f(r,t));return console.log(e),e},Se=(r,...t)=>{let e=i.green("\u2713 ")+f(r,t);return console.log(e),e},k=(r,...t)=>{let e=i.red("-")+" "+f(r,t);return console.log(e),e},U=(r,...t)=>{let e=i.green("\u25CB ")+f(r,t);return console.log(e),e},z=(r,...t)=>{let e=i.red("\u2717 ")+f(r,t);return console.log(e),e},J=(r,...t)=>{let e=i.cyan("\u{1D4F2}")+" "+f(r,t);return console.log(e),e},_e=(r,...t)=>{let e=i.green("\u23FA Success ")+f(r,t);return console.log(e),e},Le=(r,...t)=>{let e=i.yellow("\u23FA Warn ")+f(r,t);return console.log(e),e},Ye=(r,...t)=>{let e=i.bgGreen.bold.white(" \u2713 PASS ")+" "+f(r,t);return console.log(e),e},Ge=r=>{let t=H(q(X(JSON.parse(JSON.stringify(r)))),{spacerNeighbour:v("..\u2502..")+" ",keyNoNeighbour:v("..\u2514\u2500..")+" ",keyNeighbour:v("..\u251C\u2500..")+" ",separator:v("..:..")+" "});return console.log(t),t};function X(r){for(let t in r){let e=r[t];typeof e=="object"?e!==null&&!Object.keys(e).length?delete r[t]:r[t]=X(e):e===void 0&&delete r[t]}return r}function q(r){for(let t in r){let e=r[t];Array.isArray(e)?r[t]=e.map(o=>v(`**${o}**`)).join(v("..,..")):typeof e=="object"?q(e):r[t]=v(`**${e}**`)}return r}var De=(r,...t)=>{let e=i.red("\u23FA Fail ")+f(r,t);return console.log(e),e},K=(r,...t)=>{let e=v("$t ")+f(r,t);return console.log(e),e},We=pe(me());function Ve(r){let{message:t,stack:e}=typeof r=="string"?new Error(r):r,o={};return(0,We.default)(e.replace(t,"").replace(/^Error: /,"")).split(`
10
+ `).forEach(n=>{o[n.split(" ").map(l=>l.replace(/^\((.+)\)$/,`${i.cyan("$1")}`).replace(/\./g,`${i.dim(".")}`).replace(/^at$/,s=>i.dim(s))).join(" ")]=null}),{message:t.trim().replace(/Error: /g,""),stackTree:o}}var Q=(r,...t)=>{if(r instanceof Error){let{message:e,stackTree:o}=Ve(r);return console.log(""),console.log(i.bgRed.bold.white(" \u{1D5EB} ERROR ")+" "+i.bold.red(e)),console.log(H(o,{spacerNeighbour:i.redBright.dim("\u2502\u2000\u2000"),keyNoNeighbour:i.redBright.dim("\u2514\u2500\u2000"),keyNeighbour:i.redBright.dim("\u251C\u2500 "),separator:i.redBright.dim(":\u2000")})),console.log(""),e}else{let e=f(r,t);return console.log(e),e}};Object.assign(Q,{a:W,add:W,d:k,del:k,delete:k,o:U,valid:U,x:z,invalid:z,i:J,info:J,e:V,error:V,t:K,timestamp:K,success:_e,fail:De,warn:Le,pass:Ye,conflict:Ie,ok:Se,tree:Ge,paint:v});var y=Q;import Ke from"stylelint";import ie from"to-extend";var le=class extends Je{constructor(e){super(te,e);this.customOptions=e;let o=this.readConfig(null);this.options=ie(this.options,o?.compilerOptions,e),this.css=o?.css??new re(o?.config)}css;extractions=new Set;validExtractions=new Set;invalidExtractions=new Set;logConfigFound=e=>y.ok`**${e}** definition file found`;logConfigNotFound=e=>y.i`No **${e}** definition file found`;get resolvedModuleId(){return"\0"+this.options.module}get moduleHMREvent(){return`HMR:${this.options.module}`}async refresh(){this.extractions.clear(),this.validExtractions.clear(),this.invalidExtractions.clear(),console.log("");let e=this.readConfig(null);return this.css=new re(e?.config),this.options=ie({cwd:this.options.cwd},te,e?.compilerOptions,this.customOptions),await this.compile(),this}async compile(){if(this.options.classes?.fixed?.length)for(let e of this.options.classes.fixed)this.css.insert(e);return await Promise.all(this.sources.map(async e=>{let o=ze.readFileSync(ee.resolve(this.options.cwd,e),{encoding:"utf-8"}).toString();await this.insert(e,o)})),this}extract(e,o){if(!e||!o||!this.checkSourcePath(e))return[];let n=[];for(let l of Ue({content:o,name:e},this.css))this.extractions.has(l)||(this.extractions.add(l),n.push(l));return n}async insert(e,o){let n=this.extract(e,o);if(!n.length)return!1;this.invalidExtractions.size&&(n=n.filter(c=>!this.invalidExtractions.has(c))),this.validExtractions.size&&(n=n.filter(c=>!this.validExtractions.has(c))),this.options.classes?.ignored?.length&&(n=n.filter(c=>{for(let a of this.options.classes.ignored)if(typeof a=="string"){if(a===c)return!1}else if(a.test(c))return!1;return!0}));let l=oe.now(),s=[];await Promise.all(n.map(async c=>{let a=await this.createRules(c);a.length?(this.css.insertRules(a),s.push(c),this.validExtractions.add(c)):this.invalidExtractions.add(c)}));let h=Math.round((oe.now()-l)*100)/100;if(n.length&&(console.log(""),y`**${ee.relative(this.options.cwd,e)}**`,y`[extract] ${n.length} potential`),this.css.rules.length){let c=s.filter(a=>!n.includes(a));c.length&&y`[exclude] ${c.length} unknown ${c}`,y`[compile] +${s.length}+ valid inserted ${i.gray("in")} ${h}ms ${s}`,y`[virtual] ${this.css.rules.length} total ${i.gray("in")} ${this.options.module}`}return!0}async createRules(e){return(await Promise.all(this.css.create(e).map(async n=>(await Ke.lint({code:n.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:n))).filter(n=>n)}get sources(){let{include:e,exclude:o,sources:n}=this.options,l=ne.sync(e,{cwd:this.options.cwd,ignore:o});return n?.length&&l.push(...ne.sync(n,{cwd:this.options.cwd})),l}checkSourcePath(e){let{include:o,exclude:n,sources:l}=this.options;for(let s of l)if(P(e,s))return!0;for(let s of o)if(!P(e,s))return!1;for(let s of n)if(P(e,s))return!1;return!0}get config(){return this.css.config}};export{le as MasterCSSCompiler};
@@ -0,0 +1 @@
1
+ import{semantics as o}from"@master/css";function f({content:r},{config:s,classes:t}){r=S(r);let e=[...new Set(Object.keys(s.semantics??o).concat(Object.keys(t)))],a=r.match(/\S+/g)??[],c=new Set;for(let i of a){c.add(l(i,e));let m=d(i);if(m.size)for(let h of m)c.add(l(h,e))}return[...c].filter(i=>i&&!x(i,e))}var l=(r,s)=>{let t=r,e=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(e?.length?s.concat(e):s).find(a=>t.startsWith(a))?r=g(r,a=>a.replace(/^[^:@~(]*(?<!@>?)=/,"").replace(/(?:[([{\\:#=.]+|["'`].*)$/,"")):r=g(r,a=>a.replace(/^[^:@~(]*(?:["'`]|(?<!@>?)=)/,"").replace(/(?:[([{\\:#=.]+|["'`].*)$/,"")),t===r||!r?r:l(r,s)},n=r=>r.match(/((?<!\\)["'`])(?:\\\1|(?:(?!\1))[\S\s])*(?<!\\)\1/g),u=(r,s)=>(s?.forEach((t,e)=>{r=r.replace(t,`COMPLETE-STRING--${e}--`)}),r),g=(r,s)=>{let t=n(r);return r=u(r,t),r=s(r),t?.forEach((e,a)=>{r=r.replace(`COMPLETE-STRING--${a}--`,e)}),r},d=r=>{let s=new Set,t=/((?<!\\)["'`])((?:\\\1|(?:(?!\1))[\S\s])*)((?<!\\)\1)/g,e;for(;(e=t.exec(r))!==null;){e.index===t.lastIndex&&t.lastIndex++,s.add(e[2]);let a=d(e[2]);if(a.size)for(let c of a)s.add(c)}return s},S=r=>g(r,s=>s.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|import)\([^;\s]*\)/g,"").replace(/(?:@.*\n)+(?:export|function|class)/g,"")),x=(r,s)=>{let t=n(r),e=u(r,t),a=/{(.*)}/,c;for(;(c=a.exec(e))!==null;)return c[1].split(";").find(m=>p(m,s))!==void 0;return p(e,s)||w(r)},p=(r,s)=>!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)?)$/)&&!s.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\(|\(.*\)=>/)||r.match(/^\$\(.*/),w=r=>{let s=[],t;for(let e=0;e<r.length;e++)switch(r[e]){case"(":case"[":case"{":s.push(r[e]);break;case")":case"]":case"}":if(t=s.pop(),r[e]===")"&&t!=="("||r[e]==="]"&&t!=="["||r[e]==="}"&&t!=="{")return!0;break}return s.length>0};export{f as default};
@@ -0,0 +1 @@
1
+ import{default as r}from"./options";var o={},t=o;export{o as MasterCSSCompiler,t as default,r as options};
@@ -0,0 +1 @@
1
+ import{default as r}from"./options";import{MasterCSSCompiler as p,MasterCSSCompiler as s}from"./compiler";export{s as MasterCSSCompiler,p as default,r as options};
@@ -0,0 +1 @@
1
+ var t={module:"master.css",config:"master.css.*",sources:[],include:["**/*.{html,js,jsx,ts,tsx,svelte,astro,vue,md,mdx,pug,php}"],exclude:["**/node_modules/**","**/*.d.ts","**/*.test.*","**/*.config.*","node_modules","master.css.*","dist","out","styles","public","README.md"],classes:{fixed:[],ignored:[]}},e=t;export{e as default};
@@ -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.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 as options } from './options';
2
+ export type { Options, Source } from './options';
3
+ export { MasterCSSCompiler as default, MasterCSSCompiler } from './compiler';
@@ -0,0 +1,4 @@
1
+ export { default as options } from './options';
2
+ export type { Options, Source } from './options';
3
+ export declare const MasterCSSCompiler: {};
4
+ export default MasterCSSCompiler;
@@ -1,16 +1,20 @@
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;
9
+ export interface Options extends TechorOptions<Config> {
10
+ output?: string;
11
+ module?: string;
12
+ sources?: FastGlobPattern[];
13
+ include?: FastGlobPattern[];
14
+ exclude?: FastGlobPattern[];
15
+ classes?: {
16
+ fixed?: string[];
17
+ ignored?: string[] | RegExp[];
10
18
  };
11
- accept?: (source: MasterCSSCompilerSource) => boolean;
12
- extract?: (source: MasterCSSCompilerSource) => string[];
13
- config?: string;
14
- debug?: string[] | boolean;
15
19
  }
16
- export default defaultOptions;
20
+ export default options;
package/package.json CHANGED
@@ -1,145 +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.11",
142
- "chalk": "^4.0.0"
143
- },
144
- "version": "2.0.0-beta.12"
145
- }
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/cjs/index.js","jsnext:main":"./dist/esm/index.js","esnext":"./dist/esm/index.js","module":"./dist/esm/index.js","types":"./dist/index.d.ts","exports":{".":{"node":{"require":"./dist/cjs/index.js","import":"./dist/esm/index.js","types":"./dist/index.d.ts"},"require":"./dist/cjs/index.default.js","import":"./dist/esm/index.default.js","types":"./dist/index.default.d.ts"}},"files":["dist"],"publishConfig":{"access":"public"},"dependencies":{"@master/css":"^2.0.0-beta.120","fast-glob":"^3.2.12","minimatch":"^5.1.1","stylelint":"^15.2.0","techor":"^1.1.4","to-extend":"^1.5.2","upath":"^2.0.1"},"devDependencies":{"@swc-node/jest":"^1.6.2","ts-jest":"^29.0.5"},"version":"2.0.0-beta.120"}
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.
package/dist/index.cjs DELETED
@@ -1,2 +0,0 @@
1
- var _=Object.create;var y=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)y(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&&y(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?y(s,"default",{value:t,enumerable:!0}):s,t)),V=t=>j(y({},"__esModule",{value:!0}),t);var K={};G(K,{MasterCSSCompiler:()=>m,MasterCSSVitePlugin:()=>N,MasterCSSWebpackPlugin:()=>C});module.exports=V(K);var b=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 $=h(require("@master/css")),E=require("perf_hooks"),m=class{constructor(e){this.options=e;this.options=(0,$.extend)(P,e);let s;try{s=require(b.default.resolve(process.cwd(),e.config||"./master.css.js"))}catch{}this.css=new $.default(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 ${b.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(b.default.join(this.options.output.dir,this.options.output.name))}]`),this.log("extractions",` \u2192 ${p.default.green(e.length)} extractions: ${p.default.blue(e.join(" "))}`),this.log("validClasses",` \u2192 ${p.default.green(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 S="MasterCSSWebpackPlugin",C=class extends m{apply(e){let{webpack:s}=e,{Template:r,RuntimeGlobals:o,RuntimeModule:n}=s,{RawSource:x}=s.sources,{Compilation:w}=s,{options:i}=this,l=F.default.join(i.output.dir||"",i.output.name),M=l.replace(/\\/g,"/");e.hooks.thisCompilation.tap(S,a=>{let u=new WeakSet,f=(d,c)=>{u.has(d)||(u.add(d),c.add(o.publicPath),a.addRuntimeModule(d,new A(c)))};a.hooks.runtimeRequirementInTree.for(o.ensureChunkHandlers).tap(S,f),a.hooks.runtimeRequirementInTree.for(o.hmrDownloadUpdateHandlers).tap(S,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*=\\'${M}\\'][rel=stylesheet]')`,"if (link) {",r.indent(["link.href = link.href.replace(/ts=[0-9]+/, 'ts=' + Date.now())"]),"}"]):""}}}),e.hooks.compilation.tap(S,a=>{a.hooks.finishModules.tap(S,u=>{let{modifiedFiles:f,watching:A}=e,d=[];for(let c of u){let g=c.resource,k=c._source?.source();A&&f?.size&&!f.has(g)||d.push(...this.extract({name:g,content:k}))}if(d.length){let c=this.css.text;this.insert(d);let g=this.css.text;if(g!==c){let k=new x(g);a.getAsset(l)?a.updateAsset(l,k):a.emitAsset(l,k)}}}),a.hooks.processAssets.tap({name:S,stage:w.PROCESS_ASSETS_STAGE_ADDITIONS},()=>{a.chunks.forEach(u=>{u.files.add(l)})})})}};var I=h(require("path"));var 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,x=!1,w=(i,l)=>{let M=e.extract({name:i,content:l});if(M.length){let a=e.css.text;e.insert(M);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()}]})};x?f():(setTimeout(f,500),x=!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){w(l,i)},transformIndexHtml(i){return i.replace(/(<head>)/,`$1<link rel="stylesheet" href="${n}">`)},async handleHotUpdate(i){w(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,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, { 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(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 f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EAAS,OAAOW,CAAe,EAE/B,IAAME,EAAUb,EAAS,IAAI,KAC7B,GAAIa,IAAYD,GACRR,EAAQ,CACRU,EAAUT,EAAgBQ,CAAO,EAEjC,IAAME,EAAS,IAAM,CACjBX,EAAO,GAAG,KAAK,CACX,KAAM,SACN,QAAS,CAAC,CACN,KAAME,EACN,UAAW,KAAK,IAAI,CACxB,CAAC,CACL,CAAC,CACL,EAEIC,EACAQ,EAAO,GAEP,WAAWA,EAAQ,GAAG,EAEtBR,EAAW,GAEnB,CAER,CACJ,EAEA,MAAO,CACH,KAAM,yBACN,QAAS,MACT,gBAAgBS,EAAS,CACrBZ,EAASY,CACb,EACA,YAAa,CACTX,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
- }
package/dist/index.mjs DELETED
@@ -1,2 +0,0 @@
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,{extend as F}from"@master/css";import{performance as E}from"perf_hooks";var d=class{constructor(e){this.options=e;this.options=F(T,e);let s;try{s=A(O.resolve(process.cwd(),e.config||"./master.css.js"))}catch{}this.css=new P(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 q 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=q.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 N from"path";function k(t,e,s){let r=N.dirname(t);v.existsSync(r)||v.mkdirSync(r,{recursive:!0}),v.writeFileSync(t,e,s)}function _(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,_ as MasterCSSVitePlugin,M as MasterCSSWebpackPlugin};
2
- //# sourceMappingURL=index.mjs.map
@@ -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, { 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(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,CAAC,CAErC,CACA,MAAO,CAAC,GAAGD,CAAO,EAAE,OAAOM,GAAKA,GAAK,CAACC,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AAO,SAAS,mBAAmB,EACnC,MAAO,KAAOA,CACtB,EACA,UAAUC,EAAMC,EAAI,CAChBX,EAAQW,EAAID,CAAI,CACpB,EACA,mBAAmBE,EAAM,CACrB,OAAOA,EAAK,QACR,WACA,kCAAkCd,KACtC,CACJ,EACA,MAAM,gBAAgBe,EAAY,CAC9Bb,EAAQa,EAAW,KAAM,MAAMA,EAAW,KAAK,CAAC,CACpD,EACA,gBAAiB,CACb,IAAMC,EAAc,KAAK,SAAS,CAC9B,KAAM,QACN,KAAMpB,EACN,OAAQF,EAAS,IAAI,IACzB,CAAC,EACDM,EAAW,IAAM,KAAK,YAAYgB,CAAW,CACjD,CACJ,CACJ",
6
- "names": ["path", "chalk", "defaultSemantics", "extract", "content", "blocks", "strings", "block", "result", "peelString", "string", "trimString", "x", "checkToExclude", "originContent", "stringRegx", "m", "defaultOptions", "name", "extract", "options_default", "MasterCSS", "extend", "performance", "MasterCSSCompiler", "options", "extend", "options_default", "userConfig", "__require", "path", "MasterCSS", "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