elit 2.0.1 → 3.0.1
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 +275 -128
- package/dist/build.d.mts +10 -1
- package/dist/build.d.ts +10 -1
- package/dist/build.js +670 -1
- package/dist/build.mjs +641 -1
- package/dist/chokidar.d.mts +134 -0
- package/dist/chokidar.d.ts +134 -0
- package/dist/chokidar.js +240 -0
- package/dist/chokidar.mjs +221 -0
- package/dist/cli.js +2792 -495
- package/dist/dom.d.mts +10 -3
- package/dist/dom.d.ts +10 -3
- package/dist/dom.js +676 -1
- package/dist/dom.mjs +647 -1
- package/dist/el.d.mts +16 -36
- package/dist/el.d.ts +16 -36
- package/dist/el.js +789 -1
- package/dist/el.mjs +583 -1
- package/dist/fs.d.mts +255 -0
- package/dist/fs.d.ts +255 -0
- package/dist/fs.js +513 -0
- package/dist/fs.mjs +469 -0
- package/dist/hmr.js +112 -1
- package/dist/hmr.mjs +91 -1
- package/dist/http.d.mts +163 -0
- package/dist/http.d.ts +163 -0
- package/dist/http.js +632 -0
- package/dist/http.mjs +605 -0
- package/dist/https.d.mts +108 -0
- package/dist/https.d.ts +108 -0
- package/dist/https.js +907 -0
- package/dist/https.mjs +901 -0
- package/dist/index.d.mts +613 -33
- package/dist/index.d.ts +613 -33
- package/dist/index.js +2589 -1
- package/dist/index.mjs +2312 -1
- package/dist/mime-types.d.mts +48 -0
- package/dist/mime-types.d.ts +48 -0
- package/dist/mime-types.js +197 -0
- package/dist/mime-types.mjs +166 -0
- package/dist/path.d.mts +163 -0
- package/dist/path.d.ts +163 -0
- package/dist/path.js +350 -0
- package/dist/path.mjs +310 -0
- package/dist/router.d.mts +3 -1
- package/dist/router.d.ts +3 -1
- package/dist/router.js +830 -1
- package/dist/router.mjs +801 -1
- package/dist/runtime.d.mts +97 -0
- package/dist/runtime.d.ts +97 -0
- package/dist/runtime.js +43 -0
- package/dist/runtime.mjs +15 -0
- package/dist/server.d.mts +5 -1
- package/dist/server.d.ts +5 -1
- package/dist/server.js +3267 -1
- package/dist/server.mjs +3241 -1
- package/dist/state.d.mts +3 -1
- package/dist/state.d.ts +3 -1
- package/dist/state.js +1036 -1
- package/dist/state.mjs +992 -1
- package/dist/style.d.mts +47 -1
- package/dist/style.d.ts +47 -1
- package/dist/style.js +551 -1
- package/dist/style.mjs +483 -1
- package/dist/{types-DOAdFFJB.d.ts → types-C0nGi6MX.d.mts} +29 -13
- package/dist/{types-DOAdFFJB.d.mts → types-Du6kfwTm.d.ts} +29 -13
- package/dist/types.d.mts +452 -3
- package/dist/types.d.ts +452 -3
- package/dist/types.js +18 -1
- package/dist/ws.d.mts +195 -0
- package/dist/ws.d.ts +195 -0
- package/dist/ws.js +380 -0
- package/dist/ws.mjs +358 -0
- package/dist/wss.d.mts +108 -0
- package/dist/wss.d.ts +108 -0
- package/dist/wss.js +1306 -0
- package/dist/wss.mjs +1300 -0
- package/package.json +53 -6
- package/dist/client.d.mts +0 -9
- package/dist/client.d.ts +0 -9
- package/dist/client.js +0 -1
- package/dist/client.mjs +0 -1
package/dist/style.d.mts
CHANGED
|
@@ -97,6 +97,9 @@ declare class CreateStyle {
|
|
|
97
97
|
add(rules: Record<string, Record<string, string | number>>): CSSRule[];
|
|
98
98
|
important(value: string | number): string;
|
|
99
99
|
private toKebabCase;
|
|
100
|
+
private createAndAddRule;
|
|
101
|
+
private rulesToCSSRules;
|
|
102
|
+
private renderRulesWithIndent;
|
|
100
103
|
private stylesToString;
|
|
101
104
|
private renderRule;
|
|
102
105
|
private renderMediaRule;
|
|
@@ -109,5 +112,48 @@ declare class CreateStyle {
|
|
|
109
112
|
inject(styleId?: string): HTMLStyleElement;
|
|
110
113
|
clear(): void;
|
|
111
114
|
}
|
|
115
|
+
declare const styles: CreateStyle;
|
|
116
|
+
declare const addVar: (name: string, value: string) => CSSVariable;
|
|
117
|
+
declare const getVar: (variable: CSSVariable | string, fallback?: string) => string;
|
|
118
|
+
declare const addTag: (tag: string, styles: Record<string, string | number>) => CSSRule;
|
|
119
|
+
declare const addClass: (name: string, styles: Record<string, string | number>) => CSSRule;
|
|
120
|
+
declare const addId: (name: string, styles: Record<string, string | number>) => CSSRule;
|
|
121
|
+
declare const addPseudoClass: (pseudo: string, styles: Record<string, string | number>, baseSelector?: string) => CSSRule;
|
|
122
|
+
declare const addPseudoElement: (pseudo: string, styles: Record<string, string | number>, baseSelector?: string) => CSSRule;
|
|
123
|
+
declare const addAttribute: (attr: string, styles: Record<string, string | number>, baseSelector?: string) => CSSRule;
|
|
124
|
+
declare const attrEquals: (attr: string, value: string, styles: Record<string, string | number>, baseSelector?: string) => CSSRule;
|
|
125
|
+
declare const attrContainsWord: (attr: string, value: string, styles: Record<string, string | number>, baseSelector?: string) => CSSRule;
|
|
126
|
+
declare const attrStartsWith: (attr: string, value: string, styles: Record<string, string | number>, baseSelector?: string) => CSSRule;
|
|
127
|
+
declare const attrEndsWith: (attr: string, value: string, styles: Record<string, string | number>, baseSelector?: string) => CSSRule;
|
|
128
|
+
declare const attrContains: (attr: string, value: string, styles: Record<string, string | number>, baseSelector?: string) => CSSRule;
|
|
129
|
+
declare const descendant: (ancestor: string, descendant: string, styles: Record<string, string | number>) => CSSRule;
|
|
130
|
+
declare const childStyle: (parent: string, childSel: string, styles: Record<string, string | number>) => CSSRule;
|
|
131
|
+
declare const adjacentSibling: (element: string, sibling: string, styles: Record<string, string | number>) => CSSRule;
|
|
132
|
+
declare const generalSibling: (element: string, sibling: string, styles: Record<string, string | number>) => CSSRule;
|
|
133
|
+
declare const multipleStyle: (selectors: string[], styles: Record<string, string | number>) => CSSRule;
|
|
134
|
+
declare const addName: (name: string, styles: Record<string, string | number>) => CSSRule;
|
|
135
|
+
declare const nesting: (parentRule: CSSRule, ...childRules: CSSRule[]) => CSSRule;
|
|
136
|
+
declare const keyframe: (name: string, steps: Record<string | number, Record<string, string | number>>) => Keyframes;
|
|
137
|
+
declare const keyframeFromTo: (name: string, from: Record<string, string | number>, to: Record<string, string | number>) => Keyframes;
|
|
138
|
+
declare const fontFace: (options: FontFace) => FontFace;
|
|
139
|
+
declare const importStyle: (url: string, mediaQuery?: string) => string;
|
|
140
|
+
declare const mediaStyle: (type: string, condition: string, rules: Record<string, Record<string, string | number>>) => MediaRule;
|
|
141
|
+
declare const mediaScreen: (condition: string, rules: Record<string, Record<string, string | number>>) => MediaRule;
|
|
142
|
+
declare const mediaPrint: (rules: Record<string, Record<string, string | number>>) => MediaRule;
|
|
143
|
+
declare const mediaMinWidth: (minWidth: string, rules: Record<string, Record<string, string | number>>) => MediaRule;
|
|
144
|
+
declare const mediaMaxWidth: (maxWidth: string, rules: Record<string, Record<string, string | number>>) => MediaRule;
|
|
145
|
+
declare const mediaDark: (rules: Record<string, Record<string, string | number>>) => MediaRule;
|
|
146
|
+
declare const mediaLight: (rules: Record<string, Record<string, string | number>>) => MediaRule;
|
|
147
|
+
declare const mediaReducedMotion: (rules: Record<string, Record<string, string | number>>) => MediaRule;
|
|
148
|
+
declare const container: (condition: string, rules: Record<string, Record<string, string | number>>, name?: string) => ContainerRule;
|
|
149
|
+
declare const addContainer: (name: string, styles: Record<string, string | number>) => CSSRule;
|
|
150
|
+
declare const supportsStyle: (condition: string, rules: Record<string, Record<string, string | number>>) => SupportsRule;
|
|
151
|
+
declare const layerOrder: (...layers: string[]) => void;
|
|
152
|
+
declare const layer: (name: string, rules: Record<string, Record<string, string | number>>) => LayerRule;
|
|
153
|
+
declare const addStyle: (rules: Record<string, Record<string, string | number>>) => CSSRule[];
|
|
154
|
+
declare const important: (value: string | number) => string;
|
|
155
|
+
declare const renderStyle: (...additionalRules: (CSSRule | CSSRule[] | MediaRule | Keyframes | ContainerRule | SupportsRule | LayerRule | undefined | null)[]) => string;
|
|
156
|
+
declare const injectStyle: (styleId?: string) => HTMLStyleElement;
|
|
157
|
+
declare const clearStyle: () => void;
|
|
112
158
|
|
|
113
|
-
export { type CSSRule, type CSSVariable, type ContainerRule, CreateStyle, type FontFace, type KeyframeStep, type Keyframes, type LayerRule, type MediaRule, type SupportsRule };
|
|
159
|
+
export { type CSSRule, type CSSVariable, type ContainerRule, CreateStyle, type FontFace, type KeyframeStep, type Keyframes, type LayerRule, type MediaRule, type SupportsRule, addAttribute, addClass, addContainer, addId, addName, addPseudoClass, addPseudoElement, addStyle, addTag, addVar, adjacentSibling, attrContains, attrContainsWord, attrEndsWith, attrEquals, attrStartsWith, childStyle, clearStyle, container, styles as default, descendant, fontFace, generalSibling, getVar, importStyle, important, injectStyle, keyframe, keyframeFromTo, layer, layerOrder, mediaDark, mediaLight, mediaMaxWidth, mediaMinWidth, mediaPrint, mediaReducedMotion, mediaScreen, mediaStyle, multipleStyle, nesting, renderStyle, styles, supportsStyle };
|
package/dist/style.d.ts
CHANGED
|
@@ -97,6 +97,9 @@ declare class CreateStyle {
|
|
|
97
97
|
add(rules: Record<string, Record<string, string | number>>): CSSRule[];
|
|
98
98
|
important(value: string | number): string;
|
|
99
99
|
private toKebabCase;
|
|
100
|
+
private createAndAddRule;
|
|
101
|
+
private rulesToCSSRules;
|
|
102
|
+
private renderRulesWithIndent;
|
|
100
103
|
private stylesToString;
|
|
101
104
|
private renderRule;
|
|
102
105
|
private renderMediaRule;
|
|
@@ -109,5 +112,48 @@ declare class CreateStyle {
|
|
|
109
112
|
inject(styleId?: string): HTMLStyleElement;
|
|
110
113
|
clear(): void;
|
|
111
114
|
}
|
|
115
|
+
declare const styles: CreateStyle;
|
|
116
|
+
declare const addVar: (name: string, value: string) => CSSVariable;
|
|
117
|
+
declare const getVar: (variable: CSSVariable | string, fallback?: string) => string;
|
|
118
|
+
declare const addTag: (tag: string, styles: Record<string, string | number>) => CSSRule;
|
|
119
|
+
declare const addClass: (name: string, styles: Record<string, string | number>) => CSSRule;
|
|
120
|
+
declare const addId: (name: string, styles: Record<string, string | number>) => CSSRule;
|
|
121
|
+
declare const addPseudoClass: (pseudo: string, styles: Record<string, string | number>, baseSelector?: string) => CSSRule;
|
|
122
|
+
declare const addPseudoElement: (pseudo: string, styles: Record<string, string | number>, baseSelector?: string) => CSSRule;
|
|
123
|
+
declare const addAttribute: (attr: string, styles: Record<string, string | number>, baseSelector?: string) => CSSRule;
|
|
124
|
+
declare const attrEquals: (attr: string, value: string, styles: Record<string, string | number>, baseSelector?: string) => CSSRule;
|
|
125
|
+
declare const attrContainsWord: (attr: string, value: string, styles: Record<string, string | number>, baseSelector?: string) => CSSRule;
|
|
126
|
+
declare const attrStartsWith: (attr: string, value: string, styles: Record<string, string | number>, baseSelector?: string) => CSSRule;
|
|
127
|
+
declare const attrEndsWith: (attr: string, value: string, styles: Record<string, string | number>, baseSelector?: string) => CSSRule;
|
|
128
|
+
declare const attrContains: (attr: string, value: string, styles: Record<string, string | number>, baseSelector?: string) => CSSRule;
|
|
129
|
+
declare const descendant: (ancestor: string, descendant: string, styles: Record<string, string | number>) => CSSRule;
|
|
130
|
+
declare const childStyle: (parent: string, childSel: string, styles: Record<string, string | number>) => CSSRule;
|
|
131
|
+
declare const adjacentSibling: (element: string, sibling: string, styles: Record<string, string | number>) => CSSRule;
|
|
132
|
+
declare const generalSibling: (element: string, sibling: string, styles: Record<string, string | number>) => CSSRule;
|
|
133
|
+
declare const multipleStyle: (selectors: string[], styles: Record<string, string | number>) => CSSRule;
|
|
134
|
+
declare const addName: (name: string, styles: Record<string, string | number>) => CSSRule;
|
|
135
|
+
declare const nesting: (parentRule: CSSRule, ...childRules: CSSRule[]) => CSSRule;
|
|
136
|
+
declare const keyframe: (name: string, steps: Record<string | number, Record<string, string | number>>) => Keyframes;
|
|
137
|
+
declare const keyframeFromTo: (name: string, from: Record<string, string | number>, to: Record<string, string | number>) => Keyframes;
|
|
138
|
+
declare const fontFace: (options: FontFace) => FontFace;
|
|
139
|
+
declare const importStyle: (url: string, mediaQuery?: string) => string;
|
|
140
|
+
declare const mediaStyle: (type: string, condition: string, rules: Record<string, Record<string, string | number>>) => MediaRule;
|
|
141
|
+
declare const mediaScreen: (condition: string, rules: Record<string, Record<string, string | number>>) => MediaRule;
|
|
142
|
+
declare const mediaPrint: (rules: Record<string, Record<string, string | number>>) => MediaRule;
|
|
143
|
+
declare const mediaMinWidth: (minWidth: string, rules: Record<string, Record<string, string | number>>) => MediaRule;
|
|
144
|
+
declare const mediaMaxWidth: (maxWidth: string, rules: Record<string, Record<string, string | number>>) => MediaRule;
|
|
145
|
+
declare const mediaDark: (rules: Record<string, Record<string, string | number>>) => MediaRule;
|
|
146
|
+
declare const mediaLight: (rules: Record<string, Record<string, string | number>>) => MediaRule;
|
|
147
|
+
declare const mediaReducedMotion: (rules: Record<string, Record<string, string | number>>) => MediaRule;
|
|
148
|
+
declare const container: (condition: string, rules: Record<string, Record<string, string | number>>, name?: string) => ContainerRule;
|
|
149
|
+
declare const addContainer: (name: string, styles: Record<string, string | number>) => CSSRule;
|
|
150
|
+
declare const supportsStyle: (condition: string, rules: Record<string, Record<string, string | number>>) => SupportsRule;
|
|
151
|
+
declare const layerOrder: (...layers: string[]) => void;
|
|
152
|
+
declare const layer: (name: string, rules: Record<string, Record<string, string | number>>) => LayerRule;
|
|
153
|
+
declare const addStyle: (rules: Record<string, Record<string, string | number>>) => CSSRule[];
|
|
154
|
+
declare const important: (value: string | number) => string;
|
|
155
|
+
declare const renderStyle: (...additionalRules: (CSSRule | CSSRule[] | MediaRule | Keyframes | ContainerRule | SupportsRule | LayerRule | undefined | null)[]) => string;
|
|
156
|
+
declare const injectStyle: (styleId?: string) => HTMLStyleElement;
|
|
157
|
+
declare const clearStyle: () => void;
|
|
112
158
|
|
|
113
|
-
export { type CSSRule, type CSSVariable, type ContainerRule, CreateStyle, type FontFace, type KeyframeStep, type Keyframes, type LayerRule, type MediaRule, type SupportsRule };
|
|
159
|
+
export { type CSSRule, type CSSVariable, type ContainerRule, CreateStyle, type FontFace, type KeyframeStep, type Keyframes, type LayerRule, type MediaRule, type SupportsRule, addAttribute, addClass, addContainer, addId, addName, addPseudoClass, addPseudoElement, addStyle, addTag, addVar, adjacentSibling, attrContains, attrContainsWord, attrEndsWith, attrEquals, attrStartsWith, childStyle, clearStyle, container, styles as default, descendant, fontFace, generalSibling, getVar, importStyle, important, injectStyle, keyframe, keyframeFromTo, layer, layerOrder, mediaDark, mediaLight, mediaMaxWidth, mediaMinWidth, mediaPrint, mediaReducedMotion, mediaScreen, mediaStyle, multipleStyle, nesting, renderStyle, styles, supportsStyle };
|
package/dist/style.js
CHANGED
|
@@ -1 +1,551 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/style.ts
|
|
21
|
+
var style_exports = {};
|
|
22
|
+
__export(style_exports, {
|
|
23
|
+
CreateStyle: () => CreateStyle,
|
|
24
|
+
addAttribute: () => addAttribute,
|
|
25
|
+
addClass: () => addClass,
|
|
26
|
+
addContainer: () => addContainer,
|
|
27
|
+
addId: () => addId,
|
|
28
|
+
addName: () => addName,
|
|
29
|
+
addPseudoClass: () => addPseudoClass,
|
|
30
|
+
addPseudoElement: () => addPseudoElement,
|
|
31
|
+
addStyle: () => addStyle,
|
|
32
|
+
addTag: () => addTag,
|
|
33
|
+
addVar: () => addVar,
|
|
34
|
+
adjacentSibling: () => adjacentSibling,
|
|
35
|
+
attrContains: () => attrContains,
|
|
36
|
+
attrContainsWord: () => attrContainsWord,
|
|
37
|
+
attrEndsWith: () => attrEndsWith,
|
|
38
|
+
attrEquals: () => attrEquals,
|
|
39
|
+
attrStartsWith: () => attrStartsWith,
|
|
40
|
+
childStyle: () => childStyle,
|
|
41
|
+
clearStyle: () => clearStyle,
|
|
42
|
+
container: () => container,
|
|
43
|
+
default: () => style_default,
|
|
44
|
+
descendant: () => descendant,
|
|
45
|
+
fontFace: () => fontFace,
|
|
46
|
+
generalSibling: () => generalSibling,
|
|
47
|
+
getVar: () => getVar,
|
|
48
|
+
importStyle: () => importStyle,
|
|
49
|
+
important: () => important,
|
|
50
|
+
injectStyle: () => injectStyle,
|
|
51
|
+
keyframe: () => keyframe,
|
|
52
|
+
keyframeFromTo: () => keyframeFromTo,
|
|
53
|
+
layer: () => layer,
|
|
54
|
+
layerOrder: () => layerOrder,
|
|
55
|
+
mediaDark: () => mediaDark,
|
|
56
|
+
mediaLight: () => mediaLight,
|
|
57
|
+
mediaMaxWidth: () => mediaMaxWidth,
|
|
58
|
+
mediaMinWidth: () => mediaMinWidth,
|
|
59
|
+
mediaPrint: () => mediaPrint,
|
|
60
|
+
mediaReducedMotion: () => mediaReducedMotion,
|
|
61
|
+
mediaScreen: () => mediaScreen,
|
|
62
|
+
mediaStyle: () => mediaStyle,
|
|
63
|
+
multipleStyle: () => multipleStyle,
|
|
64
|
+
nesting: () => nesting,
|
|
65
|
+
renderStyle: () => renderStyle,
|
|
66
|
+
styles: () => styles,
|
|
67
|
+
supportsStyle: () => supportsStyle
|
|
68
|
+
});
|
|
69
|
+
module.exports = __toCommonJS(style_exports);
|
|
70
|
+
var CreateStyle = class {
|
|
71
|
+
constructor() {
|
|
72
|
+
this.variables = [];
|
|
73
|
+
this.rules = [];
|
|
74
|
+
this.mediaRules = [];
|
|
75
|
+
this.keyframes = [];
|
|
76
|
+
this.fontFaces = [];
|
|
77
|
+
this.imports = [];
|
|
78
|
+
this.containerRules = [];
|
|
79
|
+
this.supportsRules = [];
|
|
80
|
+
this.layerRules = [];
|
|
81
|
+
this._layerOrder = [];
|
|
82
|
+
}
|
|
83
|
+
// CSS Variables
|
|
84
|
+
addVar(name, value) {
|
|
85
|
+
const cssVar = {
|
|
86
|
+
name: name.startsWith("--") ? name : `--${name}`,
|
|
87
|
+
value,
|
|
88
|
+
toString() {
|
|
89
|
+
return `var(${this.name})`;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
this.variables.push(cssVar);
|
|
93
|
+
return cssVar;
|
|
94
|
+
}
|
|
95
|
+
var(variable, fallback) {
|
|
96
|
+
const varName = typeof variable === "string" ? variable.startsWith("--") ? variable : `--${variable}` : variable.name;
|
|
97
|
+
return fallback ? `var(${varName}, ${fallback})` : `var(${varName})`;
|
|
98
|
+
}
|
|
99
|
+
// Basic Selectors
|
|
100
|
+
addTag(tag, styles2) {
|
|
101
|
+
const rule = { selector: tag, styles: styles2, type: "tag" };
|
|
102
|
+
this.rules.push(rule);
|
|
103
|
+
return rule;
|
|
104
|
+
}
|
|
105
|
+
addClass(name, styles2) {
|
|
106
|
+
const selector = name.startsWith(".") ? name : `.${name}`;
|
|
107
|
+
const rule = { selector, styles: styles2, type: "class" };
|
|
108
|
+
this.rules.push(rule);
|
|
109
|
+
return rule;
|
|
110
|
+
}
|
|
111
|
+
addId(name, styles2) {
|
|
112
|
+
const selector = name.startsWith("#") ? name : `#${name}`;
|
|
113
|
+
const rule = { selector, styles: styles2, type: "id" };
|
|
114
|
+
this.rules.push(rule);
|
|
115
|
+
return rule;
|
|
116
|
+
}
|
|
117
|
+
// Pseudo Selectors
|
|
118
|
+
addPseudoClass(pseudo, styles2, baseSelector) {
|
|
119
|
+
const pseudoClass = pseudo.startsWith(":") ? pseudo : `:${pseudo}`;
|
|
120
|
+
const selector = baseSelector ? `${baseSelector}${pseudoClass}` : pseudoClass;
|
|
121
|
+
const rule = { selector, styles: styles2, type: "pseudo-class" };
|
|
122
|
+
this.rules.push(rule);
|
|
123
|
+
return rule;
|
|
124
|
+
}
|
|
125
|
+
addPseudoElement(pseudo, styles2, baseSelector) {
|
|
126
|
+
const pseudoElement = pseudo.startsWith("::") ? pseudo : `::${pseudo}`;
|
|
127
|
+
const selector = baseSelector ? `${baseSelector}${pseudoElement}` : pseudoElement;
|
|
128
|
+
const rule = { selector, styles: styles2, type: "pseudo-element" };
|
|
129
|
+
this.rules.push(rule);
|
|
130
|
+
return rule;
|
|
131
|
+
}
|
|
132
|
+
// Attribute Selectors
|
|
133
|
+
addAttribute(attr, styles2, baseSelector) {
|
|
134
|
+
const attrSelector = attr.startsWith("[") ? attr : `[${attr}]`;
|
|
135
|
+
const selector = baseSelector ? `${baseSelector}${attrSelector}` : attrSelector;
|
|
136
|
+
const rule = { selector, styles: styles2, type: "attribute" };
|
|
137
|
+
this.rules.push(rule);
|
|
138
|
+
return rule;
|
|
139
|
+
}
|
|
140
|
+
attrEquals(attr, value, styles2, baseSelector) {
|
|
141
|
+
return this.addAttribute(`${attr}="${value}"`, styles2, baseSelector);
|
|
142
|
+
}
|
|
143
|
+
attrContainsWord(attr, value, styles2, baseSelector) {
|
|
144
|
+
return this.addAttribute(`${attr}~="${value}"`, styles2, baseSelector);
|
|
145
|
+
}
|
|
146
|
+
attrStartsWith(attr, value, styles2, baseSelector) {
|
|
147
|
+
return this.addAttribute(`${attr}^="${value}"`, styles2, baseSelector);
|
|
148
|
+
}
|
|
149
|
+
attrEndsWith(attr, value, styles2, baseSelector) {
|
|
150
|
+
return this.addAttribute(`${attr}$="${value}"`, styles2, baseSelector);
|
|
151
|
+
}
|
|
152
|
+
attrContains(attr, value, styles2, baseSelector) {
|
|
153
|
+
return this.addAttribute(`${attr}*="${value}"`, styles2, baseSelector);
|
|
154
|
+
}
|
|
155
|
+
// Combinator Selectors
|
|
156
|
+
descendant(ancestor, descendant2, styles2) {
|
|
157
|
+
return this.createAndAddRule(`${ancestor} ${descendant2}`, styles2);
|
|
158
|
+
}
|
|
159
|
+
child(parent, childSel, styles2) {
|
|
160
|
+
return this.createAndAddRule(`${parent} > ${childSel}`, styles2);
|
|
161
|
+
}
|
|
162
|
+
adjacentSibling(element, sibling, styles2) {
|
|
163
|
+
return this.createAndAddRule(`${element} + ${sibling}`, styles2);
|
|
164
|
+
}
|
|
165
|
+
generalSibling(element, sibling, styles2) {
|
|
166
|
+
return this.createAndAddRule(`${element} ~ ${sibling}`, styles2);
|
|
167
|
+
}
|
|
168
|
+
multiple(selectors, styles2) {
|
|
169
|
+
return this.createAndAddRule(selectors.join(", "), styles2);
|
|
170
|
+
}
|
|
171
|
+
// Nesting (BEM-style)
|
|
172
|
+
addName(name, styles2) {
|
|
173
|
+
const selector = name.startsWith("--") ? `&${name}` : `&--${name}`;
|
|
174
|
+
const rule = { selector, styles: styles2, type: "name" };
|
|
175
|
+
return rule;
|
|
176
|
+
}
|
|
177
|
+
nesting(parentRule, ...childRules) {
|
|
178
|
+
parentRule.nested = childRules;
|
|
179
|
+
return parentRule;
|
|
180
|
+
}
|
|
181
|
+
// @keyframes - Animations
|
|
182
|
+
keyframe(name, steps) {
|
|
183
|
+
const keyframeSteps = Object.entries(steps).map(([step, styles2]) => ({
|
|
184
|
+
step: step === "from" ? "from" : step === "to" ? "to" : `${step}%`,
|
|
185
|
+
styles: styles2
|
|
186
|
+
}));
|
|
187
|
+
const kf = { name, steps: keyframeSteps };
|
|
188
|
+
this.keyframes.push(kf);
|
|
189
|
+
return kf;
|
|
190
|
+
}
|
|
191
|
+
keyframeFromTo(name, from, to) {
|
|
192
|
+
return this.keyframe(name, { from, to });
|
|
193
|
+
}
|
|
194
|
+
// @font-face - Custom Fonts
|
|
195
|
+
fontFace(options) {
|
|
196
|
+
this.fontFaces.push(options);
|
|
197
|
+
return options;
|
|
198
|
+
}
|
|
199
|
+
// @import - Import Stylesheets
|
|
200
|
+
import(url, mediaQuery) {
|
|
201
|
+
const importRule = mediaQuery ? `@import url("${url}") ${mediaQuery};` : `@import url("${url}");`;
|
|
202
|
+
this.imports.push(importRule);
|
|
203
|
+
return importRule;
|
|
204
|
+
}
|
|
205
|
+
// @media - Media Queries
|
|
206
|
+
media(type, condition, rules) {
|
|
207
|
+
const mediaRule = { type, condition, rules: this.rulesToCSSRules(rules) };
|
|
208
|
+
this.mediaRules.push(mediaRule);
|
|
209
|
+
return mediaRule;
|
|
210
|
+
}
|
|
211
|
+
mediaScreen(condition, rules) {
|
|
212
|
+
return this.media("screen", condition, rules);
|
|
213
|
+
}
|
|
214
|
+
mediaPrint(rules) {
|
|
215
|
+
return this.media("print", "", rules);
|
|
216
|
+
}
|
|
217
|
+
mediaMinWidth(minWidth, rules) {
|
|
218
|
+
return this.media("screen", `min-width: ${minWidth}`, rules);
|
|
219
|
+
}
|
|
220
|
+
mediaMaxWidth(maxWidth, rules) {
|
|
221
|
+
return this.media("screen", `max-width: ${maxWidth}`, rules);
|
|
222
|
+
}
|
|
223
|
+
mediaDark(rules) {
|
|
224
|
+
const mediaRule = { type: "", condition: "prefers-color-scheme: dark", rules: this.rulesToCSSRules(rules) };
|
|
225
|
+
this.mediaRules.push(mediaRule);
|
|
226
|
+
return mediaRule;
|
|
227
|
+
}
|
|
228
|
+
mediaLight(rules) {
|
|
229
|
+
const mediaRule = { type: "", condition: "prefers-color-scheme: light", rules: this.rulesToCSSRules(rules) };
|
|
230
|
+
this.mediaRules.push(mediaRule);
|
|
231
|
+
return mediaRule;
|
|
232
|
+
}
|
|
233
|
+
mediaReducedMotion(rules) {
|
|
234
|
+
const mediaRule = { type: "", condition: "prefers-reduced-motion: reduce", rules: this.rulesToCSSRules(rules) };
|
|
235
|
+
this.mediaRules.push(mediaRule);
|
|
236
|
+
return mediaRule;
|
|
237
|
+
}
|
|
238
|
+
// @container - Container Queries
|
|
239
|
+
container(condition, rules, name) {
|
|
240
|
+
const containerRule = { name, condition, rules: this.rulesToCSSRules(rules) };
|
|
241
|
+
this.containerRules.push(containerRule);
|
|
242
|
+
return containerRule;
|
|
243
|
+
}
|
|
244
|
+
addContainer(name, styles2) {
|
|
245
|
+
const containerStyles = { ...styles2, containerName: name };
|
|
246
|
+
return this.addClass(name, containerStyles);
|
|
247
|
+
}
|
|
248
|
+
// @supports - Feature Queries
|
|
249
|
+
supports(condition, rules) {
|
|
250
|
+
const supportsRule = { condition, rules: this.rulesToCSSRules(rules) };
|
|
251
|
+
this.supportsRules.push(supportsRule);
|
|
252
|
+
return supportsRule;
|
|
253
|
+
}
|
|
254
|
+
// @layer - Cascade Layers
|
|
255
|
+
layerOrder(...layers) {
|
|
256
|
+
this._layerOrder = layers;
|
|
257
|
+
}
|
|
258
|
+
layer(name, rules) {
|
|
259
|
+
const layerRule = { name, rules: this.rulesToCSSRules(rules) };
|
|
260
|
+
this.layerRules.push(layerRule);
|
|
261
|
+
return layerRule;
|
|
262
|
+
}
|
|
263
|
+
// Custom Rules
|
|
264
|
+
add(rules) {
|
|
265
|
+
const cssRules = Object.entries(rules).map(([selector, styles2]) => {
|
|
266
|
+
const rule = { selector, styles: styles2, type: "custom" };
|
|
267
|
+
this.rules.push(rule);
|
|
268
|
+
return rule;
|
|
269
|
+
});
|
|
270
|
+
return cssRules;
|
|
271
|
+
}
|
|
272
|
+
important(value) {
|
|
273
|
+
return `${value} !important`;
|
|
274
|
+
}
|
|
275
|
+
// Utility Methods
|
|
276
|
+
toKebabCase(str) {
|
|
277
|
+
return str.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
278
|
+
}
|
|
279
|
+
// Helper: Create and add rule (eliminates duplication in combinator selectors)
|
|
280
|
+
createAndAddRule(selector, styles2, type = "custom") {
|
|
281
|
+
const rule = { selector, styles: styles2, type };
|
|
282
|
+
this.rules.push(rule);
|
|
283
|
+
return rule;
|
|
284
|
+
}
|
|
285
|
+
// Helper: Convert rules object to CSSRule array (eliminates duplication in media/container/supports/layer)
|
|
286
|
+
rulesToCSSRules(rules) {
|
|
287
|
+
return Object.entries(rules).map(([selector, styles2]) => ({
|
|
288
|
+
selector,
|
|
289
|
+
styles: styles2,
|
|
290
|
+
type: "custom"
|
|
291
|
+
}));
|
|
292
|
+
}
|
|
293
|
+
// Helper: Render rules with indentation (eliminates duplication in render methods)
|
|
294
|
+
renderRulesWithIndent(rules, indent = " ") {
|
|
295
|
+
return rules.map((rule) => this.renderRule(rule, indent)).join("\n");
|
|
296
|
+
}
|
|
297
|
+
stylesToString(styles2, indent = " ") {
|
|
298
|
+
return Object.entries(styles2).map(([prop, value]) => {
|
|
299
|
+
const cssValue = typeof value === "object" && value !== null && "name" in value ? `var(${value.name})` : value;
|
|
300
|
+
return `${indent}${this.toKebabCase(prop)}: ${cssValue};`;
|
|
301
|
+
}).join("\n");
|
|
302
|
+
}
|
|
303
|
+
renderRule(rule, indent = "") {
|
|
304
|
+
let css = `${indent}${rule.selector} {
|
|
305
|
+
${this.stylesToString(rule.styles, indent + " ")}
|
|
306
|
+
`;
|
|
307
|
+
if (rule.nested && rule.nested.length > 0) {
|
|
308
|
+
for (const nestedRule of rule.nested) {
|
|
309
|
+
const nestedSelector = nestedRule.selector.startsWith("&") ? nestedRule.selector.replace(/&/g, rule.selector) : `${rule.selector} ${nestedRule.selector}`;
|
|
310
|
+
css += `
|
|
311
|
+
${indent}${nestedSelector} {
|
|
312
|
+
${this.stylesToString(nestedRule.styles, indent + " ")}
|
|
313
|
+
${indent}}
|
|
314
|
+
`;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
css += `${indent}}`;
|
|
318
|
+
return css;
|
|
319
|
+
}
|
|
320
|
+
renderMediaRule(media) {
|
|
321
|
+
const condition = media.type && media.condition ? `${media.type} and (${media.condition})` : media.type ? media.type : `(${media.condition})`;
|
|
322
|
+
return `@media ${condition} {
|
|
323
|
+
${this.renderRulesWithIndent(media.rules)}
|
|
324
|
+
}`;
|
|
325
|
+
}
|
|
326
|
+
renderKeyframes(kf) {
|
|
327
|
+
let css = `@keyframes ${kf.name} {
|
|
328
|
+
`;
|
|
329
|
+
for (const step of kf.steps) {
|
|
330
|
+
css += ` ${step.step} {
|
|
331
|
+
${this.stylesToString(step.styles, " ")}
|
|
332
|
+
}
|
|
333
|
+
`;
|
|
334
|
+
}
|
|
335
|
+
css += "}";
|
|
336
|
+
return css;
|
|
337
|
+
}
|
|
338
|
+
renderFontFace(ff) {
|
|
339
|
+
let css = "@font-face {\n";
|
|
340
|
+
css += ` font-family: "${ff.fontFamily}";
|
|
341
|
+
`;
|
|
342
|
+
css += ` src: ${ff.src};
|
|
343
|
+
`;
|
|
344
|
+
if (ff.fontWeight) css += ` font-weight: ${ff.fontWeight};
|
|
345
|
+
`;
|
|
346
|
+
if (ff.fontStyle) css += ` font-style: ${ff.fontStyle};
|
|
347
|
+
`;
|
|
348
|
+
if (ff.fontDisplay) css += ` font-display: ${ff.fontDisplay};
|
|
349
|
+
`;
|
|
350
|
+
if (ff.unicodeRange) css += ` unicode-range: ${ff.unicodeRange};
|
|
351
|
+
`;
|
|
352
|
+
css += "}";
|
|
353
|
+
return css;
|
|
354
|
+
}
|
|
355
|
+
renderContainerRule(container2) {
|
|
356
|
+
const nameStr = container2.name ? `${container2.name} ` : "";
|
|
357
|
+
return `@container ${nameStr}(${container2.condition}) {
|
|
358
|
+
${this.renderRulesWithIndent(container2.rules)}
|
|
359
|
+
}`;
|
|
360
|
+
}
|
|
361
|
+
renderSupportsRule(supports) {
|
|
362
|
+
return `@supports (${supports.condition}) {
|
|
363
|
+
${this.renderRulesWithIndent(supports.rules)}
|
|
364
|
+
}`;
|
|
365
|
+
}
|
|
366
|
+
renderLayerRule(layer2) {
|
|
367
|
+
return `@layer ${layer2.name} {
|
|
368
|
+
${this.renderRulesWithIndent(layer2.rules)}
|
|
369
|
+
}`;
|
|
370
|
+
}
|
|
371
|
+
// Render Output
|
|
372
|
+
render(...additionalRules) {
|
|
373
|
+
const parts = [];
|
|
374
|
+
if (this.imports.length > 0) {
|
|
375
|
+
parts.push(this.imports.join("\n"));
|
|
376
|
+
}
|
|
377
|
+
if (this._layerOrder.length > 0) {
|
|
378
|
+
parts.push(`@layer ${this._layerOrder.join(", ")};`);
|
|
379
|
+
}
|
|
380
|
+
if (this.variables.length > 0) {
|
|
381
|
+
const varDeclarations = this.variables.map((v) => ` ${v.name}: ${v.value};`).join("\n");
|
|
382
|
+
parts.push(`:root {
|
|
383
|
+
${varDeclarations}
|
|
384
|
+
}`);
|
|
385
|
+
}
|
|
386
|
+
for (const ff of this.fontFaces) {
|
|
387
|
+
parts.push(this.renderFontFace(ff));
|
|
388
|
+
}
|
|
389
|
+
for (const kf of this.keyframes) {
|
|
390
|
+
parts.push(this.renderKeyframes(kf));
|
|
391
|
+
}
|
|
392
|
+
const allRules = [...this.rules];
|
|
393
|
+
const allMediaRules = [...this.mediaRules];
|
|
394
|
+
const allKeyframes = [];
|
|
395
|
+
const allContainerRules = [...this.containerRules];
|
|
396
|
+
const allSupportsRules = [...this.supportsRules];
|
|
397
|
+
const allLayerRules = [...this.layerRules];
|
|
398
|
+
for (const item of additionalRules) {
|
|
399
|
+
if (!item) continue;
|
|
400
|
+
if (Array.isArray(item)) {
|
|
401
|
+
allRules.push(...item);
|
|
402
|
+
} else if ("condition" in item && "rules" in item && !("name" in item && "steps" in item)) {
|
|
403
|
+
if ("type" in item) {
|
|
404
|
+
allMediaRules.push(item);
|
|
405
|
+
} else if ("name" in item && typeof item.name === "string") {
|
|
406
|
+
allContainerRules.push(item);
|
|
407
|
+
} else {
|
|
408
|
+
allSupportsRules.push(item);
|
|
409
|
+
}
|
|
410
|
+
} else if ("name" in item && "steps" in item) {
|
|
411
|
+
allKeyframes.push(item);
|
|
412
|
+
} else if ("name" in item && "rules" in item) {
|
|
413
|
+
allLayerRules.push(item);
|
|
414
|
+
} else {
|
|
415
|
+
allRules.push(item);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
for (const kf of allKeyframes) {
|
|
419
|
+
parts.push(this.renderKeyframes(kf));
|
|
420
|
+
}
|
|
421
|
+
for (const layer2 of allLayerRules) {
|
|
422
|
+
parts.push(this.renderLayerRule(layer2));
|
|
423
|
+
}
|
|
424
|
+
for (const rule of allRules) {
|
|
425
|
+
parts.push(this.renderRule(rule));
|
|
426
|
+
}
|
|
427
|
+
for (const supports of allSupportsRules) {
|
|
428
|
+
parts.push(this.renderSupportsRule(supports));
|
|
429
|
+
}
|
|
430
|
+
for (const container2 of allContainerRules) {
|
|
431
|
+
parts.push(this.renderContainerRule(container2));
|
|
432
|
+
}
|
|
433
|
+
for (const media of allMediaRules) {
|
|
434
|
+
parts.push(this.renderMediaRule(media));
|
|
435
|
+
}
|
|
436
|
+
return parts.join("\n\n");
|
|
437
|
+
}
|
|
438
|
+
inject(styleId) {
|
|
439
|
+
const css = this.render();
|
|
440
|
+
const style = document.createElement("style");
|
|
441
|
+
if (styleId) style.id = styleId;
|
|
442
|
+
style.textContent = css;
|
|
443
|
+
document.head.appendChild(style);
|
|
444
|
+
return style;
|
|
445
|
+
}
|
|
446
|
+
clear() {
|
|
447
|
+
this.variables = [];
|
|
448
|
+
this.rules = [];
|
|
449
|
+
this.mediaRules = [];
|
|
450
|
+
this.keyframes = [];
|
|
451
|
+
this.fontFaces = [];
|
|
452
|
+
this.imports = [];
|
|
453
|
+
this.containerRules = [];
|
|
454
|
+
this.supportsRules = [];
|
|
455
|
+
this.layerRules = [];
|
|
456
|
+
this._layerOrder = [];
|
|
457
|
+
}
|
|
458
|
+
};
|
|
459
|
+
var styles = new CreateStyle();
|
|
460
|
+
var {
|
|
461
|
+
addVar,
|
|
462
|
+
var: getVar,
|
|
463
|
+
addTag,
|
|
464
|
+
addClass,
|
|
465
|
+
addId,
|
|
466
|
+
addPseudoClass,
|
|
467
|
+
addPseudoElement,
|
|
468
|
+
addAttribute,
|
|
469
|
+
attrEquals,
|
|
470
|
+
attrContainsWord,
|
|
471
|
+
attrStartsWith,
|
|
472
|
+
attrEndsWith,
|
|
473
|
+
attrContains,
|
|
474
|
+
descendant,
|
|
475
|
+
child: childStyle,
|
|
476
|
+
adjacentSibling,
|
|
477
|
+
generalSibling,
|
|
478
|
+
multiple: multipleStyle,
|
|
479
|
+
addName,
|
|
480
|
+
nesting,
|
|
481
|
+
keyframe,
|
|
482
|
+
keyframeFromTo,
|
|
483
|
+
fontFace,
|
|
484
|
+
import: importStyle,
|
|
485
|
+
media: mediaStyle,
|
|
486
|
+
mediaScreen,
|
|
487
|
+
mediaPrint,
|
|
488
|
+
mediaMinWidth,
|
|
489
|
+
mediaMaxWidth,
|
|
490
|
+
mediaDark,
|
|
491
|
+
mediaLight,
|
|
492
|
+
mediaReducedMotion,
|
|
493
|
+
container,
|
|
494
|
+
addContainer,
|
|
495
|
+
supports: supportsStyle,
|
|
496
|
+
layerOrder,
|
|
497
|
+
layer,
|
|
498
|
+
add: addStyle,
|
|
499
|
+
important,
|
|
500
|
+
render: renderStyle,
|
|
501
|
+
inject: injectStyle,
|
|
502
|
+
clear: clearStyle
|
|
503
|
+
} = styles;
|
|
504
|
+
var style_default = styles;
|
|
505
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
506
|
+
0 && (module.exports = {
|
|
507
|
+
CreateStyle,
|
|
508
|
+
addAttribute,
|
|
509
|
+
addClass,
|
|
510
|
+
addContainer,
|
|
511
|
+
addId,
|
|
512
|
+
addName,
|
|
513
|
+
addPseudoClass,
|
|
514
|
+
addPseudoElement,
|
|
515
|
+
addStyle,
|
|
516
|
+
addTag,
|
|
517
|
+
addVar,
|
|
518
|
+
adjacentSibling,
|
|
519
|
+
attrContains,
|
|
520
|
+
attrContainsWord,
|
|
521
|
+
attrEndsWith,
|
|
522
|
+
attrEquals,
|
|
523
|
+
attrStartsWith,
|
|
524
|
+
childStyle,
|
|
525
|
+
clearStyle,
|
|
526
|
+
container,
|
|
527
|
+
descendant,
|
|
528
|
+
fontFace,
|
|
529
|
+
generalSibling,
|
|
530
|
+
getVar,
|
|
531
|
+
importStyle,
|
|
532
|
+
important,
|
|
533
|
+
injectStyle,
|
|
534
|
+
keyframe,
|
|
535
|
+
keyframeFromTo,
|
|
536
|
+
layer,
|
|
537
|
+
layerOrder,
|
|
538
|
+
mediaDark,
|
|
539
|
+
mediaLight,
|
|
540
|
+
mediaMaxWidth,
|
|
541
|
+
mediaMinWidth,
|
|
542
|
+
mediaPrint,
|
|
543
|
+
mediaReducedMotion,
|
|
544
|
+
mediaScreen,
|
|
545
|
+
mediaStyle,
|
|
546
|
+
multipleStyle,
|
|
547
|
+
nesting,
|
|
548
|
+
renderStyle,
|
|
549
|
+
styles,
|
|
550
|
+
supportsStyle
|
|
551
|
+
});
|