@fastkit/plugboy-vanilla-extract-plugin 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/css.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { StyleRule, GlobalStyleRule } from '@vanilla-extract/css';
|
|
2
|
+
|
|
3
|
+
type LayerStyleRules = NonNullable<StyleRule['@layer']>[string];
|
|
4
|
+
type LayerGlobalStyleRules = NonNullable<GlobalStyleRule['@layer']>[string];
|
|
5
|
+
interface LayerStyle {
|
|
6
|
+
layerName: string;
|
|
7
|
+
parentLayerName: string | null;
|
|
8
|
+
/**
|
|
9
|
+
* @see {@link style}
|
|
10
|
+
*/
|
|
11
|
+
(rule: LayerStyleRules, debugId?: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* @see {@link style}
|
|
14
|
+
*/
|
|
15
|
+
style(rule: LayerStyleRules, debugId?: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* @see {@link globalStyle}
|
|
18
|
+
*/
|
|
19
|
+
global(selector: string, rule: LayerGlobalStyleRules): void;
|
|
20
|
+
defineNestedLayer(globalNameOrNestedOptions?: string | NestedLayerOptions): LayerStyle;
|
|
21
|
+
}
|
|
22
|
+
interface DefineLayerBaseOptions {
|
|
23
|
+
parent?: string;
|
|
24
|
+
}
|
|
25
|
+
interface DefineLayerScopedOptions extends DefineLayerBaseOptions {
|
|
26
|
+
debugId?: string;
|
|
27
|
+
}
|
|
28
|
+
interface DefineLayerGlobalOptions extends DefineLayerBaseOptions {
|
|
29
|
+
globalName: string;
|
|
30
|
+
}
|
|
31
|
+
type DefineLayerOptions = DefineLayerScopedOptions | DefineLayerGlobalOptions;
|
|
32
|
+
type NestedLayerOptions = Omit<DefineLayerOptions, 'parent'>;
|
|
33
|
+
declare function defineLayerStyle(globalNameOrOptions?: string | DefineLayerOptions): LayerStyle;
|
|
34
|
+
|
|
35
|
+
export { DefineLayerBaseOptions, DefineLayerGlobalOptions, DefineLayerOptions, DefineLayerScopedOptions, LayerStyle, NestedLayerOptions, defineLayerStyle };
|
package/dist/css.mjs
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { globalLayer, layer, globalStyle, style } from '@vanilla-extract/css';
|
|
2
|
+
|
|
3
|
+
function isGlobalOptions(options) {
|
|
4
|
+
return "globalName" in options;
|
|
5
|
+
}
|
|
6
|
+
function normalizeToObject(source) {
|
|
7
|
+
if (!source)
|
|
8
|
+
return {};
|
|
9
|
+
if (typeof source === "string")
|
|
10
|
+
return { globalName: source };
|
|
11
|
+
return source;
|
|
12
|
+
}
|
|
13
|
+
function defineLayerStyle(globalNameOrOptions) {
|
|
14
|
+
const options = normalizeToObject(globalNameOrOptions);
|
|
15
|
+
const { parent } = options;
|
|
16
|
+
const layerName = isGlobalOptions(options) ? globalLayer({ parent }, options.globalName) : layer({ parent }, options.debugId);
|
|
17
|
+
const layerStyle = function layerStyle2(rule, debugId) {
|
|
18
|
+
return style(
|
|
19
|
+
{
|
|
20
|
+
"@layer": {
|
|
21
|
+
[layerName]: rule
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
debugId
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
layerStyle.layerName = layerName;
|
|
28
|
+
layerStyle.parentLayerName = parent || null;
|
|
29
|
+
layerStyle.style = layerStyle;
|
|
30
|
+
layerStyle.global = function layerGlobalStyle(selector, rule) {
|
|
31
|
+
return globalStyle(selector, {
|
|
32
|
+
"@layer": {
|
|
33
|
+
[layerName]: rule
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
layerStyle.defineNestedLayer = function defineNestedLayer(globalNameOrNestedOptions) {
|
|
38
|
+
const options2 = normalizeToObject(globalNameOrNestedOptions);
|
|
39
|
+
return defineLayerStyle({
|
|
40
|
+
...options2,
|
|
41
|
+
parent: layerName
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
return layerStyle;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { defineLayerStyle };
|
|
48
|
+
//# sourceMappingURL=out.js.map
|
|
49
|
+
//# sourceMappingURL=css.mjs.map
|
package/dist/css.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/css/layer.ts"],"names":["layerStyle","options"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,OAEK;AA+CP,SAAS,gBACP,SACqC;AACrC,SAAO,gBAAgB;AACzB;AAEA,SAAS,kBACP,QACG;AACH,MAAI,CAAC;AAAQ,WAAO,CAAC;AACrB,MAAI,OAAO,WAAW;AAAU,WAAO,EAAE,YAAY,OAAO;AAC5D,SAAO;AACT;AAEO,SAAS,iBACd,qBACY;AACZ,QAAM,UAAU,kBAAkB,mBAAmB;AACrD,QAAM,EAAE,OAAO,IAAI;AAEnB,QAAM,YAAY,gBAAgB,OAAO,IACrC,YAAY,EAAE,OAAO,GAAG,QAAQ,UAAU,IAC1C,MAAM,EAAE,OAAO,GAAG,QAAQ,OAAO;AAErC,QAAM,aAAyB,SAASA,YAAW,MAAM,SAAS;AAChE,WAAO;AAAA,MACL;AAAA,QACE,UAAU;AAAA,UACR,CAAC,SAAS,GAAG;AAAA,QACf;AAAA,MACF;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,aAAW,YAAY;AACvB,aAAW,kBAAkB,UAAU;AACvC,aAAW,QAAQ;AAEnB,aAAW,SAAS,SAAS,iBAAiB,UAAU,MAAM;AAC5D,WAAO,YAAY,UAAU;AAAA,MAC3B,UAAU;AAAA,QACR,CAAC,SAAS,GAAG;AAAA,MACf;AAAA,IACF,CAAC;AAAA,EACH;AAEA,aAAW,oBAAoB,SAAS,kBACtC,2BACA;AACA,UAAMC,WAAU,kBAAkB,yBAAyB;AAC3D,WAAO,iBAAiB;AAAA,MACtB,GAAGA;AAAA,MACH,QAAQ;AAAA,IACV,CAAC;AAAA,EACH;AAEA,SAAO;AACT","sourcesContent":["import {\n style,\n layer,\n globalLayer,\n StyleRule,\n globalStyle,\n GlobalStyleRule,\n} from '@vanilla-extract/css';\n\ntype LayerStyleRules = NonNullable<StyleRule['@layer']>[string];\n\ntype LayerGlobalStyleRules = NonNullable<GlobalStyleRule['@layer']>[string];\n\nexport interface LayerStyle {\n layerName: string;\n parentLayerName: string | null;\n /**\n * @see {@link style}\n */\n (rule: LayerStyleRules, debugId?: string): string;\n\n /**\n * @see {@link style}\n */\n style(rule: LayerStyleRules, debugId?: string): string;\n\n /**\n * @see {@link globalStyle}\n */\n global(selector: string, rule: LayerGlobalStyleRules): void;\n\n defineNestedLayer(\n globalNameOrNestedOptions?: string | NestedLayerOptions,\n ): LayerStyle;\n}\n\nexport interface DefineLayerBaseOptions {\n parent?: string;\n}\n\nexport interface DefineLayerScopedOptions extends DefineLayerBaseOptions {\n debugId?: string;\n}\n\nexport interface DefineLayerGlobalOptions extends DefineLayerBaseOptions {\n globalName: string;\n}\n\nexport type DefineLayerOptions =\n | DefineLayerScopedOptions\n | DefineLayerGlobalOptions;\n\nexport type NestedLayerOptions = Omit<DefineLayerOptions, 'parent'>;\n\nfunction isGlobalOptions(\n options: DefineLayerOptions,\n): options is DefineLayerGlobalOptions {\n return 'globalName' in options;\n}\n\nfunction normalizeToObject<T extends NestedLayerOptions>(\n source?: string | T,\n): T {\n if (!source) return {} as T;\n if (typeof source === 'string') return { globalName: source } as unknown as T;\n return source;\n}\n\nexport function defineLayerStyle(\n globalNameOrOptions?: string | DefineLayerOptions,\n): LayerStyle {\n const options = normalizeToObject(globalNameOrOptions);\n const { parent } = options;\n\n const layerName = isGlobalOptions(options)\n ? globalLayer({ parent }, options.globalName)\n : layer({ parent }, options.debugId);\n\n const layerStyle: LayerStyle = function layerStyle(rule, debugId) {\n return style(\n {\n '@layer': {\n [layerName]: rule,\n },\n },\n debugId,\n );\n };\n\n layerStyle.layerName = layerName;\n layerStyle.parentLayerName = parent || null;\n layerStyle.style = layerStyle;\n\n layerStyle.global = function layerGlobalStyle(selector, rule) {\n return globalStyle(selector, {\n '@layer': {\n [layerName]: rule,\n },\n });\n };\n\n layerStyle.defineNestedLayer = function defineNestedLayer(\n globalNameOrNestedOptions,\n ) {\n const options = normalizeToObject(globalNameOrNestedOptions);\n return defineLayerStyle({\n ...options,\n parent: layerName,\n });\n };\n\n return layerStyle;\n}\n"]}
|
|
@@ -27,6 +27,26 @@ function ESBuildVanillaExtract(options = {}) {
|
|
|
27
27
|
}
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
+
var extMatchRe = /\.(mjs|css)$/;
|
|
31
|
+
function extractExt(filePath) {
|
|
32
|
+
return filePath.match(extMatchRe)?.[1];
|
|
33
|
+
}
|
|
34
|
+
var emptyVanillaImportRe = /(^|\n)import '@vanilla-extract\/css';?/g;
|
|
35
|
+
function cleanJS(code) {
|
|
36
|
+
return code.replace(emptyVanillaImportRe, "");
|
|
37
|
+
}
|
|
38
|
+
var allLayerDefMatchRe = /(^|\n)@layer ([a-zA-Z\d\-_\$\.]+?);/g;
|
|
39
|
+
function cleanCSS(code) {
|
|
40
|
+
const layersDefs = code.match(allLayerDefMatchRe);
|
|
41
|
+
if (!layersDefs?.length)
|
|
42
|
+
return code;
|
|
43
|
+
const uniques = Array.from(new Set(layersDefs)).map((row) => row.trim());
|
|
44
|
+
for (const def of uniques) {
|
|
45
|
+
code = code.replace(new RegExp(def + "\n?", "g"), "");
|
|
46
|
+
}
|
|
47
|
+
code = uniques.join("\n") + "\n\n" + code;
|
|
48
|
+
return code;
|
|
49
|
+
}
|
|
30
50
|
async function createVanillaExtractPlugin(options = {}) {
|
|
31
51
|
return definePlugin({
|
|
32
52
|
name: PLUGIN_NAME,
|
|
@@ -43,13 +63,14 @@ async function createVanillaExtractPlugin(options = {}) {
|
|
|
43
63
|
async onSuccess(builder, files) {
|
|
44
64
|
if (!builder.workspace.meta.hasVanillaExtract)
|
|
45
65
|
return;
|
|
46
|
-
const emptyVanillaImportRe = /(^|\n)import '@vanilla-extract\/css';?/g;
|
|
47
66
|
await Promise.all(
|
|
48
67
|
files.map(async ({ path: filePath }) => {
|
|
49
|
-
|
|
68
|
+
const ext = extractExt(filePath);
|
|
69
|
+
if (!ext)
|
|
50
70
|
return;
|
|
51
71
|
const code = await fs.readFile(filePath, "utf-8");
|
|
52
|
-
const
|
|
72
|
+
const cleaner = ext === "mjs" ? cleanJS : cleanCSS;
|
|
73
|
+
const replaced = cleaner(code);
|
|
53
74
|
if (code === replaced)
|
|
54
75
|
return;
|
|
55
76
|
await fs.writeFile(filePath, replaced.trimStart(), "utf-8");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts","../src/plugin.ts","../src/esbuild.ts","../src/utils.ts","../src/vite.ts"],"names":["vanillaExtractPlugin"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeO,IAAM,cAAc;;;ACf3B,SAAS,cAAc,gBAAgB;;;ACCvC,SAAS,4BAA4B;;;ACDrC,IAAM,oBAAoB,CAAC,QAAQ;AAE5B,SAAS,iBAAiB,QAA4C;AAC3E,QAAM,SAAmB,CAAC,GAAG,iBAAiB;AAC9C,aAAW,SAAS,QAAQ;AAC1B,aAAS,OAAO,KAAK,GAAG,KAAK;AAAA,EAC/B;AACA,SAAO,MAAM,KAAK,IAAI,IAAI,MAAM,CAAC;AACnC;;;ADHO,SAAS,sBACd,UAAyB,CAAC,GACX;AACf,QAAM,EAAE,iBAAiB,CAAC,EAAE,IAAI;AAEhC,SAAO,qBAAqB;AAAA,IAC1B,GAAG;AAAA,IACH,gBAAgB;AAAA,MACd,GAAG;AAAA,MACH,UAAU,cAAc,eAAe,QAAQ;AAAA,IACjD;AAAA,EACF,CAAC;AACH;;;ADdA,OAAO,QAAQ;AAQf,eAAsB,2BAA2B,UAAyB,CAAC,GAAG;AAC5E,SAAO,aAAmC;AAAA,IACxC,MAAM;AAAA,I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AAA,MACd,CAAC,cAAc;AACb,YAAI,CAAC,UAAU,KAAK;AAAmB;AACvC,eAAO,sBAAsB,OAAO;AAAA,MACtC;AAAA,IACF;AAAA,EACF,CAAC;AACH;;;AG5EA,SAAS,yBAAyB;AAElC,SAAS,wBAAAA,6BAA4B;AAWrC,eAAsB,yBACpB,UAA2C,CAAC,GACvB;AACrB,QAAM,SAAS,MAAM,kBAAwC,WAAW;AACxE,QAAM;AAAA,IACJ,aAAa;AAAA,IACb,gBAAgB,qBAAqB,CAAC;AAAA,EACxC,IAAI,QAAQ,WAAW,CAAC;AAExB,QAAM,EAAE,iBAAiB,CAAC,EAAE,IAAI;AAEhC,SAAOA,sBAAqB;AAAA,IAC1B,aAAa;AAAA,IACb,GAAG;AAAA,IACH,gBAAgB;AAAA,MACd,GAAG;AAAA,MACH,GAAG;AAAA,MACH,UAAU;AAAA,QACR,mBAAmB;AAAA,QACnB,eAAe;AAAA,MACjB;AAAA,IACF;AAAA,EACF,CAAC;AACH","sourcesContent":["import { Plugin } from '@fastkit/plugboy';\nimport type { vanillaExtractPlugin as esbuildPlugin } from '@vanilla-extract/esbuild-plugin';\n\ntype VanillaExtractPluginOptions = NonNullable<\n Parameters<typeof esbuildPlugin>[0]\n>;\n\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface VanillaExtractEsbuildOptions\n extends NonNullable<VanillaExtractPluginOptions['esbuildOptions']> {}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface PluginOptions\n extends Pick<VanillaExtractPluginOptions, 'identifiers' | 'esbuildOptions'> {}\n\nexport const PLUGIN_NAME = 'plugboy-vanilla-extract';\n\nexport interface VanillaExtractPlugin extends Plugin {\n name: typeof PLUGIN_NAME;\n options: PluginOptions;\n}\n","import { definePlugin, findFile } from '@fastkit/plugboy';\nimport { ESBuildVanillaExtract } from './esbuild';\nimport { VanillaExtractPlugin, PluginOptions, PLUGIN_NAME } from './types';\nimport fs from 'node:fs/promises';\n\ndeclare module '@fastkit/plugboy' {\n export interface WorkspaceMeta {\n hasVanillaExtract: boolean;\n }\n}\n\nconst extMatchRe = /\\.(mjs|css)$/;\n\nfunction extractExt(filePath: string) {\n return filePath.match(extMatchRe)?.[1] as 'mjs' | 'css' | undefined;\n}\n\nconst emptyVanillaImportRe = /(^|\\n)import '@vanilla-extract\\/css';?/g;\n\nfunction cleanJS(code: string) {\n return code.replace(emptyVanillaImportRe, '');\n}\n\nconst allLayerDefMatchRe = /(^|\\n)@layer ([a-zA-Z\\d\\-_\\$\\.]+?);/g;\n\nfunction cleanCSS(code: string) {\n const layersDefs = code.match(allLayerDefMatchRe);\n if (!layersDefs?.length) return code;\n const uniques = Array.from(new Set(layersDefs)).map((row) => row.trim());\n\n for (const def of uniques) {\n code = code.replace(new RegExp(def + '\\n?', 'g'), '');\n }\n\n code = uniques.join('\\n') + '\\n\\n' + code;\n return code;\n}\n\nexport async function createVanillaExtractPlugin(options: PluginOptions = {}) {\n return definePlugin<VanillaExtractPlugin>({\n name: PLUGIN_NAME,\n options,\n hooks: {\n async setupWorkspace(ctx) {\n const { external = [] } = ctx.config;\n\n ctx.config.external = [...external, /@vanilla\\-extract/];\n\n ctx.meta.hasVanillaExtract = await !!findFile(\n ctx.dirs.src.value,\n /\\.css\\.ts$/,\n );\n },\n async onSuccess(builder, files) {\n if (!builder.workspace.meta.hasVanillaExtract) return;\n await Promise.all(\n files.map(async ({ path: filePath }) => {\n const ext = extractExt(filePath);\n if (!ext) return;\n\n const code = await fs.readFile(filePath, 'utf-8');\n const cleaner = ext === 'mjs' ? cleanJS : cleanCSS;\n const replaced = cleaner(code);\n if (code === replaced) return;\n\n await fs.writeFile(filePath, replaced.trimStart(), 'utf-8');\n }),\n );\n },\n },\n esbuildPlugins: [\n (workspace) => {\n if (!workspace.meta.hasVanillaExtract) return;\n return ESBuildVanillaExtract(options);\n },\n ],\n });\n}\n","import { ESBuildPlugin } from '@fastkit/plugboy';\nimport { vanillaExtractPlugin } from '@vanilla-extract/esbuild-plugin';\nimport { PluginOptions } from './types';\nimport { mergeExternal } from './utils';\n\nexport function ESBuildVanillaExtract(\n options: PluginOptions = {},\n): ESBuildPlugin {\n const { esbuildOptions = {} } = options;\n\n return vanillaExtractPlugin({\n ...options,\n esbuildOptions: {\n ...esbuildOptions,\n external: mergeExternal(esbuildOptions.external),\n },\n }) as any;\n}\n","const EXTERNAL_DEFAULTS = ['node:*'];\n\nexport function mergeExternal(...chunks: (string[] | undefined)[]): string[] {\n const result: string[] = [...EXTERNAL_DEFAULTS];\n for (const chunk of chunks) {\n chunk && result.push(...chunk);\n }\n return Array.from(new Set(result));\n}\n","import { PLUGIN_NAME, VanillaExtractPlugin } from './types';\nimport { findProjectPlugin } from '@fastkit/plugboy';\nimport { Plugin as VitePlugin } from 'vite';\nimport { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin';\nimport { mergeExternal } from './utils';\n\ntype VanillaExtractVitePluginOptions = NonNullable<\n Parameters<typeof vanillaExtractPlugin>[0]\n>;\n\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface ViteVanillaExtractPluginOptions\n extends VanillaExtractVitePluginOptions {}\n\nexport async function ViteVanillaExtractPlugin(\n options: ViteVanillaExtractPluginOptions = {},\n): Promise<VitePlugin> {\n const plugin = await findProjectPlugin<VanillaExtractPlugin>(PLUGIN_NAME);\n const {\n identifiers: baseIdentifiers,\n esbuildOptions: baseEsbuildOptions = {},\n } = plugin?.options || {};\n\n const { esbuildOptions = {} } = options;\n\n return vanillaExtractPlugin({\n identifiers: baseIdentifiers,\n ...options,\n esbuildOptions: {\n ...baseEsbuildOptions,\n ...esbuildOptions,\n external: mergeExternal(\n baseEsbuildOptions.external,\n esbuildOptions.external,\n ),\n },\n });\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fastkit/plugboy-vanilla-extract-plugin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"repository": {
|
|
@@ -18,6 +18,12 @@
|
|
|
18
18
|
"default": "./dist/plugboy-vanilla-extract-plugin.mjs"
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
|
+
"./css": {
|
|
22
|
+
"types": "./dist/css.d.ts",
|
|
23
|
+
"import": {
|
|
24
|
+
"default": "./dist/css.mjs"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
21
27
|
"./*": "./dist/*"
|
|
22
28
|
},
|
|
23
29
|
"main": "./dist/plugboy-vanilla-extract-plugin.mjs",
|
|
@@ -26,6 +32,9 @@
|
|
|
26
32
|
"*": {
|
|
27
33
|
".": [
|
|
28
34
|
"./dist/plugboy-vanilla-extract-plugin.d.ts"
|
|
35
|
+
],
|
|
36
|
+
"css": [
|
|
37
|
+
"./dist/css.d.ts"
|
|
29
38
|
]
|
|
30
39
|
}
|
|
31
40
|
},
|
|
@@ -39,11 +48,11 @@
|
|
|
39
48
|
},
|
|
40
49
|
"devDependencies": {
|
|
41
50
|
"vite": "^4.1.1",
|
|
42
|
-
"@fastkit/plugboy": "0.1.
|
|
51
|
+
"@fastkit/plugboy": "0.1.1"
|
|
43
52
|
},
|
|
44
53
|
"peerDependencies": {
|
|
45
54
|
"vite": "^4.1.1",
|
|
46
|
-
"@fastkit/plugboy": "0.1.
|
|
55
|
+
"@fastkit/plugboy": "0.1.1"
|
|
47
56
|
},
|
|
48
57
|
"peerDependenciesMeta": {
|
|
49
58
|
"@vanilla-extract/vite-plugin": {
|