@barocss/server 0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 jinho park(cyberuls@gmail.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,280 @@
1
+ # @barocss/server
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@barocss/server.svg)](https://www.npmjs.com/package/@barocss/server)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-blue.svg)](https://www.typescriptlang.org/)
6
+
7
+ **Server Runtime** - Server-side CSS generation and processing
8
+
9
+ @barocss/server provides server-side utilities for parsing Tailwind classes and generating CSS without browser-specific features. Perfect for SSR, static site generation, and server-side CSS processing.
10
+
11
+ ## ✨ Key Features
12
+
13
+ - **🚀 Server-Side CSS Generation** - Generate CSS on the server without browser APIs
14
+ - **⚡ Batch Processing** - Process multiple classes efficiently
15
+ - **📱 SSR Support** - Perfect for server-side rendering scenarios
16
+ - **🎯 Static Generation** - Generate CSS for static sites and build processes
17
+ - **🌐 Node.js Optimized** - Designed specifically for Node.js environments
18
+
19
+ ## 🚀 Quick Start
20
+
21
+ ### NPM Installation
22
+
23
+ ```bash
24
+ # npm
25
+ npm install @barocss/server
26
+
27
+ # pnpm
28
+ pnpm add @barocss/server
29
+
30
+ # yarn
31
+ yarn add @barocss/server
32
+ ```
33
+
34
+ ### Basic Usage
35
+
36
+ ```typescript
37
+ import { ServerRuntime } from '@barocss/server';
38
+
39
+ // Initialize server runtime
40
+ const runtime = new ServerRuntime();
41
+
42
+ // Generate CSS for a single class
43
+ const css = runtime.generateCss('bg-blue-500 text-white p-4');
44
+ console.log(css);
45
+ // Output: .bg-blue-500 { background-color: #3b82f6; }
46
+ // .text-white { color: #ffffff; }
47
+ // .p-4 { padding: 1rem; }
48
+ ```
49
+
50
+ ### Batch Processing
51
+
52
+ ```typescript
53
+ import { ServerRuntime } from '@barocss/server';
54
+
55
+ const runtime = new ServerRuntime();
56
+
57
+ // Process multiple classes at once
58
+ const classes = [
59
+ 'bg-blue-500',
60
+ 'text-white',
61
+ 'p-4',
62
+ 'rounded-lg',
63
+ 'shadow-md'
64
+ ];
65
+
66
+ const results = runtime.generateCssForClasses(classes);
67
+ results.forEach(({ className, css }) => {
68
+ console.log(`${className}: ${css}`);
69
+ });
70
+ ```
71
+
72
+ ## 🎯 How It Works
73
+
74
+ The server runtime provides server-side CSS generation:
75
+
76
+ 1. **Class Parsing** - Parses Tailwind classes using @barocss/kit
77
+ 2. **CSS Generation** - Generates CSS rules without browser dependencies
78
+ 3. **Batch Processing** - Efficiently processes multiple classes
79
+ 4. **Static Output** - Returns CSS strings ready for server use
80
+
81
+ ```typescript
82
+ import { ServerRuntime } from '@barocss/server';
83
+
84
+ const runtime = new ServerRuntime();
85
+
86
+ // Parse and generate CSS
87
+ const css = runtime.generateCss('bg-red-500 hover:bg-red-600 text-white p-4');
88
+
89
+ // Result:
90
+ // .bg-red-500 { background-color: #ef4444; }
91
+ // .hover\:bg-red-600:hover { background-color: #dc2626; }
92
+ // .text-white { color: #ffffff; }
93
+ // .p-4 { padding: 1rem; }
94
+ ```
95
+
96
+ ## 🛠️ Usage Examples
97
+
98
+ ### Basic Server Usage
99
+
100
+ ```typescript
101
+ import { ServerRuntime } from '@barocss/server';
102
+
103
+ const runtime = new ServerRuntime({
104
+ theme: {
105
+ extend: {
106
+ colors: {
107
+ 'brand': {
108
+ 500: '#0ea5e9',
109
+ 600: '#0284c7'
110
+ }
111
+ }
112
+ }
113
+ }
114
+ });
115
+
116
+ // Generate CSS for specific classes
117
+ const css = runtime.generateCss('bg-brand-500 text-white p-4');
118
+ console.log(css);
119
+ ```
120
+
121
+ ### Processing Multiple Classes
122
+
123
+ ```typescript
124
+ import { ServerRuntime } from '@barocss/server';
125
+
126
+ const runtime = new ServerRuntime();
127
+
128
+ // Process a list of classes
129
+ const classes = [
130
+ 'bg-blue-500',
131
+ 'text-white',
132
+ 'p-4',
133
+ 'rounded-lg',
134
+ 'shadow-md'
135
+ ];
136
+
137
+ const results = runtime.generateCssForClasses(classes);
138
+ results.forEach(({ className, css }) => {
139
+ console.log(`${className}: ${css}`);
140
+ });
141
+ ```
142
+
143
+ ## 🔧 Configuration
144
+
145
+ ### Server Runtime Options
146
+
147
+ ```typescript
148
+ import { ServerRuntime } from '@barocss/server';
149
+
150
+ const runtime = new ServerRuntime({
151
+ theme: {
152
+ extend: {
153
+ colors: {
154
+ 'brand': {
155
+ 50: '#f0f9ff',
156
+ 500: '#0ea5e9',
157
+ 900: '#0c4a6e',
158
+ }
159
+ },
160
+ spacing: {
161
+ '18': '4.5rem',
162
+ '88': '22rem',
163
+ }
164
+ }
165
+ },
166
+ darkMode: 'class',
167
+ cssVarPrefix: '--baro-'
168
+ });
169
+ ```
170
+
171
+ ### Custom Theme Functions
172
+
173
+ ```typescript
174
+ const runtime = new ServerRuntime({
175
+ theme: {
176
+ spacing: (theme) => ({
177
+ ...theme('spacing'),
178
+ '18': '4.5rem',
179
+ '88': '22rem',
180
+ }),
181
+ colors: (theme) => ({
182
+ ...theme('colors'),
183
+ 'brand': {
184
+ 500: '#0ea5e9',
185
+ 600: '#0284c7'
186
+ }
187
+ })
188
+ }
189
+ });
190
+ ```
191
+
192
+ ## 🌐 API Reference
193
+
194
+ ### ServerRuntime
195
+
196
+ ```typescript
197
+ class ServerRuntime {
198
+ constructor(config?: Config)
199
+
200
+ // Parse a class name and return its AST
201
+ parseClass(className: string): AstNode[]
202
+
203
+ // Generate CSS for a single class
204
+ generateCss(className: string): string
205
+
206
+ // Generate CSS for multiple classes
207
+ generateCssForClasses(classes: string[]): Array<{
208
+ className: string;
209
+ css: string;
210
+ }>
211
+ }
212
+ ```
213
+
214
+ ### Usage Examples
215
+
216
+ ```typescript
217
+ import { ServerRuntime } from '@barocss/server';
218
+
219
+ const runtime = new ServerRuntime();
220
+
221
+ // Parse class to AST
222
+ const ast = runtime.parseClass('bg-blue-500 hover:bg-blue-600');
223
+ console.log(ast);
224
+
225
+ // Generate CSS for single class
226
+ const css = runtime.generateCss('bg-blue-500 text-white p-4');
227
+ console.log(css);
228
+
229
+ // Generate CSS for multiple classes
230
+ const results = runtime.generateCssForClasses([
231
+ 'bg-blue-500',
232
+ 'text-white',
233
+ 'p-4'
234
+ ]);
235
+ console.log(results);
236
+ ```
237
+
238
+ ## 🚀 Performance Features
239
+
240
+ - **Batch Processing** - Efficiently processes multiple classes
241
+ - **Memory Optimization** - Optimized for server environments
242
+ - **Static Generation** - Perfect for build-time CSS generation
243
+ - **No Browser Dependencies** - Runs entirely in Node.js
244
+
245
+ ## 🤝 Contributing
246
+
247
+ We welcome contributions! Please see our [Contributing Guide](../../CONTRIBUTING.md) for details.
248
+
249
+ ### Development
250
+
251
+ ```bash
252
+ # Clone repository
253
+ git clone https://github.com/easylogic/barocss.git
254
+ cd barocss
255
+
256
+ # Install dependencies
257
+ pnpm install
258
+
259
+ # Start development server
260
+ pnpm dev
261
+
262
+ # Run tests
263
+ pnpm test
264
+
265
+ # Build packages
266
+ pnpm build
267
+ ```
268
+
269
+ ## 📄 License
270
+
271
+ This project is licensed under the MIT License - see the [LICENSE](../../LICENSE) file for details.
272
+
273
+ ## 🙏 Acknowledgments
274
+
275
+ - **Tailwind CSS** - For the amazing utility-first approach and JIT inspiration
276
+ - **UnoCSS** - For ideas around on-demand, utility-first generation at runtime
277
+
278
+ ---
279
+
280
+ **@barocss/server** - Server-side CSS generation and processing.
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@barocss/kit");class n{constructor(e={}){this.context=s.createContext(e)}parseClass(e){return s.parseClassToAst(e,this.context)}generateCss(e){return s.generateCssRules(e,this.context)[0].css}generateCssForClasses(e){return e.map(t=>({className:t,css:this.generateCss(t)}))}}exports.ServerRuntime=n;
@@ -0,0 +1,26 @@
1
+ import { Config } from '@barocss/kit';
2
+ /**
3
+ * Server-side runtime for Barocss
4
+ *
5
+ * This provides server-side utilities for parsing classes and generating CSS
6
+ * without browser-specific features like DOM manipulation or MutationObserver.
7
+ */
8
+ export declare class ServerRuntime {
9
+ private context;
10
+ constructor(config?: Config);
11
+ /**
12
+ * Parse a class name and return its AST
13
+ */
14
+ parseClass(className: string): import('@barocss/kit').AstNode[];
15
+ /**
16
+ * Generate CSS for a class name
17
+ */
18
+ generateCss(className: string): string;
19
+ /**
20
+ * Parse multiple classes and return their CSS
21
+ */
22
+ generateCssForClasses(classes: string[]): {
23
+ className: string;
24
+ css: string;
25
+ }[];
26
+ }
@@ -0,0 +1,30 @@
1
+ import { createContext as r, parseClassToAst as n, generateCssRules as o } from "@barocss/kit";
2
+ class u {
3
+ constructor(s = {}) {
4
+ this.context = r(s);
5
+ }
6
+ /**
7
+ * Parse a class name and return its AST
8
+ */
9
+ parseClass(s) {
10
+ return n(s, this.context);
11
+ }
12
+ /**
13
+ * Generate CSS for a class name
14
+ */
15
+ generateCss(s) {
16
+ return o(s, this.context)[0].css;
17
+ }
18
+ /**
19
+ * Parse multiple classes and return their CSS
20
+ */
21
+ generateCssForClasses(s) {
22
+ return s.map((e) => ({
23
+ className: e,
24
+ css: this.generateCss(e)
25
+ }));
26
+ }
27
+ }
28
+ export {
29
+ u as ServerRuntime
30
+ };
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@barocss/server",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "main": "./dist/index.cjs.js",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.es.js",
11
+ "require": "./dist/index.cjs.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist/**/*",
16
+ "README.md",
17
+ "LICENSE"
18
+ ],
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "dependencies": {
23
+ "jsdom": "^26.1.0",
24
+ "@barocss/kit": "0.0.2"
25
+ },
26
+ "devDependencies": {
27
+ "vite": "^7.1.3",
28
+ "vite-plugin-dts": "^4.5.4",
29
+ "vitest": "^3.2.4"
30
+ },
31
+ "scripts": {
32
+ "build": "vite build",
33
+ "build:library": "pnpm run build",
34
+ "test:watch": "vitest",
35
+ "//test": "vitest run",
36
+ "type-check": "tsc --noEmit",
37
+ "lint": "eslint src/**/*.ts"
38
+ },
39
+ "module": "./dist/index.es.js"
40
+ }