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.
Files changed (82) hide show
  1. package/README.md +275 -128
  2. package/dist/build.d.mts +10 -1
  3. package/dist/build.d.ts +10 -1
  4. package/dist/build.js +670 -1
  5. package/dist/build.mjs +641 -1
  6. package/dist/chokidar.d.mts +134 -0
  7. package/dist/chokidar.d.ts +134 -0
  8. package/dist/chokidar.js +240 -0
  9. package/dist/chokidar.mjs +221 -0
  10. package/dist/cli.js +2792 -495
  11. package/dist/dom.d.mts +10 -3
  12. package/dist/dom.d.ts +10 -3
  13. package/dist/dom.js +676 -1
  14. package/dist/dom.mjs +647 -1
  15. package/dist/el.d.mts +16 -36
  16. package/dist/el.d.ts +16 -36
  17. package/dist/el.js +789 -1
  18. package/dist/el.mjs +583 -1
  19. package/dist/fs.d.mts +255 -0
  20. package/dist/fs.d.ts +255 -0
  21. package/dist/fs.js +513 -0
  22. package/dist/fs.mjs +469 -0
  23. package/dist/hmr.js +112 -1
  24. package/dist/hmr.mjs +91 -1
  25. package/dist/http.d.mts +163 -0
  26. package/dist/http.d.ts +163 -0
  27. package/dist/http.js +632 -0
  28. package/dist/http.mjs +605 -0
  29. package/dist/https.d.mts +108 -0
  30. package/dist/https.d.ts +108 -0
  31. package/dist/https.js +907 -0
  32. package/dist/https.mjs +901 -0
  33. package/dist/index.d.mts +613 -33
  34. package/dist/index.d.ts +613 -33
  35. package/dist/index.js +2589 -1
  36. package/dist/index.mjs +2312 -1
  37. package/dist/mime-types.d.mts +48 -0
  38. package/dist/mime-types.d.ts +48 -0
  39. package/dist/mime-types.js +197 -0
  40. package/dist/mime-types.mjs +166 -0
  41. package/dist/path.d.mts +163 -0
  42. package/dist/path.d.ts +163 -0
  43. package/dist/path.js +350 -0
  44. package/dist/path.mjs +310 -0
  45. package/dist/router.d.mts +3 -1
  46. package/dist/router.d.ts +3 -1
  47. package/dist/router.js +830 -1
  48. package/dist/router.mjs +801 -1
  49. package/dist/runtime.d.mts +97 -0
  50. package/dist/runtime.d.ts +97 -0
  51. package/dist/runtime.js +43 -0
  52. package/dist/runtime.mjs +15 -0
  53. package/dist/server.d.mts +5 -1
  54. package/dist/server.d.ts +5 -1
  55. package/dist/server.js +3267 -1
  56. package/dist/server.mjs +3241 -1
  57. package/dist/state.d.mts +3 -1
  58. package/dist/state.d.ts +3 -1
  59. package/dist/state.js +1036 -1
  60. package/dist/state.mjs +992 -1
  61. package/dist/style.d.mts +47 -1
  62. package/dist/style.d.ts +47 -1
  63. package/dist/style.js +551 -1
  64. package/dist/style.mjs +483 -1
  65. package/dist/{types-DOAdFFJB.d.ts → types-C0nGi6MX.d.mts} +29 -13
  66. package/dist/{types-DOAdFFJB.d.mts → types-Du6kfwTm.d.ts} +29 -13
  67. package/dist/types.d.mts +452 -3
  68. package/dist/types.d.ts +452 -3
  69. package/dist/types.js +18 -1
  70. package/dist/ws.d.mts +195 -0
  71. package/dist/ws.d.ts +195 -0
  72. package/dist/ws.js +380 -0
  73. package/dist/ws.mjs +358 -0
  74. package/dist/wss.d.mts +108 -0
  75. package/dist/wss.d.ts +108 -0
  76. package/dist/wss.js +1306 -0
  77. package/dist/wss.mjs +1300 -0
  78. package/package.json +53 -6
  79. package/dist/client.d.mts +0 -9
  80. package/dist/client.d.ts +0 -9
  81. package/dist/client.js +0 -1
  82. package/dist/client.mjs +0 -1
package/dist/style.mjs CHANGED
@@ -1 +1,483 @@
1
- var e=class{constructor(){this.variables=[],this.rules=[],this.mediaRules=[],this.keyframes=[],this.fontFaces=[],this.imports=[],this.containerRules=[],this.supportsRules=[],this.layerRules=[],this._layerOrder=[]}addVar(e,t){let s={name:e.startsWith("--")?e:`--${e}`,value:t,toString(){return`var(${this.name})`}};return this.variables.push(s),s}var(e,t){let s="string"==typeof e?e.startsWith("--")?e:`--${e}`:e.name;return t?`var(${s}, ${t})`:`var(${s})`}addTag(e,t){let s={selector:e,styles:t,type:"tag"};return this.rules.push(s),s}addClass(e,t){let s={selector:e.startsWith(".")?e:`.${e}`,styles:t,type:"class"};return this.rules.push(s),s}addId(e,t){let s={selector:e.startsWith("#")?e:`#${e}`,styles:t,type:"id"};return this.rules.push(s),s}addPseudoClass(e,t,s){let r=e.startsWith(":")?e:`:${e}`,n={selector:s?`${s}${r}`:r,styles:t,type:"pseudo-class"};return this.rules.push(n),n}addPseudoElement(e,t,s){let r=e.startsWith("::")?e:`::${e}`,n={selector:s?`${s}${r}`:r,styles:t,type:"pseudo-element"};return this.rules.push(n),n}addAttribute(e,t,s){let r=e.startsWith("[")?e:`[${e}]`,n={selector:s?`${s}${r}`:r,styles:t,type:"attribute"};return this.rules.push(n),n}attrEquals(e,t,s,r){return this.addAttribute(`${e}="${t}"`,s,r)}attrContainsWord(e,t,s,r){return this.addAttribute(`${e}~="${t}"`,s,r)}attrStartsWith(e,t,s,r){return this.addAttribute(`${e}^="${t}"`,s,r)}attrEndsWith(e,t,s,r){return this.addAttribute(`${e}$="${t}"`,s,r)}attrContains(e,t,s,r){return this.addAttribute(`${e}*="${t}"`,s,r)}descendant(e,t,s){let r={selector:`${e} ${t}`,styles:s,type:"custom"};return this.rules.push(r),r}child(e,t,s){let r={selector:`${e} > ${t}`,styles:s,type:"custom"};return this.rules.push(r),r}adjacentSibling(e,t,s){let r={selector:`${e} + ${t}`,styles:s,type:"custom"};return this.rules.push(r),r}generalSibling(e,t,s){let r={selector:`${e} ~ ${t}`,styles:s,type:"custom"};return this.rules.push(r),r}multiple(e,t){let s={selector:e.join(", "),styles:t,type:"custom"};return this.rules.push(s),s}addName(e,t){return{selector:e.startsWith("--")?`&${e}`:`&--${e}`,styles:t,type:"name"}}nesting(e,...t){return e.nested=t,e}keyframe(e,t){let s={name:e,steps:Object.entries(t).map(([e,t])=>({step:"from"===e?"from":"to"===e?"to":`${e}%`,styles:t}))};return this.keyframes.push(s),s}keyframeFromTo(e,t,s){return this.keyframe(e,{from:t,to:s})}fontFace(e){return this.fontFaces.push(e),e}import(e,t){let s=t?`@import url("${e}") ${t};`:`@import url("${e}");`;return this.imports.push(s),s}media(e,t,s){let r={type:e,condition:t,rules:Object.entries(s).map(([e,t])=>({selector:e,styles:t,type:"custom"}))};return this.mediaRules.push(r),r}mediaScreen(e,t){return this.media("screen",e,t)}mediaPrint(e){return this.media("print","",e)}mediaMinWidth(e,t){return this.media("screen",`min-width: ${e}`,t)}mediaMaxWidth(e,t){return this.media("screen",`max-width: ${e}`,t)}mediaDark(e){let t={type:"",condition:"prefers-color-scheme: dark",rules:Object.entries(e).map(([e,t])=>({selector:e,styles:t,type:"custom"}))};return this.mediaRules.push(t),t}mediaLight(e){let t={type:"",condition:"prefers-color-scheme: light",rules:Object.entries(e).map(([e,t])=>({selector:e,styles:t,type:"custom"}))};return this.mediaRules.push(t),t}mediaReducedMotion(e){let t={type:"",condition:"prefers-reduced-motion: reduce",rules:Object.entries(e).map(([e,t])=>({selector:e,styles:t,type:"custom"}))};return this.mediaRules.push(t),t}container(e,t,s){let r={name:s,condition:e,rules:Object.entries(t).map(([e,t])=>({selector:e,styles:t,type:"custom"}))};return this.containerRules.push(r),r}addContainer(e,t){let s={...t,containerName:e};return this.addClass(e,s)}supports(e,t){let s={condition:e,rules:Object.entries(t).map(([e,t])=>({selector:e,styles:t,type:"custom"}))};return this.supportsRules.push(s),s}layerOrder(...e){this._layerOrder=e}layer(e,t){let s={name:e,rules:Object.entries(t).map(([e,t])=>({selector:e,styles:t,type:"custom"}))};return this.layerRules.push(s),s}add(e){return Object.entries(e).map(([e,t])=>{let s={selector:e,styles:t,type:"custom"};return this.rules.push(s),s})}important(e){return`${e} !important`}toKebabCase(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}stylesToString(e,t=" "){return Object.entries(e).map(([e,s])=>{let r="object"==typeof s&&null!==s&&"name"in s?`var(${s.name})`:s;return`${t}${this.toKebabCase(e)}: ${r};`}).join("\n")}renderRule(e,t=""){let s=`${t}${e.selector} {\n${this.stylesToString(e.styles,t+" ")}\n`;if(e.nested&&e.nested.length>0)for(let r of e.nested){s+=`\n${t}${r.selector.startsWith("&")?r.selector.replace(/&/g,e.selector):`${e.selector} ${r.selector}`} {\n${this.stylesToString(r.styles,t+" ")}\n${t}}\n`}return s+=`${t}}`,s}renderMediaRule(e){let t=`@media ${e.type&&e.condition?`${e.type} and (${e.condition})`:e.type?e.type:`(${e.condition})`} {\n`;for(let s of e.rules)t+=this.renderRule(s," ")+"\n";return t+="}",t}renderKeyframes(e){let t=`@keyframes ${e.name} {\n`;for(let s of e.steps)t+=` ${s.step} {\n${this.stylesToString(s.styles," ")}\n }\n`;return t+="}",t}renderFontFace(e){let t="@font-face {\n";return t+=` font-family: "${e.fontFamily}";\n`,t+=` src: ${e.src};\n`,e.fontWeight&&(t+=` font-weight: ${e.fontWeight};\n`),e.fontStyle&&(t+=` font-style: ${e.fontStyle};\n`),e.fontDisplay&&(t+=` font-display: ${e.fontDisplay};\n`),e.unicodeRange&&(t+=` unicode-range: ${e.unicodeRange};\n`),t+="}",t}renderContainerRule(e){let t=`@container ${e.name?`${e.name} `:""}(${e.condition}) {\n`;for(let s of e.rules)t+=this.renderRule(s," ")+"\n";return t+="}",t}renderSupportsRule(e){let t=`@supports (${e.condition}) {\n`;for(let s of e.rules)t+=this.renderRule(s," ")+"\n";return t+="}",t}renderLayerRule(e){let t=`@layer ${e.name} {\n`;for(let s of e.rules)t+=this.renderRule(s," ")+"\n";return t+="}",t}render(...e){let t=[];if(this.imports.length>0&&t.push(this.imports.join("\n")),this._layerOrder.length>0&&t.push(`@layer ${this._layerOrder.join(", ")};`),this.variables.length>0){let e=this.variables.map(e=>` ${e.name}: ${e.value};`).join("\n");t.push(`:root {\n${e}\n}`)}for(let e of this.fontFaces)t.push(this.renderFontFace(e));for(let e of this.keyframes)t.push(this.renderKeyframes(e));let s=[...this.rules],r=[...this.mediaRules],n=[],i=[...this.containerRules],l=[...this.supportsRules],u=[...this.layerRules];for(let t of e)t&&(Array.isArray(t)?s.push(...t):!("condition"in t)||!("rules"in t)||"name"in t&&"steps"in t?"name"in t&&"steps"in t?n.push(t):"name"in t&&"rules"in t?u.push(t):s.push(t):"type"in t?r.push(t):"name"in t&&"string"==typeof t.name?i.push(t):l.push(t));for(let e of n)t.push(this.renderKeyframes(e));for(let e of u)t.push(this.renderLayerRule(e));for(let e of s)t.push(this.renderRule(e));for(let e of l)t.push(this.renderSupportsRule(e));for(let e of i)t.push(this.renderContainerRule(e));for(let e of r)t.push(this.renderMediaRule(e));return t.join("\n\n")}inject(e){let t=this.render(),s=document.createElement("style");return e&&(s.id=e),s.textContent=t,document.head.appendChild(s),s}clear(){this.variables=[],this.rules=[],this.mediaRules=[],this.keyframes=[],this.fontFaces=[],this.imports=[],this.containerRules=[],this.supportsRules=[],this.layerRules=[],this._layerOrder=[]}};export{e as CreateStyle};
1
+ // src/style.ts
2
+ var CreateStyle = class {
3
+ constructor() {
4
+ this.variables = [];
5
+ this.rules = [];
6
+ this.mediaRules = [];
7
+ this.keyframes = [];
8
+ this.fontFaces = [];
9
+ this.imports = [];
10
+ this.containerRules = [];
11
+ this.supportsRules = [];
12
+ this.layerRules = [];
13
+ this._layerOrder = [];
14
+ }
15
+ // CSS Variables
16
+ addVar(name, value) {
17
+ const cssVar = {
18
+ name: name.startsWith("--") ? name : `--${name}`,
19
+ value,
20
+ toString() {
21
+ return `var(${this.name})`;
22
+ }
23
+ };
24
+ this.variables.push(cssVar);
25
+ return cssVar;
26
+ }
27
+ var(variable, fallback) {
28
+ const varName = typeof variable === "string" ? variable.startsWith("--") ? variable : `--${variable}` : variable.name;
29
+ return fallback ? `var(${varName}, ${fallback})` : `var(${varName})`;
30
+ }
31
+ // Basic Selectors
32
+ addTag(tag, styles2) {
33
+ const rule = { selector: tag, styles: styles2, type: "tag" };
34
+ this.rules.push(rule);
35
+ return rule;
36
+ }
37
+ addClass(name, styles2) {
38
+ const selector = name.startsWith(".") ? name : `.${name}`;
39
+ const rule = { selector, styles: styles2, type: "class" };
40
+ this.rules.push(rule);
41
+ return rule;
42
+ }
43
+ addId(name, styles2) {
44
+ const selector = name.startsWith("#") ? name : `#${name}`;
45
+ const rule = { selector, styles: styles2, type: "id" };
46
+ this.rules.push(rule);
47
+ return rule;
48
+ }
49
+ // Pseudo Selectors
50
+ addPseudoClass(pseudo, styles2, baseSelector) {
51
+ const pseudoClass = pseudo.startsWith(":") ? pseudo : `:${pseudo}`;
52
+ const selector = baseSelector ? `${baseSelector}${pseudoClass}` : pseudoClass;
53
+ const rule = { selector, styles: styles2, type: "pseudo-class" };
54
+ this.rules.push(rule);
55
+ return rule;
56
+ }
57
+ addPseudoElement(pseudo, styles2, baseSelector) {
58
+ const pseudoElement = pseudo.startsWith("::") ? pseudo : `::${pseudo}`;
59
+ const selector = baseSelector ? `${baseSelector}${pseudoElement}` : pseudoElement;
60
+ const rule = { selector, styles: styles2, type: "pseudo-element" };
61
+ this.rules.push(rule);
62
+ return rule;
63
+ }
64
+ // Attribute Selectors
65
+ addAttribute(attr, styles2, baseSelector) {
66
+ const attrSelector = attr.startsWith("[") ? attr : `[${attr}]`;
67
+ const selector = baseSelector ? `${baseSelector}${attrSelector}` : attrSelector;
68
+ const rule = { selector, styles: styles2, type: "attribute" };
69
+ this.rules.push(rule);
70
+ return rule;
71
+ }
72
+ attrEquals(attr, value, styles2, baseSelector) {
73
+ return this.addAttribute(`${attr}="${value}"`, styles2, baseSelector);
74
+ }
75
+ attrContainsWord(attr, value, styles2, baseSelector) {
76
+ return this.addAttribute(`${attr}~="${value}"`, styles2, baseSelector);
77
+ }
78
+ attrStartsWith(attr, value, styles2, baseSelector) {
79
+ return this.addAttribute(`${attr}^="${value}"`, styles2, baseSelector);
80
+ }
81
+ attrEndsWith(attr, value, styles2, baseSelector) {
82
+ return this.addAttribute(`${attr}$="${value}"`, styles2, baseSelector);
83
+ }
84
+ attrContains(attr, value, styles2, baseSelector) {
85
+ return this.addAttribute(`${attr}*="${value}"`, styles2, baseSelector);
86
+ }
87
+ // Combinator Selectors
88
+ descendant(ancestor, descendant2, styles2) {
89
+ return this.createAndAddRule(`${ancestor} ${descendant2}`, styles2);
90
+ }
91
+ child(parent, childSel, styles2) {
92
+ return this.createAndAddRule(`${parent} > ${childSel}`, styles2);
93
+ }
94
+ adjacentSibling(element, sibling, styles2) {
95
+ return this.createAndAddRule(`${element} + ${sibling}`, styles2);
96
+ }
97
+ generalSibling(element, sibling, styles2) {
98
+ return this.createAndAddRule(`${element} ~ ${sibling}`, styles2);
99
+ }
100
+ multiple(selectors, styles2) {
101
+ return this.createAndAddRule(selectors.join(", "), styles2);
102
+ }
103
+ // Nesting (BEM-style)
104
+ addName(name, styles2) {
105
+ const selector = name.startsWith("--") ? `&${name}` : `&--${name}`;
106
+ const rule = { selector, styles: styles2, type: "name" };
107
+ return rule;
108
+ }
109
+ nesting(parentRule, ...childRules) {
110
+ parentRule.nested = childRules;
111
+ return parentRule;
112
+ }
113
+ // @keyframes - Animations
114
+ keyframe(name, steps) {
115
+ const keyframeSteps = Object.entries(steps).map(([step, styles2]) => ({
116
+ step: step === "from" ? "from" : step === "to" ? "to" : `${step}%`,
117
+ styles: styles2
118
+ }));
119
+ const kf = { name, steps: keyframeSteps };
120
+ this.keyframes.push(kf);
121
+ return kf;
122
+ }
123
+ keyframeFromTo(name, from, to) {
124
+ return this.keyframe(name, { from, to });
125
+ }
126
+ // @font-face - Custom Fonts
127
+ fontFace(options) {
128
+ this.fontFaces.push(options);
129
+ return options;
130
+ }
131
+ // @import - Import Stylesheets
132
+ import(url, mediaQuery) {
133
+ const importRule = mediaQuery ? `@import url("${url}") ${mediaQuery};` : `@import url("${url}");`;
134
+ this.imports.push(importRule);
135
+ return importRule;
136
+ }
137
+ // @media - Media Queries
138
+ media(type, condition, rules) {
139
+ const mediaRule = { type, condition, rules: this.rulesToCSSRules(rules) };
140
+ this.mediaRules.push(mediaRule);
141
+ return mediaRule;
142
+ }
143
+ mediaScreen(condition, rules) {
144
+ return this.media("screen", condition, rules);
145
+ }
146
+ mediaPrint(rules) {
147
+ return this.media("print", "", rules);
148
+ }
149
+ mediaMinWidth(minWidth, rules) {
150
+ return this.media("screen", `min-width: ${minWidth}`, rules);
151
+ }
152
+ mediaMaxWidth(maxWidth, rules) {
153
+ return this.media("screen", `max-width: ${maxWidth}`, rules);
154
+ }
155
+ mediaDark(rules) {
156
+ const mediaRule = { type: "", condition: "prefers-color-scheme: dark", rules: this.rulesToCSSRules(rules) };
157
+ this.mediaRules.push(mediaRule);
158
+ return mediaRule;
159
+ }
160
+ mediaLight(rules) {
161
+ const mediaRule = { type: "", condition: "prefers-color-scheme: light", rules: this.rulesToCSSRules(rules) };
162
+ this.mediaRules.push(mediaRule);
163
+ return mediaRule;
164
+ }
165
+ mediaReducedMotion(rules) {
166
+ const mediaRule = { type: "", condition: "prefers-reduced-motion: reduce", rules: this.rulesToCSSRules(rules) };
167
+ this.mediaRules.push(mediaRule);
168
+ return mediaRule;
169
+ }
170
+ // @container - Container Queries
171
+ container(condition, rules, name) {
172
+ const containerRule = { name, condition, rules: this.rulesToCSSRules(rules) };
173
+ this.containerRules.push(containerRule);
174
+ return containerRule;
175
+ }
176
+ addContainer(name, styles2) {
177
+ const containerStyles = { ...styles2, containerName: name };
178
+ return this.addClass(name, containerStyles);
179
+ }
180
+ // @supports - Feature Queries
181
+ supports(condition, rules) {
182
+ const supportsRule = { condition, rules: this.rulesToCSSRules(rules) };
183
+ this.supportsRules.push(supportsRule);
184
+ return supportsRule;
185
+ }
186
+ // @layer - Cascade Layers
187
+ layerOrder(...layers) {
188
+ this._layerOrder = layers;
189
+ }
190
+ layer(name, rules) {
191
+ const layerRule = { name, rules: this.rulesToCSSRules(rules) };
192
+ this.layerRules.push(layerRule);
193
+ return layerRule;
194
+ }
195
+ // Custom Rules
196
+ add(rules) {
197
+ const cssRules = Object.entries(rules).map(([selector, styles2]) => {
198
+ const rule = { selector, styles: styles2, type: "custom" };
199
+ this.rules.push(rule);
200
+ return rule;
201
+ });
202
+ return cssRules;
203
+ }
204
+ important(value) {
205
+ return `${value} !important`;
206
+ }
207
+ // Utility Methods
208
+ toKebabCase(str) {
209
+ return str.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
210
+ }
211
+ // Helper: Create and add rule (eliminates duplication in combinator selectors)
212
+ createAndAddRule(selector, styles2, type = "custom") {
213
+ const rule = { selector, styles: styles2, type };
214
+ this.rules.push(rule);
215
+ return rule;
216
+ }
217
+ // Helper: Convert rules object to CSSRule array (eliminates duplication in media/container/supports/layer)
218
+ rulesToCSSRules(rules) {
219
+ return Object.entries(rules).map(([selector, styles2]) => ({
220
+ selector,
221
+ styles: styles2,
222
+ type: "custom"
223
+ }));
224
+ }
225
+ // Helper: Render rules with indentation (eliminates duplication in render methods)
226
+ renderRulesWithIndent(rules, indent = " ") {
227
+ return rules.map((rule) => this.renderRule(rule, indent)).join("\n");
228
+ }
229
+ stylesToString(styles2, indent = " ") {
230
+ return Object.entries(styles2).map(([prop, value]) => {
231
+ const cssValue = typeof value === "object" && value !== null && "name" in value ? `var(${value.name})` : value;
232
+ return `${indent}${this.toKebabCase(prop)}: ${cssValue};`;
233
+ }).join("\n");
234
+ }
235
+ renderRule(rule, indent = "") {
236
+ let css = `${indent}${rule.selector} {
237
+ ${this.stylesToString(rule.styles, indent + " ")}
238
+ `;
239
+ if (rule.nested && rule.nested.length > 0) {
240
+ for (const nestedRule of rule.nested) {
241
+ const nestedSelector = nestedRule.selector.startsWith("&") ? nestedRule.selector.replace(/&/g, rule.selector) : `${rule.selector} ${nestedRule.selector}`;
242
+ css += `
243
+ ${indent}${nestedSelector} {
244
+ ${this.stylesToString(nestedRule.styles, indent + " ")}
245
+ ${indent}}
246
+ `;
247
+ }
248
+ }
249
+ css += `${indent}}`;
250
+ return css;
251
+ }
252
+ renderMediaRule(media) {
253
+ const condition = media.type && media.condition ? `${media.type} and (${media.condition})` : media.type ? media.type : `(${media.condition})`;
254
+ return `@media ${condition} {
255
+ ${this.renderRulesWithIndent(media.rules)}
256
+ }`;
257
+ }
258
+ renderKeyframes(kf) {
259
+ let css = `@keyframes ${kf.name} {
260
+ `;
261
+ for (const step of kf.steps) {
262
+ css += ` ${step.step} {
263
+ ${this.stylesToString(step.styles, " ")}
264
+ }
265
+ `;
266
+ }
267
+ css += "}";
268
+ return css;
269
+ }
270
+ renderFontFace(ff) {
271
+ let css = "@font-face {\n";
272
+ css += ` font-family: "${ff.fontFamily}";
273
+ `;
274
+ css += ` src: ${ff.src};
275
+ `;
276
+ if (ff.fontWeight) css += ` font-weight: ${ff.fontWeight};
277
+ `;
278
+ if (ff.fontStyle) css += ` font-style: ${ff.fontStyle};
279
+ `;
280
+ if (ff.fontDisplay) css += ` font-display: ${ff.fontDisplay};
281
+ `;
282
+ if (ff.unicodeRange) css += ` unicode-range: ${ff.unicodeRange};
283
+ `;
284
+ css += "}";
285
+ return css;
286
+ }
287
+ renderContainerRule(container2) {
288
+ const nameStr = container2.name ? `${container2.name} ` : "";
289
+ return `@container ${nameStr}(${container2.condition}) {
290
+ ${this.renderRulesWithIndent(container2.rules)}
291
+ }`;
292
+ }
293
+ renderSupportsRule(supports) {
294
+ return `@supports (${supports.condition}) {
295
+ ${this.renderRulesWithIndent(supports.rules)}
296
+ }`;
297
+ }
298
+ renderLayerRule(layer2) {
299
+ return `@layer ${layer2.name} {
300
+ ${this.renderRulesWithIndent(layer2.rules)}
301
+ }`;
302
+ }
303
+ // Render Output
304
+ render(...additionalRules) {
305
+ const parts = [];
306
+ if (this.imports.length > 0) {
307
+ parts.push(this.imports.join("\n"));
308
+ }
309
+ if (this._layerOrder.length > 0) {
310
+ parts.push(`@layer ${this._layerOrder.join(", ")};`);
311
+ }
312
+ if (this.variables.length > 0) {
313
+ const varDeclarations = this.variables.map((v) => ` ${v.name}: ${v.value};`).join("\n");
314
+ parts.push(`:root {
315
+ ${varDeclarations}
316
+ }`);
317
+ }
318
+ for (const ff of this.fontFaces) {
319
+ parts.push(this.renderFontFace(ff));
320
+ }
321
+ for (const kf of this.keyframes) {
322
+ parts.push(this.renderKeyframes(kf));
323
+ }
324
+ const allRules = [...this.rules];
325
+ const allMediaRules = [...this.mediaRules];
326
+ const allKeyframes = [];
327
+ const allContainerRules = [...this.containerRules];
328
+ const allSupportsRules = [...this.supportsRules];
329
+ const allLayerRules = [...this.layerRules];
330
+ for (const item of additionalRules) {
331
+ if (!item) continue;
332
+ if (Array.isArray(item)) {
333
+ allRules.push(...item);
334
+ } else if ("condition" in item && "rules" in item && !("name" in item && "steps" in item)) {
335
+ if ("type" in item) {
336
+ allMediaRules.push(item);
337
+ } else if ("name" in item && typeof item.name === "string") {
338
+ allContainerRules.push(item);
339
+ } else {
340
+ allSupportsRules.push(item);
341
+ }
342
+ } else if ("name" in item && "steps" in item) {
343
+ allKeyframes.push(item);
344
+ } else if ("name" in item && "rules" in item) {
345
+ allLayerRules.push(item);
346
+ } else {
347
+ allRules.push(item);
348
+ }
349
+ }
350
+ for (const kf of allKeyframes) {
351
+ parts.push(this.renderKeyframes(kf));
352
+ }
353
+ for (const layer2 of allLayerRules) {
354
+ parts.push(this.renderLayerRule(layer2));
355
+ }
356
+ for (const rule of allRules) {
357
+ parts.push(this.renderRule(rule));
358
+ }
359
+ for (const supports of allSupportsRules) {
360
+ parts.push(this.renderSupportsRule(supports));
361
+ }
362
+ for (const container2 of allContainerRules) {
363
+ parts.push(this.renderContainerRule(container2));
364
+ }
365
+ for (const media of allMediaRules) {
366
+ parts.push(this.renderMediaRule(media));
367
+ }
368
+ return parts.join("\n\n");
369
+ }
370
+ inject(styleId) {
371
+ const css = this.render();
372
+ const style = document.createElement("style");
373
+ if (styleId) style.id = styleId;
374
+ style.textContent = css;
375
+ document.head.appendChild(style);
376
+ return style;
377
+ }
378
+ clear() {
379
+ this.variables = [];
380
+ this.rules = [];
381
+ this.mediaRules = [];
382
+ this.keyframes = [];
383
+ this.fontFaces = [];
384
+ this.imports = [];
385
+ this.containerRules = [];
386
+ this.supportsRules = [];
387
+ this.layerRules = [];
388
+ this._layerOrder = [];
389
+ }
390
+ };
391
+ var styles = new CreateStyle();
392
+ var {
393
+ addVar,
394
+ var: getVar,
395
+ addTag,
396
+ addClass,
397
+ addId,
398
+ addPseudoClass,
399
+ addPseudoElement,
400
+ addAttribute,
401
+ attrEquals,
402
+ attrContainsWord,
403
+ attrStartsWith,
404
+ attrEndsWith,
405
+ attrContains,
406
+ descendant,
407
+ child: childStyle,
408
+ adjacentSibling,
409
+ generalSibling,
410
+ multiple: multipleStyle,
411
+ addName,
412
+ nesting,
413
+ keyframe,
414
+ keyframeFromTo,
415
+ fontFace,
416
+ import: importStyle,
417
+ media: mediaStyle,
418
+ mediaScreen,
419
+ mediaPrint,
420
+ mediaMinWidth,
421
+ mediaMaxWidth,
422
+ mediaDark,
423
+ mediaLight,
424
+ mediaReducedMotion,
425
+ container,
426
+ addContainer,
427
+ supports: supportsStyle,
428
+ layerOrder,
429
+ layer,
430
+ add: addStyle,
431
+ important,
432
+ render: renderStyle,
433
+ inject: injectStyle,
434
+ clear: clearStyle
435
+ } = styles;
436
+ var style_default = styles;
437
+ export {
438
+ CreateStyle,
439
+ addAttribute,
440
+ addClass,
441
+ addContainer,
442
+ addId,
443
+ addName,
444
+ addPseudoClass,
445
+ addPseudoElement,
446
+ addStyle,
447
+ addTag,
448
+ addVar,
449
+ adjacentSibling,
450
+ attrContains,
451
+ attrContainsWord,
452
+ attrEndsWith,
453
+ attrEquals,
454
+ attrStartsWith,
455
+ childStyle,
456
+ clearStyle,
457
+ container,
458
+ style_default as default,
459
+ descendant,
460
+ fontFace,
461
+ generalSibling,
462
+ getVar,
463
+ importStyle,
464
+ important,
465
+ injectStyle,
466
+ keyframe,
467
+ keyframeFromTo,
468
+ layer,
469
+ layerOrder,
470
+ mediaDark,
471
+ mediaLight,
472
+ mediaMaxWidth,
473
+ mediaMinWidth,
474
+ mediaPrint,
475
+ mediaReducedMotion,
476
+ mediaScreen,
477
+ mediaStyle,
478
+ multipleStyle,
479
+ nesting,
480
+ renderStyle,
481
+ styles,
482
+ supportsStyle
483
+ };
@@ -1,8 +1,14 @@
1
- import { IncomingMessage, ServerResponse, Server } from 'http';
2
- import { WebSocket, WebSocketServer } from 'ws';
1
+ import { IncomingMessage, ServerResponse } from './http.mjs';
2
+ import { WebSocket } from './ws.mjs';
3
+ import { Server } from 'http';
4
+ import { WebSocketServer } from 'ws';
3
5
 
4
6
  /**
5
7
  * Development server with HMR support
8
+ * Cross-runtime transpilation support
9
+ * - Node.js: uses esbuild
10
+ * - Bun: uses Bun.Transpiler
11
+ * - Deno: uses Deno.emit
6
12
  */
7
13
 
8
14
  type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS' | 'HEAD';
@@ -20,22 +26,22 @@ declare class ServerRouter {
20
26
  private routes;
21
27
  private middlewares;
22
28
  use(middleware: Middleware): this;
23
- get(path: string, handler: ServerRouteHandler): this;
24
- post(path: string, handler: ServerRouteHandler): this;
25
- put(path: string, handler: ServerRouteHandler): this;
26
- delete(path: string, handler: ServerRouteHandler): this;
27
- patch(path: string, handler: ServerRouteHandler): this;
28
- options(path: string, handler: ServerRouteHandler): this;
29
+ get: (path: string, handler: ServerRouteHandler) => this;
30
+ post: (path: string, handler: ServerRouteHandler) => this;
31
+ put: (path: string, handler: ServerRouteHandler) => this;
32
+ delete: (path: string, handler: ServerRouteHandler) => this;
33
+ patch: (path: string, handler: ServerRouteHandler) => this;
34
+ options: (path: string, handler: ServerRouteHandler) => this;
29
35
  private addRoute;
30
36
  private pathToRegex;
31
37
  private parseQuery;
32
38
  private parseBody;
33
39
  handle(req: IncomingMessage, res: ServerResponse): Promise<boolean>;
34
40
  }
35
- declare const json: (res: ServerResponse, data: any, status?: number) => void;
36
- declare const text: (res: ServerResponse, data: string, status?: number) => void;
37
- declare const html: (res: ServerResponse, data: string, status?: number) => void;
38
- declare const status: (res: ServerResponse, code: number, message?: string) => void;
41
+ declare const json: (res: ServerResponse, data: any, status?: number) => ServerResponse;
42
+ declare const text: (res: ServerResponse, data: string, status?: number) => ServerResponse;
43
+ declare const html: (res: ServerResponse, data: string, status?: number) => ServerResponse;
44
+ declare const status: (res: ServerResponse, code: number, message?: string) => ServerResponse;
39
45
  declare function cors(options?: {
40
46
  origin?: string | string[];
41
47
  methods?: string[];
@@ -165,6 +171,8 @@ interface ClientConfig {
165
171
  root: string;
166
172
  /** Base path for the client application (e.g., '/app1', '/app2') */
167
173
  basePath: string;
174
+ /** Custom index file path (relative to root, e.g., './public/index.html') */
175
+ index?: string;
168
176
  /** SSR render function - returns HTML VNode or string */
169
177
  ssr?: () => Child | string;
170
178
  /** Watch patterns for file changes */
@@ -179,6 +187,8 @@ interface ClientConfig {
179
187
  api?: Router;
180
188
  /** Custom middleware specific to this client */
181
189
  middleware?: ((req: any, res: any, next: () => void) => void)[];
190
+ /** Server mode: 'dev' uses source files, 'preview' uses built files (default: 'dev') */
191
+ mode?: 'dev' | 'preview';
182
192
  }
183
193
  interface ProxyConfig {
184
194
  /** Path prefix to match for proxying (e.g., '/api', '/graphql') */
@@ -211,6 +221,8 @@ interface DevServerOptions {
211
221
  root?: string;
212
222
  /** Base path for the client application (e.g., '/app1', '/app2') */
213
223
  basePath?: string;
224
+ /** Custom index file path (relative to root, e.g., './public/index.html') */
225
+ index?: string;
214
226
  /** Array of client configurations - allows multiple clients on same port */
215
227
  clients?: ClientConfig[];
216
228
  /** Enable HTTPS (default: false) */
@@ -233,6 +245,8 @@ interface DevServerOptions {
233
245
  ssr?: () => Child | string;
234
246
  /** Proxy configuration for API requests */
235
247
  proxy?: ProxyConfig[];
248
+ /** Server mode: 'dev' uses source files, 'preview' uses built files (default: 'dev') */
249
+ mode?: 'dev' | 'preview';
236
250
  }
237
251
  interface DevServer {
238
252
  /** HTTP server instance */
@@ -307,6 +321,8 @@ interface PreviewOptions {
307
321
  root?: string;
308
322
  /** Base path for the application (e.g., '/app') */
309
323
  basePath?: string;
324
+ /** Custom index file path (relative to root, e.g., './public/index.html') */
325
+ index?: string;
310
326
  /** Array of client configurations - allows multiple clients on same port */
311
327
  clients?: ClientConfig[];
312
328
  /** Enable HTTPS (default: false) */
@@ -327,4 +343,4 @@ interface PreviewOptions {
327
343
  worker?: WorkerConfig[];
328
344
  }
329
345
 
330
- export { type ClientConfig as A, type BuildOptions as B, type Child as C, type DevServerOptions as D, type ElementFactory as E, type ProxyConfig as F, type DevServer as G, type HttpMethod as H, type HMRMessage as I, type JsonNode as J, type PreviewOptions as K, createProxyHandler as L, type Middleware as M, type Router as N, type StateManager as O, type Props as P, type RefCallback as R, ServerRouter as S, type VNode as V, type WorkerConfig as W, type ServerRouteContext as a, type ServerRouteHandler as b, createDevServer as c, cors as d, errorHandler as e, bodyLimit as f, cacheControl as g, html as h, compress as i, json as j, security as k, logger as l, StateManager$1 as m, SharedState as n, type SharedStateOptions as o, type StateChangeHandler as p, type BuildResult as q, rateLimit as r, status as s, text as t, type Children as u, type RefObject as v, type State as w, type StateOptions as x, type VirtualListController as y, type VNodeJson as z };
346
+ export { security as A, type BuildOptions as B, type Children as C, type DevServerOptions as D, type ElementFactory as E, createProxyHandler as F, type StateChangeHandler as G, type HMRMessage as H, type SharedStateOptions as I, type JsonNode as J, SharedState as K, StateManager$1 as L, type Middleware as M, createDevServer as N, type Props as P, type RefCallback as R, type StateOptions as S, type VNode as V, type WorkerConfig as W, type Child as a, type State as b, type VirtualListController as c, type VNodeJson as d, type RefObject as e, type StateManager as f, type ClientConfig as g, type ProxyConfig as h, type DevServer as i, type BuildResult as j, type PreviewOptions as k, type HttpMethod as l, type ServerRouteContext as m, type ServerRouteHandler as n, ServerRouter as o, json as p, html as q, cors as r, status as s, text as t, logger as u, errorHandler as v, rateLimit as w, bodyLimit as x, cacheControl as y, compress as z };