@master/css-compiler 2.0.0-beta.15 → 2.0.0-beta.150
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 +1 -80
- package/dist/compiler.d.ts +25 -9
- package/dist/constants/index.d.ts +3 -0
- package/dist/constants/options-esm-text.d.ts +1 -0
- package/dist/constants/options-text.d.ts +1 -0
- package/dist/constants/options-ts-text.d.ts +1 -0
- package/dist/default.d.ts +5 -0
- package/dist/extract.d.ts +3 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.js +38 -0
- package/dist/options/index.d.ts +16 -11
- package/dist/options/index.js +1 -0
- package/package.json +1 -147
- package/LICENSE +0 -21
- package/dist/index.cjs +0 -2
- package/dist/index.cjs.map +0 -7
- package/dist/index.mjs +0 -2
- package/dist/index.mjs.map +0 -7
- package/dist/options/extract.d.ts +0 -2
- package/dist/utils/write-file.d.ts +0 -4
- package/dist/vite.d.ts +0 -3
- package/dist/webpack.d.ts +0 -5
- package/readme.md +0 -80
package/README.md
CHANGED
|
@@ -1,80 +1 @@
|
|
|
1
|
-
|
|
2
|
-
<div align="center">
|
|
3
|
-
|
|
4
|
-
<p align="center">
|
|
5
|
-
<img src="https://raw.githubusercontent.com/master-co/package/document/images/logo-and-text.svg" alt="logo" width="142">
|
|
6
|
-
</p>
|
|
7
|
-
<p align="center">
|
|
8
|
-
<b><!-- name -->CSS Compiler<!----></b>
|
|
9
|
-
</p>
|
|
10
|
-
<p align="center"><!-- package.description -->Compile Master CSS ahead of time with zero-configuration integration with build tools<!----></p>
|
|
11
|
-
|
|
12
|
-
[](https://github.com/master-co/css-compiler/blob/main/LICENSE)
|
|
13
|
-
[](https://www.npmjs.com/package/@master/css-compiler)
|
|
14
|
-
[](https://css.master.co)
|
|
15
|
-
[](https://github.com/master-co/css)
|
|
16
|
-
[](https://discord.gg/sZNKpAAAw6)
|
|
17
|
-
[](https://circleci.com/gh/master-co/workflows/css-compiler/tree/main)
|
|
18
|
-
|
|
19
|
-
</div>
|
|
20
|
-
|
|
21
|
-
##### On this page
|
|
22
|
-
|
|
23
|
-
- [Usage](#usage)
|
|
24
|
-
- [`webpack.config.js`](#webpackconfigjs)
|
|
25
|
-
- [`vite.config.js`](#viteconfigjs)
|
|
26
|
-
- [`next.config.js`](#nextconfigjs)
|
|
27
|
-
- [Related](#related)
|
|
28
|
-
|
|
29
|
-
---
|
|
30
|
-
|
|
31
|
-
# Usage
|
|
32
|
-
|
|
33
|
-
## `webpack.config.js`
|
|
34
|
-
```js
|
|
35
|
-
const { MasterCSSWebpackPlugin } = require('@master/css-compiler')
|
|
36
|
-
|
|
37
|
-
module.exports = {
|
|
38
|
-
plugins: [
|
|
39
|
-
new MasterCSSWebpackPlugin()
|
|
40
|
-
]
|
|
41
|
-
};
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
## `vite.config.js`
|
|
45
|
-
```js
|
|
46
|
-
import { MasterCSSVitePlugin } from '@master/css-compiler'
|
|
47
|
-
|
|
48
|
-
export default defineConfig({
|
|
49
|
-
plugins: [
|
|
50
|
-
MasterCSSVitePlugin()
|
|
51
|
-
]
|
|
52
|
-
})
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## `next.config.js`
|
|
56
|
-
```js
|
|
57
|
-
const { MasterCSSWebpackPlugin } = require('@master/css-compiler')
|
|
58
|
-
|
|
59
|
-
const nextConfig = {
|
|
60
|
-
...,
|
|
61
|
-
webpack: (config) => {
|
|
62
|
-
config.plugins.push(
|
|
63
|
-
new MasterCSSWebpackPlugin({
|
|
64
|
-
output: {
|
|
65
|
-
path: 'static/css'
|
|
66
|
-
}
|
|
67
|
-
})
|
|
68
|
-
)
|
|
69
|
-
return config
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
module.exports = nextConfig
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
---
|
|
77
|
-
|
|
78
|
-
# Related
|
|
79
|
-
- [@master/css](https://github.com/master-co/css) - A Virtual CSS language with enhanced syntax. ( ~13KB )
|
|
80
|
-
- [@master/css.react](https://github.com/master-co/css.react) - React hooks for Master CSS
|
|
1
|
+
Check out the [official documentation](https://beta.css.master.co/docs/compiler).
|
package/dist/compiler.d.ts
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import MasterCSS from '@master/css';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
+
customOptions?: Options;
|
|
7
7
|
css: MasterCSS;
|
|
8
8
|
extractions: Set<string>;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
validExtractions: Set<string>;
|
|
10
|
+
invalidExtractions: Set<string>;
|
|
11
|
+
get resolvedModuleId(): string;
|
|
12
|
+
get moduleHMREvent(): string;
|
|
13
|
+
constructor(customOptions?: Options);
|
|
14
|
+
private init;
|
|
15
|
+
logOptionsFound: (optionsPath: string) => void;
|
|
16
|
+
logOptionsNotFound: (optionsPath: string) => void;
|
|
17
|
+
readOptions(key?: string): Options | any;
|
|
18
|
+
get optionsPath(): string;
|
|
19
|
+
get resolvedOptionsPath(): string;
|
|
20
|
+
refresh(customOptions?: Options): Promise<this>;
|
|
21
|
+
compile(): Promise<this>;
|
|
22
|
+
extract(name: string, content: string): string[];
|
|
23
|
+
insert(name: string, content: string): Promise<boolean>;
|
|
24
|
+
createRules(extraction: string): Promise<Rule[]>;
|
|
25
|
+
get sources(): string[];
|
|
26
|
+
checkSourcePath(name: string): boolean;
|
|
27
|
+
get config(): Config;
|
|
12
28
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const OPTIONS_ESM_TEXT = "/** @type {import('@master/css-compiler').Options} */\nconst options = {\n sources: [],\n classes: {\n fixed: [],\n ignored: []\n }\n}\n\nexport default options\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const OPTIONS_TEXT = "/** @type {import('@master/css-compiler').Options} */\nmodule.exports = {\n sources: [],\n classes: {\n fixed: [],\n ignored: []\n }\n}\n";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const OPTIONS_TS_TEXT = "import type { Options } from '@master/css-compiler'\nconst options: Options = {\n sources: [],\n classes: {\n fixed: [],\n ignored: []\n }\n}\n\nexport default options\n";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export { default as
|
|
1
|
+
export * from './options';
|
|
2
|
+
export * from './constants';
|
|
3
|
+
export { default as options } from './options';
|
|
4
|
+
export { MasterCSSCompiler as default, MasterCSSCompiler } from './compiler';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var we=Object.create;var R=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var Ee=Object.getOwnPropertyNames;var Ce=Object.getPrototypeOf,Se=Object.prototype.hasOwnProperty;var Re=(e,r)=>{for(var t in r)R(e,t,{get:r[t],enumerable:!0})},z=(e,r,t,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of Ee(r))!Se.call(e,i)&&i!==t&&R(e,i,{get:()=>r[i],enumerable:!(s=Te(r,i))||s.enumerable});return e};var m=(e,r,t)=>(t=e!=null?we(Ce(e)):{},z(r||!e||!e.__esModule?R(t,"default",{value:e,enumerable:!0}):t,e)),ke=e=>z(R({},"__esModule",{value:!0}),e);var yt={};Re(yt,{MasterCSSCompiler:()=>S,OPTIONS_ESM_TEXT:()=>Pe,OPTIONS_TEXT:()=>je,OPTIONS_TS_TEXT:()=>Be,default:()=>S,options:()=>T});module.exports=ke(yt);var Ne={path:"master.css-compiler.*",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:[]}},T=Ne;var je=`/** @type {import('@master/css-compiler').Options} */
|
|
2
|
+
module.exports = {
|
|
3
|
+
sources: [],
|
|
4
|
+
classes: {
|
|
5
|
+
fixed: [],
|
|
6
|
+
ignored: []
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
`;var Pe=`/** @type {import('@master/css-compiler').Options} */
|
|
10
|
+
const options = {
|
|
11
|
+
sources: [],
|
|
12
|
+
classes: {
|
|
13
|
+
fixed: [],
|
|
14
|
+
ignored: []
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default options
|
|
19
|
+
`;var Be=`import type { Options } from '@master/css-compiler'
|
|
20
|
+
const options: Options = {
|
|
21
|
+
sources: [],
|
|
22
|
+
classes: {
|
|
23
|
+
fixed: [],
|
|
24
|
+
ignored: []
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default options
|
|
29
|
+
`;var P=m(require("upath"));var be=m(require("@master/css"));var H=require("@master/css");function G({content:e},{config:r,classes:t}){e=Me(e);let s=[...new Set(Object.keys(r.semantics??H.semantics).concat(Object.keys(t)))],i=e.match(/\S+/g)??[],o=new Set;for(let n of i){o.add(F(n,s));let g=q(n);if(g.size)for(let c of g)o.add(F(c,s))}return[...o].filter(n=>n&&!Ae(n,s))}var F=(e,r)=>{let t=e,s=e.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?r.concat(s):r).find(i=>t.startsWith(i))?e=_(e,i=>i.replace(/^[^:@~(]*(?<!@>?)=/,"").replace(/(?:[([{\\:#=.]+|["'`].*)$/,"")):e=_(e,i=>i.replace(/^[^:@~(]*(?:["'`]|(?<!@>?)=)/,"").replace(/(?:[([{\\:#=.]+|["'`].*)$/,"")),t===e||!e?e:F(e,r)},J=e=>e.match(/((?<!\\)["'`])(?:\\\1|(?:(?!\1))[\S\s])*(?<!\\)\1/g),K=(e,r)=>(r?.forEach((t,s)=>{e=e.replace(t,`COMPLETE-STRING--${s}--`)}),e),_=(e,r)=>{let t=J(e);return e=K(e,t),e=r(e),t?.forEach((s,i)=>{e=e.replace(`COMPLETE-STRING--${i}--`,s)}),e},q=e=>{let r=new Set,t=/((?<!\\)["'`])((?:\\\1|(?:(?!\1))[\S\s])*)((?<!\\)\1)/g,s;for(;(s=t.exec(e))!==null;){s.index===t.lastIndex&&t.lastIndex++,r.add(s[2]);let i=q(s[2]);if(i.size)for(let o of i)r.add(o)}return r},Me=e=>_(e,r=>r.replace(/\/\*(?:(?!\*\/)[\S\s])*\*\//g,"").replace(/<!--(?:(?!-->)[\S\s])*-->/g,"").replace(/\/\/.*/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,"")),Ae=(e,r)=>{let t=J(e),s=K(e,t),i=/{(.*)}/,o;for(;(o=i.exec(s))!==null;)return o[1].split(";").find(g=>X(g,r))!==void 0;return X(s,r)||Ie(e)},X=(e,r)=>!e||!e.match(/(?:\S*\{\S*\})|(?:^[\w\-()]+:\S+)|(?:^[\w-]+\(\S+\))|(?:^[@~]\S+$)/)&&!e.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)?)$/)&&!r.find(t=>e.startsWith(t))||e.match(/\*\*/)||e.match(/:\[/)||e.match(/\$\{/)||e.match(/\{\{/)||e.match(/\(\{[^}]*\}/)||e.match(/<\w+>|<\/\w+>/)||e.match(/;$/)||e.match(/^\w+:\/\//)||e.match(/^@(?:ts-[^\s]+|charset|import|namespace|media|supports|document|page|font-face|keyframes|counter-style|font-feature-values|property|layer|[^/]+\/.*)$/)||e.match(/^~\/.+.\w+$/)||e.match(/function\(|\(.*\)=>/)||e.match(/^\$\(.*/),Ie=e=>{let r=[],t;for(let s=0;s<e.length;s++)switch(e[s]){case"(":case"[":case"{":r.push(e[s]);break;case")":case"]":case"}":if(t=r.pop(),e[s]===")"&&t!=="("||e[s]==="]"&&t!=="["||e[s]==="}"&&t!=="{")return!0;break}return r.length>0};var ve=m(require("fs")),B=m(require("fast-glob")),M=m(require("minimatch")),A=m(require("techor"));var j=m(require("node:process"),1),he=m(require("node:os"),1),D=m(require("node:tty"),1),Fe=Object.create,pe=Object.defineProperty,_e=Object.getOwnPropertyDescriptor,Ge=Object.getOwnPropertyNames,Le=Object.getPrototypeOf,Ye=Object.prototype.hasOwnProperty,De=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),We=(e,r,t,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of Ge(r))!Ye.call(e,i)&&i!==t&&pe(e,i,{get:()=>r[i],enumerable:!(s=_e(r,i))||s.enumerable});return e},Ve=(e,r,t)=>(t=e!=null?Fe(Le(e)):{},We(r||!e||!e.r?pe(t,"default",{value:e,enumerable:!0}):t,e)),Ue=De((e,r)=>{"use strict";function t(s){var i=void 0;typeof s=="string"?i=[s]:i=s.raw;for(var o="",n=0;n<i.length;n++)o+=i[n].replace(/\\\n[ \t]*/g,"").replace(/\\`/g,"`"),n<(arguments.length<=1?0:arguments.length-1)&&(o+=arguments.length<=n+1?void 0:arguments[n+1]);var g=o.split(`
|
|
30
|
+
`),c=null;return g.forEach(function(a){var d=a.match(/^(\s+)\S+/);if(d){var x=d[1].length;c?c=Math.min(c,x):c=x}}),c!==null&&(o=g.map(function(a){return a[0]===" "?a.slice(c):a}).join(`
|
|
31
|
+
`)),o=o.trim(),o.replace(/\\n/g,`
|
|
32
|
+
`)}typeof r<"u"&&(r.exports=t)}),b=(e,r)=>{if(!e)throw new Error(r)},ze=e=>{let r={joined:!0,spacerNoNeighbour:" ",spacerNeighbour:"\u2502 ",keyNoNeighbour:"\u2514\u2500 ",keyNeighbour:"\u251C\u2500 ",separator:": ",renderFn:t=>["boolean","string","number"].includes(typeof t)?t:void 0,sortFn:null,breakCircularWith:" (circular ref.)",...e};return b(Object.keys(r).length===9,"Unexpected Option(s) provided"),b(typeof r.joined=="boolean",'Option "joined" has invalid format'),b(typeof r.spacerNoNeighbour=="string",'Option "spacerNoNeighbour" has invalid format'),b(typeof r.spacerNeighbour=="string",'Option "spacerNeighbour" has invalid format'),b(typeof r.keyNoNeighbour=="string",'Option "keyNoNeighbour" has invalid format'),b(typeof r.keyNeighbour=="string",'Option "keyNeighbour" has invalid format'),b(typeof r.separator=="string",'Option "separator" has invalid format'),b(typeof r.renderFn=="function",'Option "renderFn" has invalid format'),b(typeof r.sortFn=="function"||r.sortFn===null,'Option "sortFn" has invalid format'),b(typeof r.breakCircularWith=="string"||r.breakCircularWith===null,'Option "breakCircularWith" has invalid format'),r},ge=(e,r={})=>{let t=ze(r),s=[],i=t.renderFn(e);i!==void 0&&s.push(String(i));let o=a=>t.sortFn===null?a.reverse():a.sort((d,x)=>t.sortFn(x,d)),n=[],g=o(Object.keys(e)).map(a=>[a]),c=[e];for(;g.length!==0;){let a=g.pop(),d=c[a.length-1][a[a.length-1]],x=t.breakCircularWith!==null&&c.includes(d);n[a.length-1]=g.length!==0&&g[g.length-1].length===a.length;let $e=t.renderFn(d);s.push([n.slice(0,a.length-1).map(I=>I?t.spacerNeighbour:t.spacerNoNeighbour).join(""),n[a.length-1]?t.keyNeighbour:t.keyNoNeighbour,a[a.length-1],$e===void 0?"":`${t.separator}${d}`,x?t.breakCircularWith:""].join("")),d instanceof Object&&!Array.isArray(d)&&!x&&(g.push(...o(Object.keys(d)).map(I=>a.concat(I))),c[a.length]=d)}return t.joined===!0?s.join(`
|
|
33
|
+
`):s},Z=(e=0)=>r=>`\x1B[${r+e}m`,Q=(e=0)=>r=>`\x1B[${38+e};5;${r}m`,ee=(e=0)=>(r,t,s)=>`\x1B[${38+e};2;${r};${t};${s}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),Xe=Object.keys(u.color),He=Object.keys(u.bgColor),Rt=[...Xe,...He];function Je(){let e=new Map;for(let[r,t]of Object.entries(u)){for(let[s,i]of Object.entries(t))u[s]={open:`\x1B[${i[0]}m`,close:`\x1B[${i[1]}m`},t[s]=u[s],e.set(i[0],i[1]);Object.defineProperty(u,r,{value:t,enumerable:!1})}return Object.defineProperty(u,"codes",{value:e,enumerable:!1}),u.color.close="\x1B[39m",u.bgColor.close="\x1B[49m",u.color.ansi=Z(),u.color.ansi256=Q(),u.color.ansi16m=ee(),u.bgColor.ansi=Z(10),u.bgColor.ansi256=Q(10),u.bgColor.ansi16m=ee(10),Object.defineProperties(u,{rgbToAnsi256:{value(r,t,s){return r===t&&t===s?r<8?16:r>248?231:Math.round((r-8)/247*24)+232:16+36*Math.round(r/255*5)+6*Math.round(t/255*5)+Math.round(s/255*5)},enumerable:!1},hexToRgb:{value(r){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(r.toString(16));if(!t)return[0,0,0];let[s]=t;s.length===3&&(s=[...s].map(o=>o+o).join(""));let i=Number.parseInt(s,16);return[i>>16&255,i>>8&255,i&255]},enumerable:!1},hexToAnsi256:{value:r=>u.rgbToAnsi256(...u.hexToRgb(r)),enumerable:!1},ansi256ToAnsi:{value(r){if(r<8)return 30+r;if(r<16)return 90+(r-8);let t,s,i;if(r>=232)t=((r-232)*10+8)/255,s=t,i=t;else{r-=16;let g=r%36;t=Math.floor(r/36)/5,s=Math.floor(g/6)/5,i=g%6/5}let o=Math.max(t,s,i)*2;if(o===0)return 30;let n=30+(Math.round(i)<<2|Math.round(s)<<1|Math.round(t));return o===2&&(n+=60),n},enumerable:!1},rgbToAnsi:{value:(r,t,s)=>u.ansi256ToAnsi(u.rgbToAnsi256(r,t,s)),enumerable:!1},hexToAnsi:{value:r=>u.ansi256ToAnsi(u.hexToAnsi256(r)),enumerable:!1}}),u}var Ke=Je(),v=Ke;function f(e,r=globalThis.Deno?globalThis.Deno.args:j.default.argv){let t=e.startsWith("-")?"":e.length===1?"-":"--",s=r.indexOf(t+e),i=r.indexOf("--");return s!==-1&&(i===-1||s<i)}var{env:p}=j.default,k;f("no-color")||f("no-colors")||f("color=false")||f("color=never")?k=0:(f("color")||f("colors")||f("color=true")||f("color=always"))&&(k=1);function qe(){if("FORCE_COLOR"in p)return p.FORCE_COLOR==="true"?1:p.FORCE_COLOR==="false"?0:p.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(p.FORCE_COLOR,10),3)}function Ze(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function Qe(e,{streamIsTTY:r,sniffFlags:t=!0}={}){let s=qe();s!==void 0&&(k=s);let i=t?k:s;if(i===0)return 0;if(t){if(f("color=16m")||f("color=full")||f("color=truecolor"))return 3;if(f("color=256"))return 2}if("TF_BUILD"in p&&"AGENT_NAME"in p)return 1;if(e&&!r&&i===void 0)return 0;let o=i||0;if(p.TERM==="dumb")return o;if(j.default.platform==="win32"){let n=he.default.release().split(".");return Number(n[0])>=10&&Number(n[2])>=10586?Number(n[2])>=14931?3:2:1}if("CI"in p)return"GITHUB_ACTIONS"in p?3:["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(n=>n in p)||p.CI_NAME==="codeship"?1:o;if("TEAMCITY_VERSION"in p)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(p.TEAMCITY_VERSION)?1:0;if(p.COLORTERM==="truecolor"||p.TERM==="xterm-kitty")return 3;if("TERM_PROGRAM"in p){let n=Number.parseInt((p.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(p.TERM_PROGRAM){case"iTerm.app":return n>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(p.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(p.TERM)||"COLORTERM"in p?1:o}function te(e,r={}){let t=Qe(e,{streamIsTTY:e&&e.isTTY,...r});return Ze(t)}var et={stdout:te({isTTY:D.default.isatty(1)}),stderr:te({isTTY:D.default.isatty(2)})},tt=et;function rt(e,r,t){let s=e.indexOf(r);if(s===-1)return e;let i=r.length,o=0,n="";do n+=e.slice(o,s)+r+t,o=s+i,s=e.indexOf(r,o);while(s!==-1);return n+=e.slice(o),n}function st(e,r,t,s){let i=0,o="";do{let n=e[s-1]==="\r";o+=e.slice(i,n?s-1:s)+r+(n?`\r
|
|
34
|
+
`:`
|
|
35
|
+
`)+t,i=s+1,s=e.indexOf(`
|
|
36
|
+
`,i)}while(s!==-1);return o+=e.slice(i),o}var{stdout:re,stderr:se}=tt,W=Symbol("GENERATOR"),$=Symbol("STYLER"),E=Symbol("IS_EMPTY"),ie=["ansi","ansi","ansi256","ansi16m"],w=Object.create(null),it=(e,r={})=>{if(r.level&&!(Number.isInteger(r.level)&&r.level>=0&&r.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let t=re?re.level:0;e.level=r.level===void 0?t:r.level},ot=e=>{let r=(...t)=>t.join(" ");return it(r,e),Object.setPrototypeOf(r,C.prototype),r};function C(e){return ot(e)}Object.setPrototypeOf(C.prototype,Function.prototype);for(let[e,r]of Object.entries(v))w[e]={get(){let t=N(this,U(r.open,r.close,this[$]),this[E]);return Object.defineProperty(this,e,{value:t}),t}};w.visible={get(){let e=N(this,this[$],!0);return Object.defineProperty(this,"visible",{value:e}),e}};var V=(e,r,t,...s)=>e==="rgb"?r==="ansi16m"?v[t].ansi16m(...s):r==="ansi256"?v[t].ansi256(v.rgbToAnsi256(...s)):v[t].ansi(v.rgbToAnsi(...s)):e==="hex"?V("rgb",r,t,...v.hexToRgb(...s)):v[t][e](...s),nt=["rgb","hex","ansi256"];for(let e of nt){w[e]={get(){let{level:t}=this;return function(...s){let i=U(V(e,ie[t],"color",...s),v.color.close,this[$]);return N(this,i,this[E])}}};let r="bg"+e[0].toUpperCase()+e.slice(1);w[r]={get(){let{level:t}=this;return function(...s){let i=U(V(e,ie[t],"bgColor",...s),v.bgColor.close,this[$]);return N(this,i,this[E])}}}}var lt=Object.defineProperties(()=>{},{...w,level:{enumerable:!0,get(){return this[W].level},set(e){this[W].level=e}}}),U=(e,r,t)=>{let s,i;return t===void 0?(s=e,i=r):(s=t.openAll+e,i=r+t.closeAll),{open:e,close:r,openAll:s,closeAll:i,parent:t}},N=(e,r,t)=>{let s=(...i)=>at(s,i.length===1?""+i[0]:i.join(" "));return Object.setPrototypeOf(s,lt),s[W]=e,s[$]=r,s[E]=t,s},at=(e,r)=>{if(e.level<=0||!r)return e[E]?"":r;let t=e[$];if(t===void 0)return r;let{openAll:s,closeAll:i}=t;if(r.includes("\x1B"))for(;t!==void 0;)r=rt(r,t.close,t.open),t=t.parent;let o=r.indexOf(`
|
|
37
|
+
`);return o!==-1&&(r=st(r,i,s,o)),s+r+i};Object.defineProperties(C.prototype,w);var ct=C(),kt=C({level:se?se.level:0}),l=ct;function y(e){return e.split(" ").map(r=>r.replace(/^(\d*\.?\d*)$/g,`${l.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,`${l.cyan("$1")}${l.magenta("$2")}`).replace(/^((?:[0-1]?[0-9]|[2][0-3]):[0-5][0-9]:[0-5][0-9] (?:AM|PM)?)$/g,`${l.dim("$1")}`).replace(/^\[(.*?)\]$/g,`${l.dim("[")}${l.magenta("$1")}${l.dim("]")}`).replace(/^`(.*?)`$/g,`${l.dim("`")}$1${l.dim("`")}`).replace(/^\((.*?)\)$/g,`${l.dim("(")}$1${l.dim(")")}`).replace(/^<(.*?)>$/g,`${l.dim("<")}${l.gray("$1")}${l.dim(">")}`).replace(/->/g,l.dim("\u2192")).replace(/<-/g,l.dim("\u2190")).replace(/^\$t$/g,`${l.dim(new Date().toLocaleTimeString())}`).replace(/^\*\*(.*?)\*\*$/g,`${l.bold.white("$1")}`).replace(/^~~(.*?)~~$/g,`${l.strikethrough("$1")}`).replace(/^__(.*?)__$/g,`${l.underline("$1")}`).replace(/^\.\.(.*?)\.\.$/g,`${l.dim("$1")}`).replace(/^!!(.*?)!!$/g,`${l.yellow("$1")}`).replace(/^\*(.*?)\*$/g,`${l.italic("$1")}`).replace(/^_(.*?)_$/g,`${l.italic("$1")}`).replace(/^\+(.*?)\+$/g,`${l.green("$1")}`).replace(/^-(.*?)-$/g,`${l.red("$1")}`)).join(" ")}function h(e,r){let t="";if(Array.isArray(e))for(let s=0;s<e.length;s++)t+=L(e[s])+L(r[s]);else t=[e,...r].map(s=>L(s)).join(" ");return y(t)}var L=e=>e?Array.isArray(e)?e.map(r=>{switch(typeof r){case"string":return`'${l.yellow(r)}'`;case"number":case"boolean":return l.blue(r);default:return r}}).join(l.gray(", ")):e:"",oe=(e,...r)=>{let t=l.green("+")+" "+h(e,r);return console.log(t),t},ne=(e,...r)=>{let t=l.bgRed.bold.white(" \u{1D5EB} ERROR ")+" "+h(e,r);return console.log(t),t},ut=(e,...r)=>{let t=l.bgYellow.bold.white(" \u26A0\uFE0F CONFLICT ")+" "+l.yellow(h(e,r));return console.log(t),t},pt=(e,...r)=>{let t=l.green("\u2713 ")+h(e,r);return console.log(t),t},Y=(e,...r)=>{let t=l.red("-")+" "+h(e,r);return console.log(t),t},le=(e,...r)=>{let t=l.green("\u25CB ")+h(e,r);return console.log(t),t},ae=(e,...r)=>{let t=l.red("\u2717 ")+h(e,r);return console.log(t),t},ce=(e,...r)=>{let t=l.cyan("\u{1D4F2}")+" "+h(e,r);return console.log(t),t},gt=(e,...r)=>{let t=l.green("\u23FA Success ")+h(e,r);return console.log(t),t},ht=(e,...r)=>{let t=l.yellow("\u23FA Warn ")+h(e,r);return console.log(t),t},dt=(e,...r)=>{let t=l.bgGreen.bold.white(" \u2713 PASS ")+" "+h(e,r);return console.log(t),t},ft=e=>{let r=ge(fe(de(JSON.parse(JSON.stringify(e)))),{spacerNeighbour:y("..\u2502..")+" ",keyNoNeighbour:y("..\u2514\u2500..")+" ",keyNeighbour:y("..\u251C\u2500..")+" ",separator:y("..:..")+" "});return console.log(r),r};function de(e){for(let r in e){let t=e[r];typeof t=="object"?t!==null&&!Object.keys(t).length?delete e[r]:e[r]=de(t):t===void 0&&delete e[r]}return e}function fe(e){for(let r in e){let t=e[r];Array.isArray(t)?e[r]=t.map(s=>y(`**${s}**`)).join(y("..,..")):typeof t=="object"?fe(t):e[r]=y(`**${t}**`)}return e}var mt=(e,...r)=>{let t=l.red("\u23FA Fail ")+h(e,r);return console.log(t),t},ue=(e,...r)=>{let t=y("$t ")+h(e,r);return console.log(t),t},bt=Ve(Ue());function vt(e){let{message:r,stack:t}=typeof e=="string"?new Error(e):e,s={};return(0,bt.default)(t.replace(r,"").replace(/^Error: /,"")).split(`
|
|
38
|
+
`).forEach(i=>{s[i.split(" ").map(o=>o.replace(/^\((.+)\)$/,`${l.cyan("$1")}`).replace(/\./g,`${l.dim(".")}`).replace(/^at$/,n=>l.dim(n))).join(" ")]=null}),{message:r.trim().replace(/Error: /g,""),stackTree:s}}var me=(e,...r)=>{if(e instanceof Error){let{message:t,stackTree:s}=vt(e);return console.log(""),console.log(l.bgRed.bold.white(" \u{1D5EB} ERROR ")+" "+l.bold.red(t)),console.log(ge(s,{spacerNeighbour:l.redBright.dim("\u2502\u2000\u2000"),keyNoNeighbour:l.redBright.dim("\u2514\u2500\u2000"),keyNeighbour:l.redBright.dim("\u251C\u2500 "),separator:l.redBright.dim(":\u2000")})),console.log(""),t}else{let t=h(e,r);return console.log(t),t}};Object.assign(me,{a:oe,add:oe,d:Y,del:Y,delete:Y,o:le,valid:le,x:ae,invalid:ae,i:ce,info:ce,e:ne,error:ne,t:ue,timestamp:ue,success:gt,fail:mt,warn:ht,pass:dt,conflict:ut,ok:pt,tree:ft,paint:y});var O=me;var ye=m(require("stylelint")),Oe=require("@techor/extend"),xe=m(require("cross-import")),S=class extends A.default{constructor(t){super(T,t);this.customOptions=t;this.init(t)}css;extractions=new Set;validExtractions=new Set;invalidExtractions=new Set;get resolvedModuleId(){return"\0"+this.options.module}get moduleHMREvent(){return`HMR:${this.options.module}`}init(t=this.customOptions){this.options=(0,Oe.extend)(A.options,T,this.readOptions(),t),this.css=new be.default({...typeof this.options.config=="object"?this.options.config:this.readConfig()||{},observe:!1})}logOptionsFound=t=>O.ok`**${t}** file found`;logOptionsNotFound=t=>O.i`No **${t}** file found`;readOptions(t="options"){let{cwd:s}=this.options;if(typeof this.options.path=="object")return this.options.path;let i;try{let o=this.optionsPath;if(o){let n=(0,xe.default)(o,{cwd:s});i=(t?n[t]:void 0)||n.default||n,this.logOptionsFound(o)}else this.logOptionsNotFound(this.options.path)}catch(o){O.error(o)}return i}get optionsPath(){if(!(!this.options.path||typeof this.options.path!="string"))return B.default.sync(this.options.path,{cwd:this.options.cwd})[0]}get resolvedOptionsPath(){let t=this.optionsPath;return t?P.default.resolve(this.options.cwd,t):""}async refresh(t=this.customOptions){return this.extractions.clear(),this.validExtractions.clear(),this.invalidExtractions.clear(),console.log(""),this.init(t),await this.compile(),this}async compile(){if(this.options.classes?.fixed?.length)for(let t of this.options.classes.fixed)this.css.insert(t);return await Promise.all(this.sources.map(async t=>{let s=ve.default.readFileSync(P.default.resolve(this.options.cwd,t),{encoding:"utf-8"}).toString();await this.insert(t,s)})),this}extract(t,s){if(!t||!s||!this.checkSourcePath(t))return[];let i=[];for(let o of G({content:s,name:t},this.css))this.extractions.has(o)||(this.extractions.add(o),i.push(o));return i}async insert(t,s){let i=this.extract(t,s);if(!i.length)return!1;this.invalidExtractions.size&&(i=i.filter(c=>!this.invalidExtractions.has(c))),this.validExtractions.size&&(i=i.filter(c=>!this.validExtractions.has(c))),this.options.classes?.ignored?.length&&(i=i.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 o=process.hrtime(),n=[];await Promise.all(i.map(async c=>{let a=await this.createRules(c);a.length?(this.css.insertRules(a),n.push(c),this.validExtractions.add(c)):this.invalidExtractions.add(c)})),o=process.hrtime(o);let g=Math.round((o[0]*1e9+o[1])/1e6*10)/10;if(i.length&&(console.log(""),O`**${P.default.relative(this.options.cwd,t)}**`,O`[extract] ${i.length} potential`),this.css.rules.length){let c=n.filter(a=>!i.includes(a));c.length&&O`[exclude] ${c.length} unknown ${c}`,O`[compile] +${n.length}+ valid inserted ${l.gray("in")} ${g}ms ${n}`,O`[virtual] ${this.css.rules.length} total ${l.gray("in")} ${this.options.module}`}return!0}async createRules(t){return(await Promise.all(this.css.create(t).map(async i=>(await ye.default.lint({code:i.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:i))).filter(i=>i)}get sources(){let{include:t,exclude:s,sources:i,cwd:o}=this.options,n=B.default.sync(t,{cwd:o,ignore:s});return i?.length&&n.push(...B.default.sync(i,{cwd:o})),n.filter(g=>!!g)}checkSourcePath(t){let{include:s,exclude:i,sources:o}=this.options;for(let n of o)if((0,M.default)(t,n))return!0;for(let n of s)if(!(0,M.default)(t,n))return!1;for(let n of i)if((0,M.default)(t,n))return!1;return!0}get config(){return this.css.config}};0&&(module.exports={MasterCSSCompiler,OPTIONS_ESM_TEXT,OPTIONS_TEXT,OPTIONS_TS_TEXT,options});
|
package/dist/options/index.d.ts
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
|
7
|
-
output?:
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
export interface Options extends TechorOptions<Config> {
|
|
10
|
+
output?: string;
|
|
11
|
+
path?: string;
|
|
12
|
+
module?: string;
|
|
13
|
+
sources?: FastGlobPattern[];
|
|
14
|
+
include?: FastGlobPattern[];
|
|
15
|
+
exclude?: FastGlobPattern[];
|
|
16
|
+
classes?: {
|
|
17
|
+
fixed?: string[];
|
|
18
|
+
ignored?: string[] | RegExp[];
|
|
10
19
|
};
|
|
11
|
-
accept?: (source: MasterCSSCompilerSource) => boolean;
|
|
12
|
-
extract?: (source: MasterCSSCompilerSource) => string[];
|
|
13
|
-
config?: string;
|
|
14
|
-
debug?: string[] | boolean;
|
|
15
20
|
}
|
|
16
|
-
export default
|
|
21
|
+
export default options;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var r=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var p=(s,t)=>{for(var o in t)r(s,o,{get:t[o],enumerable:!0})},d=(s,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of a(t))!c.call(s,e)&&e!==o&&r(s,e,{get:()=>t[e],enumerable:!(n=i(t,e))||n.enumerable});return s};var l=s=>d(r({},"__esModule",{value:!0}),s);var g={};p(g,{default:()=>u});module.exports=l(g);var m={path:"master.css-compiler.*",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;
|
package/package.json
CHANGED
|
@@ -1,147 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@master/css-compiler",
|
|
3
|
-
"license": "MIT",
|
|
4
|
-
"description": "Compile Master CSS ahead of time with zero-configuration integration with build tools",
|
|
5
|
-
"author": "Aoyue Design LLC.",
|
|
6
|
-
"funding": "https://docs.master.co/css/donate",
|
|
7
|
-
"homepage": "https://css.master.co",
|
|
8
|
-
"repository": {
|
|
9
|
-
"type": "git",
|
|
10
|
-
"url": "https://github.com/master-co/css-compiler.git"
|
|
11
|
-
},
|
|
12
|
-
"keywords": [
|
|
13
|
-
"webpack",
|
|
14
|
-
"plugin",
|
|
15
|
-
"integration",
|
|
16
|
-
"vite",
|
|
17
|
-
"parcel",
|
|
18
|
-
"build tools",
|
|
19
|
-
"css",
|
|
20
|
-
"mastercss",
|
|
21
|
-
"vite-plugin"
|
|
22
|
-
],
|
|
23
|
-
"sideEffects": false,
|
|
24
|
-
"scripts": {
|
|
25
|
-
"build:cjs": "esbuild src/index.ts --bundle --outfile=dist/index.cjs --format=cjs --platform=node --external:@master/css --external:chalk",
|
|
26
|
-
"build:esm": "esbuild src/index.ts --bundle --outfile=dist/index.mjs --format=esm --platform=node --external:@master/css --external:chalk",
|
|
27
|
-
"dev:cjs": "npm run build:cjs -- --watch",
|
|
28
|
-
"dev:esm": "npm run build:esm -- --watch",
|
|
29
|
-
"prod": "rm -rf dist && npm run build:cjs -- --minify --sourcemap && npm run build:esm -- --minify --sourcemap && tsc --emitDeclarationOnly",
|
|
30
|
-
"test": "jest",
|
|
31
|
-
"lint": "eslint ./src"
|
|
32
|
-
},
|
|
33
|
-
"main": "./dist/index.cjs",
|
|
34
|
-
"jsnext:main": "./dist/index.mjs",
|
|
35
|
-
"browser": "./dist/index.browser.js",
|
|
36
|
-
"esnext": "./dist/index.mjs",
|
|
37
|
-
"module": "./dist/index.mjs",
|
|
38
|
-
"types": "./dist/index.d.ts",
|
|
39
|
-
"exports": {
|
|
40
|
-
".": {
|
|
41
|
-
"require": "./dist/index.cjs",
|
|
42
|
-
"import": "./dist/index.mjs",
|
|
43
|
-
"types": "./dist/index.d.ts"
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
"jest": {
|
|
47
|
-
"testEnvironment": "node",
|
|
48
|
-
"transform": {
|
|
49
|
-
"^.+\\.(t|j)sx?$": "@swc/jest"
|
|
50
|
-
},
|
|
51
|
-
"testMatch": [
|
|
52
|
-
"<rootDir>/tests/*.ts",
|
|
53
|
-
"<rootDir>/src/**/*.test.ts"
|
|
54
|
-
]
|
|
55
|
-
},
|
|
56
|
-
"private": false,
|
|
57
|
-
"publishConfig": {
|
|
58
|
-
"access": "public"
|
|
59
|
-
},
|
|
60
|
-
"engines": {
|
|
61
|
-
"node": ">=14"
|
|
62
|
-
},
|
|
63
|
-
"release": {
|
|
64
|
-
"plugins": [
|
|
65
|
-
[
|
|
66
|
-
"@semantic-release/commit-analyzer",
|
|
67
|
-
{
|
|
68
|
-
"preset": "angular",
|
|
69
|
-
"releaseRules": [
|
|
70
|
-
{
|
|
71
|
-
"type": "docs",
|
|
72
|
-
"scope": "README",
|
|
73
|
-
"release": "patch"
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
"type": "refactor",
|
|
77
|
-
"release": "patch"
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
"type": "style",
|
|
81
|
-
"release": "patch"
|
|
82
|
-
}
|
|
83
|
-
],
|
|
84
|
-
"parserOpts": {
|
|
85
|
-
"noteKeywords": [
|
|
86
|
-
"BREAKING CHANGE",
|
|
87
|
-
"BREAKING CHANGES"
|
|
88
|
-
]
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
],
|
|
92
|
-
"@semantic-release/release-notes-generator",
|
|
93
|
-
[
|
|
94
|
-
"@semantic-release/exec",
|
|
95
|
-
{
|
|
96
|
-
"prepareCmd": "npm run prod"
|
|
97
|
-
}
|
|
98
|
-
],
|
|
99
|
-
[
|
|
100
|
-
"@semantic-release/github"
|
|
101
|
-
],
|
|
102
|
-
[
|
|
103
|
-
"@semantic-release/npm"
|
|
104
|
-
]
|
|
105
|
-
],
|
|
106
|
-
"branches": [
|
|
107
|
-
"+([0-9])?(.{+([0-9]),x}).x",
|
|
108
|
-
"main",
|
|
109
|
-
"next",
|
|
110
|
-
"next-major",
|
|
111
|
-
{
|
|
112
|
-
"name": "beta",
|
|
113
|
-
"prerelease": true
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
"name": "alpha",
|
|
117
|
-
"prerelease": true
|
|
118
|
-
}
|
|
119
|
-
]
|
|
120
|
-
},
|
|
121
|
-
"files": [
|
|
122
|
-
"dist"
|
|
123
|
-
],
|
|
124
|
-
"devDependencies": {
|
|
125
|
-
"@semantic-release/exec": "^6.0.3",
|
|
126
|
-
"@swc/core": "^1.3.9",
|
|
127
|
-
"@swc/jest": "^0.2.23",
|
|
128
|
-
"@types/jest": "^29.2.0",
|
|
129
|
-
"@types/node": "^18.11.0",
|
|
130
|
-
"@types/webpack": "^5.28.0",
|
|
131
|
-
"@typescript-eslint/eslint-plugin": "^5.40.1",
|
|
132
|
-
"@typescript-eslint/parser": "^5.40.1",
|
|
133
|
-
"esbuild": "^0.15.10",
|
|
134
|
-
"eslint": "^8.25.0",
|
|
135
|
-
"jest": "^29.2.2",
|
|
136
|
-
"semantic-release": "^19.0.5",
|
|
137
|
-
"typescript": "^4.8.4",
|
|
138
|
-
"vite": "^3.1.8"
|
|
139
|
-
},
|
|
140
|
-
"peerDependencies": {
|
|
141
|
-
"@master/css": "^2.0.0-beta.22"
|
|
142
|
-
},
|
|
143
|
-
"dependencies": {
|
|
144
|
-
"chalk": "^4.0.0"
|
|
145
|
-
},
|
|
146
|
-
"version": "2.0.0-beta.15"
|
|
147
|
-
}
|
|
1
|
+
{"name":"@master/css-compiler","scripts":{"build":"techor pack --platform node","dev":"npm run build -- --watch","lint":"eslint ./src","type-check":"tsc --noEmit","test":"jest --forceExit --detectOpenHandles"},"license":"MIT","description":"The ahead-of-time compiler of Master CSS","author":"Aoyue Design LLC.","funding":"https://docs.master.co/css/donate","homepage":"https://css.master.co","bugs":{"url":"https://github.com/master-co/css/issues"},"repository":{"type":"git","url":"https://github.com/master-co/css.git","directory":"packages/compiler"},"keywords":["webpack","plugin","integration","vite","parcel","build tools","css","mastercss","vite-plugin"],"sideEffects":false,"main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":"./dist/index.js","./options":"./dist/options/index.js"},"typesVersions":{"*":{".":["./dist/index.d.js"],"./options":["./dist/options/index.d.ts"]}},"files":["dist"],"publishConfig":{"access":"public"},"dependencies":{"@master/css":"^2.0.0-beta.150","@techor/extend":"^2.1.15","cross-import":"^2.1.15","fast-glob":"^3.2.12","minimatch":"^5.1.1","stylelint":"^15.2.0","techor":"^2.1.15","upath":"^2.0.1"},"devDependencies":{"ts-jest":"^29.0.5"},"version":"2.0.0-beta.150"}
|
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 N=Object.create;var k=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var U=Object.getPrototypeOf,B=Object.prototype.hasOwnProperty;var G=(t,e)=>{for(var s in e)k(t,s,{get:e[s],enumerable:!0})},I=(t,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of W(e))!B.call(t,i)&&i!==s&&k(t,i,{get:()=>e[i],enumerable:!(r=_(e,i))||r.enumerable});return t};var h=(t,e,s)=>(s=t!=null?N(U(t)):{},I(e||!t||!t.__esModule?k(s,"default",{value:t,enumerable:!0}):s,t)),V=t=>I(k({},"__esModule",{value:!0}),t);var K={};G(K,{MasterCSSCompiler:()=>m,MasterCSSVitePlugin:()=>z,MasterCSSWebpackPlugin:()=>C});module.exports=V(K);var b=h(require("path")),u=h(require("chalk"));var j=require("@master/css");function R({content:t}){let e=t.match(/[^\s]+/g)??[],s=new Set;for(let r of e){let i=D(r);if(i.size)for(let n of i)s.add(n);else s.add(T(r))}return[...s].filter(r=>r&&!J(r))}var T=t=>{let e=t;return t=t.replace(/^([\w={[(\\]*["'`])/,""),t.match(/^content:((?<!\\)["'`])((?:\\\1|(?:(?!\1))[\S\s])*)((?<!\\)\1)$/)||(t=t.replace(/(\.*|[([{\\:#]*|["'`].*)$/,"")),e===t?t:T(t)},D=t=>{let e=new Set,s=/((?<!\\)["'`])((?:\\\1|(?:(?!\1))[\S\s])*)((?<!\\)\1)/g,r;for(;(r=s.exec(t))!==null;){r.index===s.lastIndex&&s.lastIndex++;let i=D(r[2]);if(i.size)for(let n of i)e.add(n);else e.add(T(r[2]))}return e},J=t=>!t||!t.match(/(?:^[\w-]+:[\w$#]+)|(?:^[@~][\w-]+$)/)&&!Object.keys(j.defaultSemantics).includes(t)||t.match(/\*\*/)||t.match(/:\[/)||t.match(/\$\{/)||t.match(/\{\{/)||t.match(/\(\{[^}]*\}/)||t.match(/<\w+>|<\/\w+>/);var L={config:"./master.css.js",output:{name:"master.css",dir:""},accept({name:t}){if(t.match(/[\\/]node_modules[\\/]/))return!1;if(t.match(/\.(html|js|jsx|ts|tsx|svelte|astro|vue)$/i))return!0},extract:R},H=L;var $=h(require("@master/css")),E=require("perf_hooks"),m=class{constructor(e){this.options=e;this.options=(0,$.extend)(H,e),(async()=>{let s;try{s=(await import(b.default.resolve(process.cwd(),this.options.config))).default}catch{}this.css=new $.default({config:s})})()}initializing;css;extractions=new Set;extract({name:e,content:s}){if(!e||!s||!this.options.accept?.({content:s,name:e}))return[];let r=[];this.log("accepts",` \u2192 ${b.default.relative(process.cwd(),e)}`);for(let i of this.options.extract({content:s,name:e}))this.extractions.has(i)||(this.extractions.add(i),r.push(i));return r}insert(e){let s=E.performance.now();for(let n of e)this.css.findAndInsert(n);let r=Math.round((E.performance.now()-s)*1e3),i=this.css.rules.map(n=>n.className);console.log(`[Master CSS] process ${u.default.green(e.length)} extractions in ${u.default.green(r)} \xB5s [${u.default.green(this.css.rules.length)} rules in ${u.default.green(b.default.join(this.options.output.dir,this.options.output.name))}]`),this.log("extractions",` \u2192 ${u.default.green(e.length)} extractions: ${u.default.blue(e.join(" "))}`),this.log("validClasses",` \u2192 ${u.default.green(i.length)} total valid classes: ${u.default.blue(i.join(" "))}`)}log(e,s){(this.options.debug===!0||Array.isArray(this.options.debug)&&this.options.debug.includes(e))&&console.log(s)}};var F=h(require("path"));var S="MasterCSSWebpackPlugin",C=class extends m{async apply(e){await this.initializing;let{webpack:s}=e,{Template:r,RuntimeGlobals:i,RuntimeModule:n}=s,{RawSource:x}=s.sources,{Compilation:w}=s,{options:o}=this,l=F.default.join(o.output.dir||"",o.output.name),M=l.replace(/\\/g,"/");e.hooks.thisCompilation.tap(S,a=>{let p=new WeakSet,f=(d,c)=>{p.has(d)||(p.add(d),c.add(i.publicPath),a.addRuntimeModule(d,new A(c)))};a.hooks.runtimeRequirementInTree.for(i.ensureChunkHandlers).tap(S,f),a.hooks.runtimeRequirementInTree.for(i.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(i.hmrDownloadUpdateHandlers)?r.asString([Date.now().toString(),`const link = document.querySelector('[href*=\\'${M}\\'][rel=stylesheet]')`,"if (link) {",r.indent(["link.href = link.href.replace(/ts=[0-9]+/, 'ts=' + Date.now())"]),"}"]):""}}}),e.hooks.compilation.tap(S,a=>{a.hooks.finishModules.tap(S,p=>{let{modifiedFiles:f,watching:A}=e,d=[];for(let c of p){let g=c.resource,y=c._source?.source();A&&f?.size&&!f.has(g)||d.push(...this.extract({name:g,content:y}))}if(d.length){let c=this.css.text;this.insert(d);let g=this.css.text;if(g!==c){let y=new x(g);a.getAsset(l)?a.updateAsset(l,y):a.emitAsset(l,y)}}}),a.hooks.processAssets.tap({name:S,stage:w.PROCESS_ASSETS_STAGE_ADDITIONS},()=>{a.chunks.forEach(p=>{p.files.add(l)})})})}};var P=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)}async function z(t){let e=new m(t);await e.initializing;let s=P.default.join(e.options.output.dir||"",e.options.output.name),r,i,n,x=!1,w=(o,l)=>{let M=e.extract({name:o,content:l});if(M.length){let a=e.css.text;e.insert(M);let p=e.css.text;if(p!==a&&r){v(i,p);let f=()=>{r.ws.send({type:"update",updates:[{path:n,timestamp:Date.now()}]})};x?f():(setTimeout(f,500),x=!0)}}};return{name:"vite-plugin-master-css",enforce:"pre",configureServer(o){r=o},buildStart(){i=P.default.resolve(r?.config.cacheDir??process.cwd(),s),r&&(v(i,""),n=(r.config.cacheDir.slice(process.cwd().length)+"/"+s).replace(/\\/g,"/"))},resolveId(o){if(o.endsWith("master.css?direct"))return"\0"+o},transform(o,l){w(l,o)},transformIndexHtml(o){return o.replace(/(<head>)/,`$1<link rel="stylesheet" href="${n}">`)},async handleHotUpdate(o){w(o.file,await o.read())},generateBundle(){let o=this.emitFile({type:"asset",name:s,source:e.css.text});n="/"+this.getFileName(o)}}}0&&(module.exports={MasterCSSCompiler,MasterCSSVitePlugin,MasterCSSWebpackPlugin});
|
|
2
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
DELETED
|
@@ -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 (async () => {\n let userConfig: MasterCSSConfig\n try {\n userConfig = (await import(path.resolve(process.cwd(), this.options.config))).default\n // eslint-disable-next-line no-empty\n } catch (err) { }\n this.css = new MasterCSS({ config: userConfig })\n })()\n }\n\n initializing: Promise<any>\n css: MasterCSS\n extractions = new Set<string>()\n\n extract({ name, content }: MasterCSSCompilerSource) {\n if (\n !name || !content\n || !this.options.accept?.({ content, name })\n ) {\n return []\n }\n const eachExtractions: string[] = []\n\n this.log('accepts', ` \u2192 ${path.relative(process.cwd(), name)}`)\n\n for (const eachNewExtraction of this.options.extract({ content, name })) {\n if (this.extractions.has(eachNewExtraction)) {\n continue\n } else {\n this.extractions.add(eachNewExtraction)\n eachExtractions.push(eachNewExtraction)\n }\n }\n return eachExtractions\n }\n\n insert(extractions) {\n const p1 = performance.now()\n\n /* \u6839\u64DA\u985E\u540D\u5C0B\u627E\u4E26\u63D2\u5165\u898F\u5247 ( MasterCSS \u672C\u8EAB\u5E36\u6709\u5FEB\u53D6\u6A5F\u5236\uFF0C\u91CD\u8907\u7684\u985E\u540D\u4E0D\u6703\u518D\u7DE8\u8B6F\u53CA\u7522\u751F ) */\n for (const eachExtraction of extractions) {\n this.css.findAndInsert(eachExtraction)\n }\n\n const spent = Math.round((performance.now() - p1) * 1000)\n const validClasses = this.css.rules.map((rule) => rule.className)\n\n /* \u5370\u51FA Master CSS \u7DE8\u8B6F\u6642\u9593 */\n console.log(`[Master CSS] process ${chalk.green(extractions.length)} extractions in ${chalk.green(spent)} \u00B5s [${chalk.green(this.css.rules.length)} rules in ${chalk.green(path.join(this.options.output.dir, this.options.output.name))}]`)\n\n this.log('extractions', ` \u2192 ${chalk.green(extractions.length)} extractions: ${chalk.blue(extractions.join(' '))}`)\n this.log('validClasses', ` \u2192 ${chalk.green(validClasses.length)} total valid classes: ${chalk.blue(validClasses.join(' '))}`)\n }\n\n log(name, content) {\n if (this.options.debug === true || Array.isArray(this.options.debug) && this.options.debug.includes(name)) {\n console.log(content)\n }\n }\n}", "import { defaultSemantics } from '@master/css'\nimport type { MasterCSSCompilerSource } from './index'\n\nexport default function extract({ content }: MasterCSSCompilerSource) {\n const blocks = content.match(/[^\\s]+/g) ?? []\n const strings = new Set<string>()\n for (const block of blocks) {\n const result = peelString(block)\n if (result.size) {\n for (const string of result) {\n strings.add(string)\n }\n } else {\n strings.add(trimString(block))\n }\n }\n return [...strings].filter(x => x && !checkToExclude(x))\n}\n\nconst trimString = (content) => {\n const originContent = content\n content = content.replace(/^([\\w={[(\\\\]*[\"'`])/, '')\n if (!content.match(/^content:((?<!\\\\)[\"'`])((?:\\\\\\1|(?:(?!\\1))[\\S\\s])*)((?<!\\\\)\\1)$/)) {\n content = content.replace(/(\\.*|[([{\\\\:#]*|[\"'`].*)$/, '')\n }\n if (originContent === content) {\n return content\n } else {\n return trimString(content)\n }\n}\n\nconst peelString = (content) => {\n const strings = new Set<string>()\n const stringRegx = /((?<!\\\\)[\"'`])((?:\\\\\\1|(?:(?!\\1))[\\S\\s])*)((?<!\\\\)\\1)/g\n let m\n while ((m = stringRegx.exec(content)) !== null) {\n if (m.index === stringRegx.lastIndex) {\n stringRegx.lastIndex++\n }\n const result = peelString(m[2])\n if (result.size) {\n for (const string of result) {\n strings.add(string)\n }\n } else {\n strings.add(trimString(m[2]))\n }\n }\n return strings\n}\n\nconst checkToExclude = (content) => {\n return !content\n || (!content.match(/(?:^[\\w-]+:[\\w$#]+)|(?:^[@~][\\w-]+$)/) && !Object.keys(defaultSemantics).includes(content))\n || content.match(/\\*\\*/)\n || content.match(/:\\[/)\n || content.match(/\\$\\{/)\n || content.match(/\\{\\{/)\n || content.match(/\\(\\{[^}]*\\}/)\n || content.match(/<\\w+>|<\\/\\w+>/)\n}", "import extract from './extract'\n\nconst defaultOptions: MasterCSSCompilerOptions = {\n config: './master.css.js',\n output: {\n name: 'master.css',\n dir: ''\n },\n accept({ name }) {\n if (name.match(/[\\\\/]node_modules[\\\\/]/)) {\n return false\n }\n if (name.match(/\\.(html|js|jsx|ts|tsx|svelte|astro|vue)$/i)) {\n return true\n }\n },\n extract\n}\n\nexport declare type MasterCSSCompilerSource = {\n name: string\n content: string\n}\n\nexport interface MasterCSSCompilerOptions {\n output?: {\n name: string\n dir: string\n },\n accept?: (source: MasterCSSCompilerSource) => boolean\n extract?: (source: MasterCSSCompilerSource) => string[]\n config?: string\n debug?: string[] | boolean\n}\n\nexport default defaultOptions", "import path from 'path'\nimport MasterCSSCompiler from './compiler'\nimport type { Compiler } from 'webpack'\n\nconst NAME = 'MasterCSSWebpackPlugin'\n\nexport default class MasterCSSWebpackPlugin extends MasterCSSCompiler {\n\n async apply(compiler: Compiler) {\n await this.initializing\n const { webpack } = compiler\n const { Template, RuntimeGlobals, RuntimeModule } = webpack\n const { RawSource } = webpack.sources\n const { Compilation } = webpack\n const { options } = this\n const outputPath = path.join(options.output.dir || '', options.output.name)\n const linkHref = outputPath.replace(/\\\\/g, '/')\n\n compiler.hooks.thisCompilation.tap(NAME, (compilation) => {\n\n const enabledChunks = new WeakSet()\n\n const handler = (chunk, set) => {\n if (enabledChunks.has(chunk))\n return\n\n enabledChunks.add(chunk)\n\n set.add(RuntimeGlobals.publicPath)\n\n compilation.addRuntimeModule(chunk, new CssLoadingRuntimeModule(set))\n }\n\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.ensureChunkHandlers)\n .tap(NAME, handler)\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.hmrDownloadUpdateHandlers)\n .tap(NAME, handler)\n\n class CssLoadingRuntimeModule extends RuntimeModule {\n\n runtimeRequirements: Set<string>\n\n constructor(runtimeRequirements: Set<string>) {\n super('master-css-loading', 10)\n\n this.runtimeRequirements = runtimeRequirements\n }\n\n generate() {\n const { runtimeRequirements } = this\n const withHmr = runtimeRequirements.has(RuntimeGlobals.hmrDownloadUpdateHandlers)\n if (!withHmr)\n return ''\n\n return Template.asString([\n Date.now().toString(),\n `const link = document.querySelector('[href*=\\\\'${linkHref}\\\\'][rel=stylesheet]')`,\n 'if (link) {',\n Template.indent([\n 'link.href = link.href.replace(/ts=[0-9]+/, \\'ts=\\' + Date.now())'\n ]),\n '}'\n ])\n }\n }\n })\n\n compiler.hooks.compilation.tap(NAME, (compilation) => {\n // \u589E\u52A0\u984D\u5916\u7684 `master.css` assets\n compilation.hooks.finishModules.tap(NAME, (modules) => {\n const { modifiedFiles, watching } = compiler\n const eachExtractions: string[] = []\n\n for (const eachModule of modules) {\n const name = eachModule['resource']\n // \u5F9E\u8A18\u61B6\u9AD4\u6216\u5FEB\u53D6\u53D6\u5F97\u7576\u524D module \u7684\u539F\u59CB\u78BC\n const content = eachModule['_source']?.source()\n // \u5728 watch \u6A21\u5F0F\u4E0B\u50C5\u8655\u7406\u7576\u4E0B\u8B8A\u66F4\u7684\u6A94\u6848\n if (watching && modifiedFiles?.size && !modifiedFiles.has(name)) { continue }\n eachExtractions.push(...this.extract({ name, content }))\n }\n\n if (eachExtractions.length) {\n const originalCssText = this.css.text\n /* \u6BD4\u5C0D\u63D0\u53D6\u7269\u4E26\u63D2\u5165 CSS \u898F\u5247 */\n this.insert(eachExtractions)\n /* \u6839\u64DA cssText \u751F\u6210 `master.css` \u4E26\u52A0\u5165\u5230 Webpack \u7684 assets \u4E2D */\n const cssText = this.css.text\n if (cssText !== originalCssText) {\n const newSource = new RawSource(cssText)\n if (compilation.getAsset(outputPath)) {\n compilation.updateAsset(outputPath, newSource)\n } else {\n compilation.emitAsset(outputPath, newSource)\n }\n }\n }\n })\n\n compilation.hooks.processAssets.tap({\n name: NAME,\n stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,\n }, () => {\n compilation.chunks.forEach((chunk) => {\n chunk.files.add(outputPath)\n })\n })\n })\n }\n}\n", "import MasterCSSCompiler from './compiler'\nimport path from 'path'\nimport writeFile from './utils/write-file'\nimport type { MasterCSSCompilerOptions } from './options'\nimport type { PluginOption } from 'vite'\n\nexport default async function (options?: MasterCSSCompilerOptions): Promise<PluginOption> {\n const compiler = new MasterCSSCompiler(options)\n await compiler.initializing\n const outputPath = path.join(compiler.options.output.dir || '', compiler.options.output.name)\n\n let server\n let outputFilePath: string\n let linkHref: string\n let rendered = false\n\n const extract = (name, content) => {\n const eachExtractions = compiler.extract({ name, content })\n if (eachExtractions.length) {\n const originalCssText = compiler.css.text\n /* \u6BD4\u5C0D\u63D0\u53D6\u7269\u4E26\u63D2\u5165 CSS \u898F\u5247 */\n compiler.insert(eachExtractions)\n /* \u6839\u64DA cssText \u751F\u6210 `master.css` \u4E26\u52A0\u5165\u5230 Webpack \u7684 assets \u4E2D */\n const cssText = compiler.css.text\n if (cssText !== originalCssText) {\n if (server) {\n writeFile(outputFilePath, cssText)\n\n const notify = () => {\n server.ws.send({\n type: 'update',\n updates: [{\n path: linkHref,\n timestamp: Date.now()\n }]\n })\n }\n\n if (rendered) {\n notify()\n } else {\n setTimeout(notify, 500)\n\n rendered = true\n }\n }\n }\n }\n }\n\n return {\n name: 'vite-plugin-master-css',\n enforce: 'pre',\n configureServer(_server) {\n server = _server\n },\n buildStart() {\n outputFilePath = path.resolve(server?.config.cacheDir ?? process.cwd(), outputPath)\n if (server) {\n writeFile(outputFilePath, '')\n\n linkHref = (server.config.cacheDir.slice(process.cwd().length) + '/' + outputPath).replace(/\\\\/g, '/')\n }\n },\n resolveId(source) {\n if (source.endsWith('master.css?direct'))\n return '\\0' + source\n },\n transform(code, id) {\n extract(id, code)\n },\n transformIndexHtml(html) {\n return html.replace(\n /(<head>)/,\n `$1<link rel=\"stylesheet\" href=\"${linkHref}\">`\n )\n },\n async handleHotUpdate(hmrContext) {\n extract(hmrContext.file, await hmrContext.read())\n },\n generateBundle() {\n const referenceId = this.emitFile({\n type: 'asset',\n name: outputPath,\n source: compiler.css.text\n })\n linkHref = '/' + this.getFileName(referenceId)\n }\n } as PluginOption\n}", "import fs from 'fs'\nimport path from 'path'\n\nexport default function writeFile(filePath: string, data: string | NodeJS.ArrayBufferView, options?: fs.WriteFileOptions) {\n const dirname = path.dirname(filePath)\n if (!fs.existsSync(dirname)) {\n fs.mkdirSync(dirname, { recursive: true })\n }\n fs.writeFileSync(filePath, data, options)\n\n}\n"],
|
|
5
|
-
"mappings": "6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,EAAA,wBAAAC,EAAA,2BAAAC,IAAA,eAAAC,EAAAL,GCAA,IAAAM,EAAiB,mBACjBC,EAAkB,oBCDlB,IAAAC,EAAiC,uBAGlB,SAARC,EAAyB,CAAE,QAAAC,CAAQ,EAA4B,CAClE,IAAMC,EAASD,EAAQ,MAAM,SAAS,GAAK,CAAC,EACtCE,EAAU,IAAI,IACpB,QAAWC,KAASF,EAAQ,CACxB,IAAMG,EAASC,EAAWF,CAAK,EAC/B,GAAIC,EAAO,KACP,QAAWE,KAAUF,EACjBF,EAAQ,IAAII,CAAM,OAGtBJ,EAAQ,IAAIK,EAAWJ,CAAK,CAAC,CAErC,CACA,MAAO,CAAC,GAAGD,CAAO,EAAE,OAAOM,GAAKA,GAAK,CAACC,EAAeD,CAAC,CAAC,CAC3D,CAEA,IAAMD,EAAcP,GAAY,CAC5B,IAAMU,EAAgBV,EAKtB,OAJAA,EAAU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,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
|
-
import O from"path";import f from"chalk";import{defaultSemantics as P}from"@master/css";function b({content:t}){let e=t.match(/[^\s]+/g)??[],r=new Set;for(let s of e){let i=A(s);if(i.size)for(let n of i)r.add(n);else r.add($(s))}return[...r].filter(s=>s&&!I(s))}var $=t=>{let e=t;return t=t.replace(/^([\w={[(\\]*["'`])/,""),t.match(/^content:((?<!\\)["'`])((?:\\\1|(?:(?!\1))[\S\s])*)((?<!\\)\1)$/)||(t=t.replace(/(\.*|[([{\\:#]*|["'`].*)$/,"")),e===t?t:$(t)},A=t=>{let e=new Set,r=/((?<!\\)["'`])((?:\\\1|(?:(?!\1))[\S\s])*)((?<!\\)\1)/g,s;for(;(s=r.exec(t))!==null;){s.index===r.lastIndex&&r.lastIndex++;let i=A(s[2]);if(i.size)for(let n of i)e.add(n);else e.add($(s[2]))}return e},I=t=>!t||!t.match(/(?:^[\w-]+:[\w$#]+)|(?:^[@~][\w-]+$)/)&&!Object.keys(P).includes(t)||t.match(/\*\*/)||t.match(/:\[/)||t.match(/\$\{/)||t.match(/\{\{/)||t.match(/\(\{[^}]*\}/)||t.match(/<\w+>|<\/\w+>/);var j={config:"./master.css.js",output:{name:"master.css",dir:""},accept({name:t}){if(t.match(/[\\/]node_modules[\\/]/))return!1;if(t.match(/\.(html|js|jsx|ts|tsx|svelte|astro|vue)$/i))return!0},extract:b},R=j;import D,{extend as H}from"@master/css";import{performance as T}from"perf_hooks";var d=class{constructor(e){this.options=e;this.options=H(R,e),(async()=>{let r;try{r=(await import(O.resolve(process.cwd(),this.options.config))).default}catch{}this.css=new D({config:r})})()}initializing;css;extractions=new Set;extract({name:e,content:r}){if(!e||!r||!this.options.accept?.({content:r,name:e}))return[];let s=[];this.log("accepts",` \u2192 ${O.relative(process.cwd(),e)}`);for(let i of this.options.extract({content:r,name:e}))this.extractions.has(i)||(this.extractions.add(i),s.push(i));return s}insert(e){let r=T.now();for(let n of e)this.css.findAndInsert(n);let s=Math.round((T.now()-r)*1e3),i=this.css.rules.map(n=>n.className);console.log(`[Master CSS] process ${f.green(e.length)} extractions in ${f.green(s)} \xB5s [${f.green(this.css.rules.length)} rules in ${f.green(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(i.length)} total valid classes: ${f.blue(i.join(" "))}`)}log(e,r){(this.options.debug===!0||Array.isArray(this.options.debug)&&this.options.debug.includes(e))&&console.log(r)}};import F from"path";var g="MasterCSSWebpackPlugin",M=class extends d{async apply(e){await this.initializing;let{webpack:r}=e,{Template:s,RuntimeGlobals:i,RuntimeModule:n}=r,{RawSource:S}=r.sources,{Compilation:C}=r,{options:o}=this,l=F.join(o.output.dir||"",o.output.name),x=l.replace(/\\/g,"/");e.hooks.thisCompilation.tap(g,a=>{let p=new WeakSet,u=(m,c)=>{p.has(m)||(p.add(m),c.add(i.publicPath),a.addRuntimeModule(m,new k(c)))};a.hooks.runtimeRequirementInTree.for(i.ensureChunkHandlers).tap(g,u),a.hooks.runtimeRequirementInTree.for(i.hmrDownloadUpdateHandlers).tap(g,u);class k extends n{runtimeRequirements;constructor(c){super("master-css-loading",10),this.runtimeRequirements=c}generate(){let{runtimeRequirements:c}=this;return c.has(i.hmrDownloadUpdateHandlers)?s.asString([Date.now().toString(),`const link = document.querySelector('[href*=\\'${x}\\'][rel=stylesheet]')`,"if (link) {",s.indent(["link.href = link.href.replace(/ts=[0-9]+/, 'ts=' + Date.now())"]),"}"]):""}}}),e.hooks.compilation.tap(g,a=>{a.hooks.finishModules.tap(g,p=>{let{modifiedFiles:u,watching:k}=e,m=[];for(let c of p){let h=c.resource,w=c._source?.source();k&&u?.size&&!u.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(p=>{p.files.add(l)})})})}};import E from"path";import v from"fs";import q from"path";function y(t,e,r){let s=q.dirname(t);v.existsSync(s)||v.mkdirSync(s,{recursive:!0}),v.writeFileSync(t,e,r)}async function z(t){let e=new d(t);await e.initializing;let r=E.join(e.options.output.dir||"",e.options.output.name),s,i,n,S=!1,C=(o,l)=>{let x=e.extract({name:o,content:l});if(x.length){let a=e.css.text;e.insert(x);let p=e.css.text;if(p!==a&&s){y(i,p);let u=()=>{s.ws.send({type:"update",updates:[{path:n,timestamp:Date.now()}]})};S?u():(setTimeout(u,500),S=!0)}}};return{name:"vite-plugin-master-css",enforce:"pre",configureServer(o){s=o},buildStart(){i=E.resolve(s?.config.cacheDir??process.cwd(),r),s&&(y(i,""),n=(s.config.cacheDir.slice(process.cwd().length)+"/"+r).replace(/\\/g,"/"))},resolveId(o){if(o.endsWith("master.css?direct"))return"\0"+o},transform(o,l){C(l,o)},transformIndexHtml(o){return o.replace(/(<head>)/,`$1<link rel="stylesheet" href="${n}">`)},async handleHotUpdate(o){C(o.file,await o.read())},generateBundle(){let o=this.emitFile({type:"asset",name:r,source:e.css.text});n="/"+this.getFileName(o)}}}export{d as MasterCSSCompiler,z as MasterCSSVitePlugin,M as MasterCSSWebpackPlugin};
|
|
2
|
-
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
DELETED
|
@@ -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 (async () => {\n let userConfig: MasterCSSConfig\n try {\n userConfig = (await import(path.resolve(process.cwd(), this.options.config))).default\n // eslint-disable-next-line no-empty\n } catch (err) { }\n this.css = new MasterCSS({ config: userConfig })\n })()\n }\n\n initializing: Promise<any>\n css: MasterCSS\n extractions = new Set<string>()\n\n extract({ name, content }: MasterCSSCompilerSource) {\n if (\n !name || !content\n || !this.options.accept?.({ content, name })\n ) {\n return []\n }\n const eachExtractions: string[] = []\n\n this.log('accepts', ` \u2192 ${path.relative(process.cwd(), name)}`)\n\n for (const eachNewExtraction of this.options.extract({ content, name })) {\n if (this.extractions.has(eachNewExtraction)) {\n continue\n } else {\n this.extractions.add(eachNewExtraction)\n eachExtractions.push(eachNewExtraction)\n }\n }\n return eachExtractions\n }\n\n insert(extractions) {\n const p1 = performance.now()\n\n /* \u6839\u64DA\u985E\u540D\u5C0B\u627E\u4E26\u63D2\u5165\u898F\u5247 ( MasterCSS \u672C\u8EAB\u5E36\u6709\u5FEB\u53D6\u6A5F\u5236\uFF0C\u91CD\u8907\u7684\u985E\u540D\u4E0D\u6703\u518D\u7DE8\u8B6F\u53CA\u7522\u751F ) */\n for (const eachExtraction of extractions) {\n this.css.findAndInsert(eachExtraction)\n }\n\n const spent = Math.round((performance.now() - p1) * 1000)\n const validClasses = this.css.rules.map((rule) => rule.className)\n\n /* \u5370\u51FA Master CSS \u7DE8\u8B6F\u6642\u9593 */\n console.log(`[Master CSS] process ${chalk.green(extractions.length)} extractions in ${chalk.green(spent)} \u00B5s [${chalk.green(this.css.rules.length)} rules in ${chalk.green(path.join(this.options.output.dir, this.options.output.name))}]`)\n\n this.log('extractions', ` \u2192 ${chalk.green(extractions.length)} extractions: ${chalk.blue(extractions.join(' '))}`)\n this.log('validClasses', ` \u2192 ${chalk.green(validClasses.length)} total valid classes: ${chalk.blue(validClasses.join(' '))}`)\n }\n\n log(name, content) {\n if (this.options.debug === true || Array.isArray(this.options.debug) && this.options.debug.includes(name)) {\n console.log(content)\n }\n }\n}", "import { defaultSemantics } from '@master/css'\nimport type { MasterCSSCompilerSource } from './index'\n\nexport default function extract({ content }: MasterCSSCompilerSource) {\n const blocks = content.match(/[^\\s]+/g) ?? []\n const strings = new Set<string>()\n for (const block of blocks) {\n const result = peelString(block)\n if (result.size) {\n for (const string of result) {\n strings.add(string)\n }\n } else {\n strings.add(trimString(block))\n }\n }\n return [...strings].filter(x => x && !checkToExclude(x))\n}\n\nconst trimString = (content) => {\n const originContent = content\n content = content.replace(/^([\\w={[(\\\\]*[\"'`])/, '')\n if (!content.match(/^content:((?<!\\\\)[\"'`])((?:\\\\\\1|(?:(?!\\1))[\\S\\s])*)((?<!\\\\)\\1)$/)) {\n content = content.replace(/(\\.*|[([{\\\\:#]*|[\"'`].*)$/, '')\n }\n if (originContent === content) {\n return content\n } else {\n return trimString(content)\n }\n}\n\nconst peelString = (content) => {\n const strings = new Set<string>()\n const stringRegx = /((?<!\\\\)[\"'`])((?:\\\\\\1|(?:(?!\\1))[\\S\\s])*)((?<!\\\\)\\1)/g\n let m\n while ((m = stringRegx.exec(content)) !== null) {\n if (m.index === stringRegx.lastIndex) {\n stringRegx.lastIndex++\n }\n const result = peelString(m[2])\n if (result.size) {\n for (const string of result) {\n strings.add(string)\n }\n } else {\n strings.add(trimString(m[2]))\n }\n }\n return strings\n}\n\nconst checkToExclude = (content) => {\n return !content\n || (!content.match(/(?:^[\\w-]+:[\\w$#]+)|(?:^[@~][\\w-]+$)/) && !Object.keys(defaultSemantics).includes(content))\n || content.match(/\\*\\*/)\n || content.match(/:\\[/)\n || content.match(/\\$\\{/)\n || content.match(/\\{\\{/)\n || content.match(/\\(\\{[^}]*\\}/)\n || content.match(/<\\w+>|<\\/\\w+>/)\n}", "import extract from './extract'\n\nconst defaultOptions: MasterCSSCompilerOptions = {\n config: './master.css.js',\n output: {\n name: 'master.css',\n dir: ''\n },\n accept({ name }) {\n if (name.match(/[\\\\/]node_modules[\\\\/]/)) {\n return false\n }\n if (name.match(/\\.(html|js|jsx|ts|tsx|svelte|astro|vue)$/i)) {\n return true\n }\n },\n extract\n}\n\nexport declare type MasterCSSCompilerSource = {\n name: string\n content: string\n}\n\nexport interface MasterCSSCompilerOptions {\n output?: {\n name: string\n dir: string\n },\n accept?: (source: MasterCSSCompilerSource) => boolean\n extract?: (source: MasterCSSCompilerSource) => string[]\n config?: string\n debug?: string[] | boolean\n}\n\nexport default defaultOptions", "import path from 'path'\nimport MasterCSSCompiler from './compiler'\nimport type { Compiler } from 'webpack'\n\nconst NAME = 'MasterCSSWebpackPlugin'\n\nexport default class MasterCSSWebpackPlugin extends MasterCSSCompiler {\n\n async apply(compiler: Compiler) {\n await this.initializing\n const { webpack } = compiler\n const { Template, RuntimeGlobals, RuntimeModule } = webpack\n const { RawSource } = webpack.sources\n const { Compilation } = webpack\n const { options } = this\n const outputPath = path.join(options.output.dir || '', options.output.name)\n const linkHref = outputPath.replace(/\\\\/g, '/')\n\n compiler.hooks.thisCompilation.tap(NAME, (compilation) => {\n\n const enabledChunks = new WeakSet()\n\n const handler = (chunk, set) => {\n if (enabledChunks.has(chunk))\n return\n\n enabledChunks.add(chunk)\n\n set.add(RuntimeGlobals.publicPath)\n\n compilation.addRuntimeModule(chunk, new CssLoadingRuntimeModule(set))\n }\n\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.ensureChunkHandlers)\n .tap(NAME, handler)\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.hmrDownloadUpdateHandlers)\n .tap(NAME, handler)\n\n class CssLoadingRuntimeModule extends RuntimeModule {\n\n runtimeRequirements: Set<string>\n\n constructor(runtimeRequirements: Set<string>) {\n super('master-css-loading', 10)\n\n this.runtimeRequirements = runtimeRequirements\n }\n\n generate() {\n const { runtimeRequirements } = this\n const withHmr = runtimeRequirements.has(RuntimeGlobals.hmrDownloadUpdateHandlers)\n if (!withHmr)\n return ''\n\n return Template.asString([\n Date.now().toString(),\n `const link = document.querySelector('[href*=\\\\'${linkHref}\\\\'][rel=stylesheet]')`,\n 'if (link) {',\n Template.indent([\n 'link.href = link.href.replace(/ts=[0-9]+/, \\'ts=\\' + Date.now())'\n ]),\n '}'\n ])\n }\n }\n })\n\n compiler.hooks.compilation.tap(NAME, (compilation) => {\n // \u589E\u52A0\u984D\u5916\u7684 `master.css` assets\n compilation.hooks.finishModules.tap(NAME, (modules) => {\n const { modifiedFiles, watching } = compiler\n const eachExtractions: string[] = []\n\n for (const eachModule of modules) {\n const name = eachModule['resource']\n // \u5F9E\u8A18\u61B6\u9AD4\u6216\u5FEB\u53D6\u53D6\u5F97\u7576\u524D module \u7684\u539F\u59CB\u78BC\n const content = eachModule['_source']?.source()\n // \u5728 watch \u6A21\u5F0F\u4E0B\u50C5\u8655\u7406\u7576\u4E0B\u8B8A\u66F4\u7684\u6A94\u6848\n if (watching && modifiedFiles?.size && !modifiedFiles.has(name)) { continue }\n eachExtractions.push(...this.extract({ name, content }))\n }\n\n if (eachExtractions.length) {\n const originalCssText = this.css.text\n /* \u6BD4\u5C0D\u63D0\u53D6\u7269\u4E26\u63D2\u5165 CSS \u898F\u5247 */\n this.insert(eachExtractions)\n /* \u6839\u64DA cssText \u751F\u6210 `master.css` \u4E26\u52A0\u5165\u5230 Webpack \u7684 assets \u4E2D */\n const cssText = this.css.text\n if (cssText !== originalCssText) {\n const newSource = new RawSource(cssText)\n if (compilation.getAsset(outputPath)) {\n compilation.updateAsset(outputPath, newSource)\n } else {\n compilation.emitAsset(outputPath, newSource)\n }\n }\n }\n })\n\n compilation.hooks.processAssets.tap({\n name: NAME,\n stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,\n }, () => {\n compilation.chunks.forEach((chunk) => {\n chunk.files.add(outputPath)\n })\n })\n })\n }\n}\n", "import MasterCSSCompiler from './compiler'\nimport path from 'path'\nimport writeFile from './utils/write-file'\nimport type { MasterCSSCompilerOptions } from './options'\nimport type { PluginOption } from 'vite'\n\nexport default async function (options?: MasterCSSCompilerOptions): Promise<PluginOption> {\n const compiler = new MasterCSSCompiler(options)\n await compiler.initializing\n const outputPath = path.join(compiler.options.output.dir || '', compiler.options.output.name)\n\n let server\n let outputFilePath: string\n let linkHref: string\n let rendered = false\n\n const extract = (name, content) => {\n const eachExtractions = compiler.extract({ name, content })\n if (eachExtractions.length) {\n const originalCssText = compiler.css.text\n /* \u6BD4\u5C0D\u63D0\u53D6\u7269\u4E26\u63D2\u5165 CSS \u898F\u5247 */\n compiler.insert(eachExtractions)\n /* \u6839\u64DA cssText \u751F\u6210 `master.css` \u4E26\u52A0\u5165\u5230 Webpack \u7684 assets \u4E2D */\n const cssText = compiler.css.text\n if (cssText !== originalCssText) {\n if (server) {\n writeFile(outputFilePath, cssText)\n\n const notify = () => {\n server.ws.send({\n type: 'update',\n updates: [{\n path: linkHref,\n timestamp: Date.now()\n }]\n })\n }\n\n if (rendered) {\n notify()\n } else {\n setTimeout(notify, 500)\n\n rendered = true\n }\n }\n }\n }\n }\n\n return {\n name: 'vite-plugin-master-css',\n enforce: 'pre',\n configureServer(_server) {\n server = _server\n },\n buildStart() {\n outputFilePath = path.resolve(server?.config.cacheDir ?? process.cwd(), outputPath)\n if (server) {\n writeFile(outputFilePath, '')\n\n linkHref = (server.config.cacheDir.slice(process.cwd().length) + '/' + outputPath).replace(/\\\\/g, '/')\n }\n },\n resolveId(source) {\n if (source.endsWith('master.css?direct'))\n return '\\0' + source\n },\n transform(code, id) {\n extract(id, code)\n },\n transformIndexHtml(html) {\n return html.replace(\n /(<head>)/,\n `$1<link rel=\"stylesheet\" href=\"${linkHref}\">`\n )\n },\n async handleHotUpdate(hmrContext) {\n extract(hmrContext.file, await hmrContext.read())\n },\n generateBundle() {\n const referenceId = this.emitFile({\n type: 'asset',\n name: outputPath,\n source: compiler.css.text\n })\n linkHref = '/' + this.getFileName(referenceId)\n }\n } 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": "AAAA,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,EAAeD,CAAC,CAAC,CAC3D,CAEA,IAAMD,EAAcP,GAAY,CAC5B,IAAMU,EAAgBV,EAKtB,OAJAA,EAAUA,EAAQ,QAAQ,sBAAuB,EAAE,EAC9CA,EAAQ,MAAM,iEAAiE,IAChFA,EAAUA,EAAQ,QAAQ,4BAA6B,EAAE,GAEzDU,IAAkBV,EACXA,EAEAO,EAAWP,CAAO,CAEjC,EAEMK,EAAcL,GAAY,CAC5B,IAAME,EAAU,IAAI,IACdS,EAAa,yDACfC,EACJ,MAAQA,EAAID,EAAW,KAAKX,CAAO,KAAO,MAAM,CACxCY,EAAE,QAAUD,EAAW,WACvBA,EAAW,YAEf,IAAMP,EAASC,EAAWO,EAAE,EAAE,EAC9B,GAAIR,EAAO,KACP,QAAWE,KAAUF,EACjBF,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IAAM,KAAK,YAAYgB,CAAW,CACjD,CACJ,CACJ",
|
|
6
|
-
"names": ["path", "chalk", "defaultSemantics", "extract", "content", "blocks", "strings", "block", "result", "peelString", "string", "trimString", "x", "checkToExclude", "originContent", "stringRegx", "m", "defaultOptions", "name", "extract", "options_default", "MasterCSS", "extend", "performance", "MasterCSSCompiler", "options", "options_default", "userConfig", "path", "name", "content", "eachExtractions", "eachNewExtraction", "extractions", "p1", "eachExtraction", "spent", "validClasses", "rule", "chalk", "path", "NAME", "MasterCSSWebpackPlugin", "MasterCSSCompiler", "compiler", "webpack", "Template", "RuntimeGlobals", "RuntimeModule", "RawSource", "Compilation", "options", "outputPath", "path", "linkHref", "compilation", "enabledChunks", "handler", "chunk", "set", "CssLoadingRuntimeModule", "runtimeRequirements", "modules", "modifiedFiles", "watching", "eachExtractions", "eachModule", "name", "content", "originalCssText", "cssText", "newSource", "path", "fs", "path", "writeFile", "filePath", "data", "options", "dirname", "vite_default", "options", "compiler", "MasterCSSCompiler", "outputPath", "path", "server", "outputFilePath", "linkHref", "rendered", "extract", "name", "content", "eachExtractions", "originalCssText", "cssText", "writeFile", "notify", "_server", "source", "code", "id", "html", "hmrContext", "referenceId"]
|
|
7
|
-
}
|
package/dist/vite.d.ts
DELETED
package/dist/webpack.d.ts
DELETED
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
|
-
[](https://github.com/master-co/css-compiler/blob/main/LICENSE)
|
|
13
|
-
[](https://www.npmjs.com/package/@master/css-compiler)
|
|
14
|
-
[](https://css.master.co)
|
|
15
|
-
[](https://github.com/master-co/css)
|
|
16
|
-
[](https://discord.gg/sZNKpAAAw6)
|
|
17
|
-
[](https://circleci.com/gh/master-co/workflows/css-compiler/tree/main)
|
|
18
|
-
|
|
19
|
-
</div>
|
|
20
|
-
|
|
21
|
-
##### On this page
|
|
22
|
-
|
|
23
|
-
- [Usage](#usage)
|
|
24
|
-
- [`webpack.config.js`](#webpackconfigjs)
|
|
25
|
-
- [`vite.config.js`](#viteconfigjs)
|
|
26
|
-
- [`next.config.js`](#nextconfigjs)
|
|
27
|
-
- [Related](#related)
|
|
28
|
-
|
|
29
|
-
---
|
|
30
|
-
|
|
31
|
-
# Usage
|
|
32
|
-
|
|
33
|
-
## `webpack.config.js`
|
|
34
|
-
```js
|
|
35
|
-
const { MasterCSSWebpackPlugin } = require('@master/css-compiler')
|
|
36
|
-
|
|
37
|
-
module.exports = {
|
|
38
|
-
plugins: [
|
|
39
|
-
new MasterCSSWebpackPlugin()
|
|
40
|
-
]
|
|
41
|
-
};
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
## `vite.config.js`
|
|
45
|
-
```js
|
|
46
|
-
import { MasterCSSVitePlugin } from '@master/css-compiler'
|
|
47
|
-
|
|
48
|
-
export default defineConfig({
|
|
49
|
-
plugins: [
|
|
50
|
-
MasterCSSVitePlugin()
|
|
51
|
-
]
|
|
52
|
-
})
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## `next.config.js`
|
|
56
|
-
```js
|
|
57
|
-
const { MasterCSSWebpackPlugin } = require('@master/css-compiler')
|
|
58
|
-
|
|
59
|
-
const nextConfig = {
|
|
60
|
-
...,
|
|
61
|
-
webpack: (config) => {
|
|
62
|
-
config.plugins.push(
|
|
63
|
-
new MasterCSSWebpackPlugin({
|
|
64
|
-
output: {
|
|
65
|
-
path: 'static/css'
|
|
66
|
-
}
|
|
67
|
-
})
|
|
68
|
-
)
|
|
69
|
-
return config
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
module.exports = nextConfig
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
---
|
|
77
|
-
|
|
78
|
-
# Related
|
|
79
|
-
- [@master/css](https://github.com/master-co/css) - A Virtual CSS language with enhanced syntax. ( ~13KB )
|
|
80
|
-
- [@master/css.react](https://github.com/master-co/css.react) - React hooks for Master CSS
|