@fastkit/plugboy-vanilla-extract-plugin 4.0.0-next.13 → 4.0.0-next.14

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fastkit/plugboy-vanilla-extract-plugin",
3
- "version": "4.0.0-next.13",
3
+ "version": "4.0.0-next.14",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "repository": {
@@ -18,12 +18,6 @@
18
18
  "default": "./dist/plugboy-vanilla-extract-plugin.mjs"
19
19
  }
20
20
  },
21
- "./css": {
22
- "types": "./dist/css.d.mts",
23
- "import": {
24
- "default": "./dist/css.mjs"
25
- }
26
- },
27
21
  "./*": "./dist/*"
28
22
  },
29
23
  "main": "./dist/plugboy-vanilla-extract-plugin.mjs",
@@ -32,9 +26,6 @@
32
26
  "*": {
33
27
  ".": [
34
28
  "./dist/plugboy-vanilla-extract-plugin.d.mts"
35
- ],
36
- "css": [
37
- "./dist/css.d.mts"
38
29
  ]
39
30
  }
40
31
  },
@@ -42,17 +33,16 @@
42
33
  "dist"
43
34
  ],
44
35
  "dependencies": {
45
- "@vanilla-extract/css": "^1.20.1",
46
36
  "@vanilla-extract/rollup-plugin": "^1.5.3",
47
37
  "@vanilla-extract/vite-plugin": "^5.2.2"
48
38
  },
49
39
  "devDependencies": {
50
40
  "vite": "^8.0.16",
51
- "@fastkit/plugboy": "^1.0.0-next.6"
41
+ "@fastkit/plugboy": "^1.0.0-next.9"
52
42
  },
53
43
  "peerDependencies": {
54
44
  "vite": "^5.0.0 || ^6.0.0 || ^7.0.0",
55
- "@fastkit/plugboy": "^1.0.0-next.6"
45
+ "@fastkit/plugboy": "^1.0.0-next.9"
56
46
  },
57
47
  "peerDependenciesMeta": {
58
48
  "@vanilla-extract/vite-plugin": {
package/dist/css.d.mts DELETED
@@ -1,95 +0,0 @@
1
- import { GlobalStyleRule, StyleRule, createGlobalTheme } from "@vanilla-extract/css";
2
-
3
- //#region src/css/layer.d.ts
4
- type CustomStyleRules = Record<string, any>;
5
- type _LayerStyleRules = NonNullable<StyleRule['@layer']>[string];
6
- type LayerStyleRules<CustomRules extends CustomStyleRules | null = null> = CustomRules extends null ? _LayerStyleRules : _LayerStyleRules & CustomRules;
7
- type ClassNames = string | ClassNames[];
8
- type ComplexLayerStyleRule<CustomRules extends CustomStyleRules | null = null> = LayerStyleRules<CustomRules> | (LayerStyleRules<CustomRules> | ClassNames)[];
9
- type _LayerGlobalStyleRules = NonNullable<GlobalStyleRule['@layer']>[string];
10
- type LayerGlobalStyleRules<CustomRules extends CustomStyleRules | null = null> = CustomRules extends null ? _LayerGlobalStyleRules : _LayerGlobalStyleRules & CustomRules;
11
- type AnyStyleRule<CustomRules extends CustomStyleRules | null = null> = LayerStyleRules<CustomRules> | LayerGlobalStyleRules<CustomRules>;
12
- type LayerStyleHooks<CustomRules extends CustomStyleRules | null = null> = {
13
- style?: (rule: ComplexLayerStyleRule<CustomRules>, debugId?: string) => void;
14
- global?: (selector: string, rule: LayerGlobalStyleRules<CustomRules>) => void;
15
- anyStyle?: (style: AnyStyleRule<CustomRules>) => void;
16
- };
17
- interface LayerStyle<CustomRules extends CustomStyleRules | null = null> {
18
- layerName: string;
19
- parentLayerName: string | null;
20
- /**
21
- * @see {@link style}
22
- */
23
- (rule: ComplexLayerStyleRule<CustomRules>, debugId?: string): string;
24
- /**
25
- * @see {@link style}
26
- */
27
- style(rule: ComplexLayerStyleRule<CustomRules>, debugId?: string): string;
28
- /**
29
- * @see {@link globalStyle}
30
- */
31
- global(selector: string, rule: LayerGlobalStyleRules<CustomRules>): void;
32
- /**
33
- * @see {@link _createGlobalTheme}
34
- */
35
- globalTheme: typeof createGlobalTheme;
36
- defineNestedLayer(globalNameOrNestedOptions?: string | DefineLayerOptions<CustomRules>): LayerStyle<CustomRules>;
37
- /**
38
- * Add global CSS variable with layer
39
- *
40
- * @remarks The vanilla-extract API is buggy when handling layered css variables.
41
- *
42
- * @param selector - selector
43
- * @param vars - variables
44
- */
45
- pushGlobalVars(selector: string, vars: Record<string, string>): void;
46
- /**
47
- * Output variables accumulated by `pushGlobalVars`.
48
- *
49
- * @remarks The vanilla-extract API is buggy when handling layered css variables.
50
- */
51
- dumpGlobalVars(): void;
52
- hooks: LayerStyleHooks<CustomRules>;
53
- }
54
- interface DefineLayerParentOptions {
55
- parent?: string;
56
- }
57
- interface DefineLayerBaseOptions<CustomRules extends CustomStyleRules | null = null> {
58
- hooks?: LayerStyleHooks<CustomRules>;
59
- }
60
- interface DefineLayerScopedOptions<CustomRules extends CustomStyleRules | null = null> extends DefineLayerBaseOptions<CustomRules> {
61
- /** Debug ID */
62
- debugId?: string;
63
- globalName?: never;
64
- }
65
- interface DefineLayerGlobalOptions<CustomRules extends CustomStyleRules | null = null> extends DefineLayerBaseOptions<CustomRules> {
66
- debugId?: never;
67
- /** Parent layer name */
68
- globalName: string;
69
- }
70
- type DefineLayerOptions<CustomRules extends CustomStyleRules | null = null> = DefineLayerScopedOptions<CustomRules> | DefineLayerGlobalOptions<CustomRules>;
71
- type DefineNestableLayerOptions<CustomRules extends CustomStyleRules | null = null> = DefineLayerOptions<CustomRules> & DefineLayerParentOptions;
72
- /**
73
- * Re-construct a {@link LayerStyle} from a name that was already resolved at
74
- * build time, WITHOUT re-running `layer()` / `globalLayer()`.
75
- *
76
- * @remarks
77
- * This is the runtime counterpart used by the function serializer (see
78
- * {@link defineLayerStyle}). Because the `layerName` is passed verbatim, the
79
- * re-constructed instance points at the exact layer that was emitted into CSS at
80
- * build time — even for scoped layers whose name is a non-deterministic hash that
81
- * could never be reproduced by calling `layer()` again.
82
- *
83
- * The re-constructed instance carries only deterministic state (`layerName` /
84
- * `parentLayerName`). It has no `hooks` and none of the additions made via
85
- * `extend()`; it is a reference handle to an already-built layer, not a fresh
86
- * style-defining entry point.
87
- *
88
- * @internal Not part of the public API; exported only so the serializer's
89
- * `importName` can resolve it at runtime.
90
- */
91
- declare function defineLayerStyleFromResolvedName<CustomRules extends CustomStyleRules | null = null>(layerName: string, parentLayerName: string | null): LayerStyle<CustomRules>;
92
- declare function defineLayerStyle<CustomRules extends CustomStyleRules | null = null>(globalNameOrOptions?: string | DefineNestableLayerOptions<CustomRules>): LayerStyle<CustomRules>;
93
- //#endregion
94
- export { DefineLayerBaseOptions, DefineLayerGlobalOptions, DefineLayerOptions, DefineLayerParentOptions, DefineLayerScopedOptions, DefineNestableLayerOptions, LayerStyle, defineLayerStyle, defineLayerStyleFromResolvedName };
95
- //# sourceMappingURL=css.d.mts.map
package/dist/css.mjs DELETED
@@ -1,159 +0,0 @@
1
- import { createThemeContract, globalLayer, globalStyle, layer, style } from "@vanilla-extract/css";
2
- import { addFunctionSerializer } from "@vanilla-extract/css/functionSerializer";
3
- //#region src/css/utils.ts
4
- function get(obj, path) {
5
- let result = obj;
6
- for (const key of path) {
7
- if (!(key in result)) throw new Error(`Path ${path.join(" -> ")} does not exist in object`);
8
- result = result[key];
9
- }
10
- return result;
11
- }
12
- function walkObject(obj, fn, path = []) {
13
- const clone = obj.constructor();
14
- for (const key in obj) {
15
- const value = obj[key];
16
- const currentPath = [...path, key];
17
- if (typeof value === "string" || typeof value === "number" || value == null) clone[key] = fn(value, currentPath);
18
- else if (typeof value === "object" && !Array.isArray(value)) clone[key] = walkObject(value, fn, currentPath);
19
- else console.warn(`Skipping invalid key "${currentPath.join(".")}". Should be a string, number, null or object. Received: "${Array.isArray(value) ? "Array" : typeof value}"`);
20
- }
21
- return clone;
22
- }
23
- function assignVars(varContract, tokens) {
24
- const varSetters = {};
25
- walkObject(tokens, (value, path) => {
26
- varSetters[get(varContract, path)] = String(value);
27
- });
28
- return varSetters;
29
- }
30
- //#endregion
31
- //#region src/css/theme.ts
32
- function createGlobalTheme$1(layerName, selector, arg2, arg3) {
33
- const shouldCreateVars = Boolean(!arg3);
34
- const themeVars = shouldCreateVars ? createThemeContract(arg2) : arg2;
35
- const tokens = shouldCreateVars ? arg2 : arg3;
36
- globalStyle(selector, { "@layer": { [layerName]: { vars: assignVars(themeVars, tokens) } } });
37
- if (shouldCreateVars) return themeVars;
38
- }
39
- //#endregion
40
- //#region src/css/layer.ts
41
- function isGlobalOptions(options) {
42
- return "globalName" in options;
43
- }
44
- function normalizeToObject(source) {
45
- if (!source) return {};
46
- if (typeof source === "string") return { globalName: source };
47
- return source;
48
- }
49
- /**
50
- * Assemble a {@link LayerStyle} object for an already-resolved `layerName`.
51
- *
52
- * @remarks
53
- * This contains the whole object-building logic shared by {@link defineLayerStyle}
54
- * (build-time, where `layerName` was just produced by `layer()`/`globalLayer()`)
55
- * and {@link defineLayerStyleFromResolvedName} (runtime re-construction, where
56
- * `layerName` is the deterministic value carried over from build time). It must
57
- * NOT call any `@vanilla-extract/css` side-effecting API (no `layer()` /
58
- * `globalLayer()`), so that re-construction never regenerates a hash-based name.
59
- *
60
- * @internal
61
- */
62
- function buildLayerStyle(layerName, parentLayerName, hooks) {
63
- const layerStyle = function layerStyle(rule, debugId) {
64
- const rules = Array.isArray(rule) ? rule : [rule];
65
- const layerAppliedRules = rules.map((_rule) => {
66
- if (typeof _rule === "string" || Array.isArray(_rule)) return _rule;
67
- return { "@layer": { [layerName]: _rule } };
68
- });
69
- if (hooks.anyStyle) for (const _rule of rules) {
70
- if (typeof _rule === "string" || Array.isArray(_rule)) continue;
71
- hooks.anyStyle(_rule);
72
- }
73
- hooks.style && hooks.style(rule, debugId);
74
- return style(layerAppliedRules, debugId);
75
- };
76
- layerStyle.layerName = layerName;
77
- layerStyle.parentLayerName = parentLayerName;
78
- layerStyle.style = layerStyle;
79
- layerStyle.hooks = hooks;
80
- layerStyle.global = function layerGlobalStyle(selector, rule) {
81
- hooks.anyStyle && hooks.anyStyle(rule);
82
- hooks.global && hooks.global(selector, rule);
83
- return globalStyle(selector, { "@layer": { [layerName]: rule } });
84
- };
85
- layerStyle.globalTheme = (...args) => createGlobalTheme$1(layerName, ...args);
86
- let _varQueues = [];
87
- layerStyle.pushGlobalVars = function pushGlobalVars(selector, vars) {
88
- let queue = _varQueues.find((q) => q[0] === selector);
89
- if (!queue) {
90
- queue = [selector, {}];
91
- _varQueues.push(queue);
92
- }
93
- Object.assign(queue[1], vars);
94
- };
95
- layerStyle.dumpGlobalVars = function dumpGlobalVars() {
96
- for (const [selector, vars] of _varQueues) layerStyle.global(selector, { vars });
97
- _varQueues = [];
98
- };
99
- layerStyle.defineNestedLayer = function defineNestedLayer(globalNameOrNestedOptions) {
100
- const _options = normalizeToObject(globalNameOrNestedOptions);
101
- const nestedHooks = _options.hooks;
102
- return defineLayerStyle({
103
- ..._options,
104
- hooks: {
105
- ...hooks,
106
- ...nestedHooks
107
- },
108
- parent: layerName
109
- });
110
- };
111
- return layerStyle;
112
- }
113
- /**
114
- * Re-construct a {@link LayerStyle} from a name that was already resolved at
115
- * build time, WITHOUT re-running `layer()` / `globalLayer()`.
116
- *
117
- * @remarks
118
- * This is the runtime counterpart used by the function serializer (see
119
- * {@link defineLayerStyle}). Because the `layerName` is passed verbatim, the
120
- * re-constructed instance points at the exact layer that was emitted into CSS at
121
- * build time — even for scoped layers whose name is a non-deterministic hash that
122
- * could never be reproduced by calling `layer()` again.
123
- *
124
- * The re-constructed instance carries only deterministic state (`layerName` /
125
- * `parentLayerName`). It has no `hooks` and none of the additions made via
126
- * `extend()`; it is a reference handle to an already-built layer, not a fresh
127
- * style-defining entry point.
128
- *
129
- * @internal Not part of the public API; exported only so the serializer's
130
- * `importName` can resolve it at runtime.
131
- */
132
- function defineLayerStyleFromResolvedName(layerName, parentLayerName) {
133
- return buildLayerStyle(layerName, parentLayerName, {});
134
- }
135
- function defineLayerStyle(globalNameOrOptions) {
136
- const options = normalizeToObject(globalNameOrOptions);
137
- const { parent, hooks = {} } = options;
138
- const isGlobal = isGlobalOptions(options);
139
- const layerName = isGlobal ? globalLayer({ parent }, options.globalName) : layer({ parent }, options.debugId);
140
- const layerStyle = buildLayerStyle(layerName, parent || null, hooks);
141
- if (isGlobal) addFunctionSerializer(layerStyle, {
142
- importPath: "@fastkit/plugboy-vanilla-extract-plugin/css",
143
- importName: "defineLayerStyle",
144
- args: [{
145
- globalName: options.globalName,
146
- ...parent ? { parent } : {}
147
- }]
148
- });
149
- else addFunctionSerializer(layerStyle, {
150
- importPath: "@fastkit/plugboy-vanilla-extract-plugin/css",
151
- importName: "defineLayerStyleFromResolvedName",
152
- args: [layerName, parent || null]
153
- });
154
- return layerStyle;
155
- }
156
- //#endregion
157
- export { defineLayerStyle, defineLayerStyleFromResolvedName };
158
-
159
- //# sourceMappingURL=css.mjs.map
package/dist/css.mjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"css.mjs","names":["createGlobalTheme","createGlobalTheme"],"sources":["../src/css/utils.ts","../src/css/theme.ts","../src/css/layer.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport { Contract, MapLeafNodes, CSSVarFunction } from './types';\n\ntype Primitive = string | number | null | undefined;\n\ntype Walkable = {\n [Key in string | number]: Primitive | Walkable;\n};\n\nexport function get(obj: any, path: Array<string>) {\n let result = obj;\n\n for (const key of path) {\n if (!(key in result)) {\n throw new Error(`Path ${path.join(' -> ')} does not exist in object`);\n }\n result = result[key];\n }\n\n return result;\n}\nexport function walkObject<T extends Walkable, MapTo>(\n obj: T,\n fn: (value: Primitive, path: Array<string>) => MapTo,\n path: Array<string> = [],\n): MapLeafNodes<T, MapTo> {\n const clone = obj.constructor();\n\n for (const key in obj) {\n const value = obj[key];\n const currentPath = [...path, key];\n\n if (\n typeof value === 'string' ||\n typeof value === 'number' ||\n value == null\n ) {\n clone[key] = fn(value as Primitive, currentPath);\n } else if (typeof value === 'object' && !Array.isArray(value)) {\n clone[key] = walkObject(value as Walkable, fn, currentPath);\n } else {\n console.warn(\n `Skipping invalid key \"${currentPath.join(\n '.',\n )}\". Should be a string, number, null or object. Received: \"${\n Array.isArray(value) ? 'Array' : typeof value\n }\"`,\n );\n }\n }\n\n return clone;\n}\n\nexport function assignVars<VarContract extends Contract>(\n varContract: VarContract,\n tokens: MapLeafNodes<VarContract, string>,\n): Record<CSSVarFunction, string> {\n const varSetters: { [cssVarName: string]: string } = {};\n // const { valid, diffString } = validateContract(varContract, tokens);\n\n // if (!valid) {\n // throw new Error(`Tokens don't match contract.\\n${diffString}`);\n // }\n\n walkObject(tokens, (value, path) => {\n varSetters[get(varContract, path)] = String(value);\n });\n\n return varSetters;\n}\n","import { createThemeContract, globalStyle } from '@vanilla-extract/css';\nimport { Tokens, ThemeVars, Contract, MapLeafNodes } from './types';\nimport { assignVars } from './utils';\n\nexport function createGlobalTheme<ThemeTokens extends Tokens>(\n layerName: string,\n selector: string,\n tokens: ThemeTokens,\n): ThemeVars<ThemeTokens>;\nexport function createGlobalTheme<ThemeContract extends Contract>(\n layerName: string,\n selector: string,\n themeContract: ThemeContract,\n tokens: MapLeafNodes<ThemeContract, string>,\n): void;\nexport function createGlobalTheme(\n layerName: string,\n selector: string,\n arg2: any,\n arg3?: any,\n): any {\n const shouldCreateVars = Boolean(!arg3);\n\n const themeVars = shouldCreateVars\n ? createThemeContract(arg2)\n : (arg2 as ThemeVars<any>);\n\n const tokens = shouldCreateVars ? arg2 : arg3;\n\n globalStyle(selector, {\n '@layer': {\n [layerName]: {\n vars: assignVars(themeVars, tokens),\n },\n },\n });\n\n // appendCss(\n // {\n // type: 'global',\n // selector: selector,\n // rule: { vars: assignVars(themeVars, tokens) },\n // },\n // getFileScope(),\n // );\n\n if (shouldCreateVars) {\n return themeVars;\n }\n}\n","import {\n style,\n layer,\n globalLayer,\n StyleRule,\n globalStyle,\n GlobalStyleRule,\n createGlobalTheme as _createGlobalTheme,\n} from '@vanilla-extract/css';\nimport { addFunctionSerializer } from '@vanilla-extract/css/functionSerializer';\nimport { createGlobalTheme } from './theme';\n\ntype CustomStyleRules = Record<string, any>;\n\ntype _LayerStyleRules = NonNullable<StyleRule['@layer']>[string];\n\ntype LayerStyleRules<CustomRules extends CustomStyleRules | null = null> =\n CustomRules extends null ? _LayerStyleRules : _LayerStyleRules & CustomRules;\n\ntype ClassNames = string | ClassNames[];\n\ntype ComplexLayerStyleRule<CustomRules extends CustomStyleRules | null = null> =\n | LayerStyleRules<CustomRules>\n | (LayerStyleRules<CustomRules> | ClassNames)[];\n\ntype _LayerGlobalStyleRules = NonNullable<GlobalStyleRule['@layer']>[string];\n\ntype LayerGlobalStyleRules<CustomRules extends CustomStyleRules | null = null> =\n CustomRules extends null\n ? _LayerGlobalStyleRules\n : _LayerGlobalStyleRules & CustomRules;\n\ntype AnyStyleRule<CustomRules extends CustomStyleRules | null = null> =\n | LayerStyleRules<CustomRules>\n | LayerGlobalStyleRules<CustomRules>;\n\ntype LayerStyleHooks<CustomRules extends CustomStyleRules | null = null> = {\n style?: (rule: ComplexLayerStyleRule<CustomRules>, debugId?: string) => void;\n global?: (selector: string, rule: LayerGlobalStyleRules<CustomRules>) => void;\n anyStyle?: (style: AnyStyleRule<CustomRules>) => void;\n};\n\nexport interface LayerStyle<\n CustomRules extends CustomStyleRules | null = null,\n> {\n layerName: string;\n parentLayerName: string | null;\n /**\n * @see {@link style}\n */\n (rule: ComplexLayerStyleRule<CustomRules>, debugId?: string): string;\n\n /**\n * @see {@link style}\n */\n style(rule: ComplexLayerStyleRule<CustomRules>, debugId?: string): string;\n\n /**\n * @see {@link globalStyle}\n */\n global(selector: string, rule: LayerGlobalStyleRules<CustomRules>): void;\n\n /**\n * @see {@link _createGlobalTheme}\n */\n globalTheme: typeof _createGlobalTheme;\n\n defineNestedLayer(\n globalNameOrNestedOptions?: string | DefineLayerOptions<CustomRules>,\n ): LayerStyle<CustomRules>;\n\n /**\n * Add global CSS variable with layer\n *\n * @remarks The vanilla-extract API is buggy when handling layered css variables.\n *\n * @param selector - selector\n * @param vars - variables\n */\n pushGlobalVars(selector: string, vars: Record<string, string>): void;\n\n /**\n * Output variables accumulated by `pushGlobalVars`.\n *\n * @remarks The vanilla-extract API is buggy when handling layered css variables.\n */\n dumpGlobalVars(): void;\n hooks: LayerStyleHooks<CustomRules>;\n}\n\nexport interface DefineLayerParentOptions {\n parent?: string;\n}\n\nexport interface DefineLayerBaseOptions<\n CustomRules extends CustomStyleRules | null = null,\n> {\n hooks?: LayerStyleHooks<CustomRules>;\n}\n\nexport interface DefineLayerScopedOptions<\n CustomRules extends CustomStyleRules | null = null,\n> extends DefineLayerBaseOptions<CustomRules> {\n /** Debug ID */\n debugId?: string;\n globalName?: never;\n}\n\nexport interface DefineLayerGlobalOptions<\n CustomRules extends CustomStyleRules | null = null,\n> extends DefineLayerBaseOptions<CustomRules> {\n debugId?: never;\n /** Parent layer name */\n globalName: string;\n}\n\nexport type DefineLayerOptions<\n CustomRules extends CustomStyleRules | null = null,\n> =\n | DefineLayerScopedOptions<CustomRules>\n | DefineLayerGlobalOptions<CustomRules>;\n\nexport type DefineNestableLayerOptions<\n CustomRules extends CustomStyleRules | null = null,\n> = DefineLayerOptions<CustomRules> & DefineLayerParentOptions;\n\nfunction isGlobalOptions(\n options: DefineLayerOptions<any>,\n): options is DefineLayerGlobalOptions {\n return 'globalName' in options;\n}\n\nfunction normalizeToObject<T extends DefineLayerOptions<any>>(\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\n/**\n * Assemble a {@link LayerStyle} object for an already-resolved `layerName`.\n *\n * @remarks\n * This contains the whole object-building logic shared by {@link defineLayerStyle}\n * (build-time, where `layerName` was just produced by `layer()`/`globalLayer()`)\n * and {@link defineLayerStyleFromResolvedName} (runtime re-construction, where\n * `layerName` is the deterministic value carried over from build time). It must\n * NOT call any `@vanilla-extract/css` side-effecting API (no `layer()` /\n * `globalLayer()`), so that re-construction never regenerates a hash-based name.\n *\n * @internal\n */\nfunction buildLayerStyle<CustomRules extends CustomStyleRules | null = null>(\n layerName: string,\n parentLayerName: string | null,\n hooks: LayerStyleHooks<CustomRules>,\n): LayerStyle<CustomRules> {\n const layerStyle = function layerStyle(rule, debugId) {\n const rules = Array.isArray(rule) ? rule : [rule];\n const layerAppliedRules = rules.map((_rule) => {\n if (typeof _rule === 'string' || Array.isArray(_rule)) return _rule;\n return {\n '@layer': {\n [layerName]: _rule,\n },\n };\n });\n if (hooks.anyStyle) {\n for (const _rule of rules) {\n if (typeof _rule === 'string' || Array.isArray(_rule)) continue;\n hooks.anyStyle(_rule);\n }\n }\n hooks.style && hooks.style(rule, debugId);\n return style(layerAppliedRules, debugId);\n } as LayerStyle<CustomRules>;\n\n layerStyle.layerName = layerName;\n layerStyle.parentLayerName = parentLayerName;\n layerStyle.style = layerStyle;\n layerStyle.hooks = hooks;\n\n layerStyle.global = function layerGlobalStyle(\n selector: string,\n rule: LayerGlobalStyleRules<CustomRules>,\n ) {\n hooks.anyStyle && hooks.anyStyle(rule);\n hooks.global && hooks.global(selector, rule);\n\n return globalStyle(selector, {\n '@layer': {\n [layerName]: rule,\n },\n });\n };\n\n layerStyle.globalTheme = (...args: any) =>\n (createGlobalTheme as any)(layerName, ...args);\n\n let _varQueues: [string, Record<string, string>][] = [];\n\n layerStyle.pushGlobalVars = function pushGlobalVars(\n selector: string,\n vars: Record<string, string>,\n ) {\n let queue = _varQueues.find((q) => q[0] === selector);\n if (!queue) {\n queue = [selector, {}];\n _varQueues.push(queue);\n }\n Object.assign(queue[1], vars);\n };\n\n layerStyle.dumpGlobalVars = function dumpGlobalVars() {\n for (const [selector, vars] of _varQueues) {\n layerStyle.global(selector, {\n vars,\n } as any);\n }\n _varQueues = [];\n };\n\n layerStyle.defineNestedLayer = function defineNestedLayer(\n globalNameOrNestedOptions?: string | DefineLayerOptions<CustomRules>,\n ) {\n const _options = normalizeToObject(globalNameOrNestedOptions);\n const nestedHooks = _options.hooks;\n\n return defineLayerStyle({\n ..._options,\n hooks: {\n ...hooks,\n ...nestedHooks,\n },\n parent: layerName,\n });\n };\n\n return layerStyle;\n}\n\n/**\n * Re-construct a {@link LayerStyle} from a name that was already resolved at\n * build time, WITHOUT re-running `layer()` / `globalLayer()`.\n *\n * @remarks\n * This is the runtime counterpart used by the function serializer (see\n * {@link defineLayerStyle}). Because the `layerName` is passed verbatim, the\n * re-constructed instance points at the exact layer that was emitted into CSS at\n * build time — even for scoped layers whose name is a non-deterministic hash that\n * could never be reproduced by calling `layer()` again.\n *\n * The re-constructed instance carries only deterministic state (`layerName` /\n * `parentLayerName`). It has no `hooks` and none of the additions made via\n * `extend()`; it is a reference handle to an already-built layer, not a fresh\n * style-defining entry point.\n *\n * @internal Not part of the public API; exported only so the serializer's\n * `importName` can resolve it at runtime.\n */\nexport function defineLayerStyleFromResolvedName<\n CustomRules extends CustomStyleRules | null = null,\n>(layerName: string, parentLayerName: string | null): LayerStyle<CustomRules> {\n return buildLayerStyle<CustomRules>(layerName, parentLayerName, {});\n}\n\nexport function defineLayerStyle<\n CustomRules extends CustomStyleRules | null = null,\n>(\n globalNameOrOptions?: string | DefineNestableLayerOptions<CustomRules>,\n): LayerStyle<CustomRules> {\n const options = normalizeToObject(globalNameOrOptions);\n const { parent, hooks = {} } = options;\n\n const isGlobal = isGlobalOptions(options);\n\n const layerName = isGlobal\n ? globalLayer({ parent }, options.globalName)\n : layer({ parent }, options.debugId);\n\n const layerStyle = buildLayerStyle<CustomRules>(\n layerName,\n parent || null,\n hooks,\n );\n\n // Attach vanilla-extract's official function serializer so that a `LayerStyle`\n // can survive being exported from a `.css.ts` module. The `.css.ts` build is\n // delegated to `@vanilla-extract/rollup-plugin`, whose `serializeVanillaModule`\n // rejects plain function exports. `addFunctionSerializer` registers a\n // descriptor (`__function_serializer__`) so the function is emitted as\n // re-construction code instead of throwing.\n //\n // Two re-construction paths, chosen so each reproduces the SAME `layerName`:\n //\n // - global: re-run `defineLayerStyle({ globalName, parent })`. `globalLayer()`\n // derives a deterministic name from `globalName`/`parent`, so re-running it at\n // runtime yields the identical layer. Kept verbatim from the original\n // implementation, so global behavior (including the runtime `globalLayer()`\n // call) is unchanged.\n // - scoped: call `defineLayerStyleFromResolvedName(layerName, parentLayerName)`,\n // which does NOT re-run `layer()`. A scoped layer's name is a hash that cannot\n // be reproduced by calling `layer()` again, so the build-time name is carried\n // over as a plain string instead.\n //\n // What re-construction restores (BOTH paths): only the deterministic state —\n // `layerName` / `parentLayerName`. `hooks` (and anything added via `extend()`:\n // extra `anyStyle`, custom methods, etc.) are intentionally NOT serialized,\n // because they hold functions and the serializer args must be plain serializable\n // values. This does not change build behavior: `hooks` run at `.css.ts`\n // evaluation time when `.style()` / `.global()` are called, and the CSS they emit\n // is already baked in before serialization (which only reads\n // `__function_serializer__` and writes re-construction code). The only caveat is\n // purely runtime: an instance re-constructed in a consumer is a *reference\n // handle* to the already-built layer — calling its `.style()` / `.global()` /\n // extended methods there runs without the original hooks. If a runtime-hooked\n // layer is ever needed, keep that instance build-time only, or add a separately\n // serializable descriptor for it.\n if (isGlobal) {\n addFunctionSerializer(layerStyle, {\n importPath: '@fastkit/plugboy-vanilla-extract-plugin/css',\n importName: 'defineLayerStyle',\n args: [\n {\n globalName: options.globalName,\n ...(parent ? { parent } : {}),\n },\n ],\n });\n } else {\n addFunctionSerializer(layerStyle, {\n importPath: '@fastkit/plugboy-vanilla-extract-plugin/css',\n importName: 'defineLayerStyleFromResolvedName',\n args: [layerName, parent || null],\n });\n }\n\n return layerStyle;\n}\n"],"mappings":";;;AASA,SAAgB,IAAI,KAAU,MAAqB;CACjD,IAAI,SAAS;CAEb,KAAK,MAAM,OAAO,MAAM;EACtB,IAAI,EAAE,OAAO,SACX,MAAM,IAAI,MAAM,QAAQ,KAAK,KAAK,MAAM,EAAE,0BAA0B;EAEtE,SAAS,OAAO;CAClB;CAEA,OAAO;AACT;AACA,SAAgB,WACd,KACA,IACA,OAAsB,CAAC,GACC;CACxB,MAAM,QAAQ,IAAI,YAAY;CAE9B,KAAK,MAAM,OAAO,KAAK;EACrB,MAAM,QAAQ,IAAI;EAClB,MAAM,cAAc,CAAC,GAAG,MAAM,GAAG;EAEjC,IACE,OAAO,UAAU,YACjB,OAAO,UAAU,YACjB,SAAS,MAET,MAAM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