stylpp 1.0.0
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 +475 -0
- package/bin/stylpp.js +2 -0
- package/dist/stylpp.esm.js +726 -0
- package/dist/stylpp.esm.js.map +1 -0
- package/dist/stylpp.js +734 -0
- package/dist/stylpp.js.map +1 -0
- package/dist/stylpp.min.js +2 -0
- package/dist/stylpp.min.js.map +1 -0
- package/package.json +59 -0
- package/src/cli/index.js +400 -0
- package/src/compiler/animation.js +346 -0
- package/src/compiler/effects.js +344 -0
- package/src/compiler/generator.js +157 -0
- package/src/compiler/index.js +119 -0
- package/src/compiler/parser.js +210 -0
- package/src/compiler/physics.js +286 -0
- package/src/compiler/transformer.js +228 -0
- package/src/runtime/advanced.js +293 -0
- package/src/runtime/browser.js +239 -0
- package/stylpp-1.0.0.tgz +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
# STYL++ - A Revolutionary Styling Language
|
|
2
|
+
|
|
3
|
+
Welcome to STYL++ - a modern CSS preprocessor with an elegant, semicolon-based syntax that's intuitive, concise, and powerful.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
✨ **Semicolon-Based Syntax** - Elegant indentation using leading semicolons
|
|
8
|
+
📦 **Variables** - Define reusable values across your styles
|
|
9
|
+
🔢 **Math Operations** - `width 100% - 40px;` → `calc(100% - 40px)`
|
|
10
|
+
🔄 **Loops** - Generate multiple rules with `for` loops
|
|
11
|
+
🎯 **Conditionals** - Responsive breakpoints and theme support with `@mobile`, `@dark`, etc.
|
|
12
|
+
🎨 **Nested Selectors** - Clean, hierarchical styling
|
|
13
|
+
⚡ **Zero Config** - Works out of the box
|
|
14
|
+
🌐 **Multiple Outputs** - Node.js, Browser, VS Code Extension, CLI
|
|
15
|
+
🎁 **Vendor Prefixes** - Automatic browser compatibility
|
|
16
|
+
📱 **Responsive Helpers** - `responsive()` and `fluid()` functions
|
|
17
|
+
|
|
18
|
+
### Advanced Physics-Based Features (Transcends CSS)
|
|
19
|
+
|
|
20
|
+
🔬 **Physics Engine** - Real Verlet integration for physics-based layouts
|
|
21
|
+
🎬 **Advanced Animations** - 16+ easing functions + timeline support
|
|
22
|
+
🎯 **Spring Constraints** - Natural physics-based element positioning
|
|
23
|
+
🌀 **3D Transforms** - Full matrix3d support beyond CSS
|
|
24
|
+
✨ **Particle Systems** - Generate particle effects programmatically
|
|
25
|
+
🎨 **Advanced Filters** - Glassmorphism, neumorphism, glow effects
|
|
26
|
+
🚀 **Performance** - 60 FPS physics simulation engine
|
|
27
|
+
|
|
28
|
+
## Quick Start
|
|
29
|
+
|
|
30
|
+
### Installation
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install -g stylpp
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Create a STYL++ File
|
|
37
|
+
|
|
38
|
+
Create `style.stylpp`:
|
|
39
|
+
|
|
40
|
+
```stylpp
|
|
41
|
+
variables;
|
|
42
|
+
primary #007bff;
|
|
43
|
+
spacing 16px;
|
|
44
|
+
|
|
45
|
+
body;
|
|
46
|
+
font-family system-ui;
|
|
47
|
+
background white;
|
|
48
|
+
|
|
49
|
+
.container;
|
|
50
|
+
max-width 1200px;
|
|
51
|
+
margin 0 auto;
|
|
52
|
+
padding var(spacing);
|
|
53
|
+
|
|
54
|
+
h1;
|
|
55
|
+
color var(primary);
|
|
56
|
+
font-size 32px;
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Compile to CSS
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
stylpp compile style.stylpp style.css
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
This generates:
|
|
66
|
+
|
|
67
|
+
```css
|
|
68
|
+
body {
|
|
69
|
+
font-family: system-ui;
|
|
70
|
+
background: white;
|
|
71
|
+
}
|
|
72
|
+
body .container {
|
|
73
|
+
max-width: 1200px;
|
|
74
|
+
margin: 0 auto;
|
|
75
|
+
padding: 16px;
|
|
76
|
+
}
|
|
77
|
+
body .container h1 {
|
|
78
|
+
color: #007bff;
|
|
79
|
+
font-size: 32px;
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Core Syntax
|
|
84
|
+
|
|
85
|
+
### 1. Semicolon-Based Indentation
|
|
86
|
+
|
|
87
|
+
Every line ends with a semicolon. Indentation is represented by leading semicolons:
|
|
88
|
+
|
|
89
|
+
```stylpp
|
|
90
|
+
; No semicolon means this is a comment
|
|
91
|
+
|
|
92
|
+
body;
|
|
93
|
+
background white;
|
|
94
|
+
|
|
95
|
+
; One semicolon = one indent level
|
|
96
|
+
p;
|
|
97
|
+
color red;
|
|
98
|
+
|
|
99
|
+
; Two semicolons = two indent levels
|
|
100
|
+
span;
|
|
101
|
+
font-weight bold;
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### 2. Variables
|
|
105
|
+
|
|
106
|
+
Define variables in the `variables` section:
|
|
107
|
+
|
|
108
|
+
```stylpp
|
|
109
|
+
variables;
|
|
110
|
+
primary #007bff;
|
|
111
|
+
secondary #6c757d;
|
|
112
|
+
spacing 16px;
|
|
113
|
+
radius 4px;
|
|
114
|
+
|
|
115
|
+
.button;
|
|
116
|
+
background var(primary);
|
|
117
|
+
padding var(spacing);
|
|
118
|
+
border-radius var(radius);
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### 3. Math Operations
|
|
122
|
+
|
|
123
|
+
Values with mathematical expressions are automatically wrapped in `calc()`:
|
|
124
|
+
|
|
125
|
+
```stylpp
|
|
126
|
+
.container;
|
|
127
|
+
width 100% - 40px;
|
|
128
|
+
height 300px + 50px;
|
|
129
|
+
padding var(spacing) * 2;
|
|
130
|
+
margin-left 50px / 2;
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### 4. Nested Selectors
|
|
134
|
+
|
|
135
|
+
Create hierarchical CSS with natural nesting:
|
|
136
|
+
|
|
137
|
+
```stylpp
|
|
138
|
+
.card;
|
|
139
|
+
background white;
|
|
140
|
+
padding 16px;
|
|
141
|
+
|
|
142
|
+
.card-header;
|
|
143
|
+
font-size 20px;
|
|
144
|
+
font-weight bold;
|
|
145
|
+
|
|
146
|
+
.card-body;
|
|
147
|
+
line-height 1.6;
|
|
148
|
+
|
|
149
|
+
p;
|
|
150
|
+
margin 0 0 16px 0;
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### 5. For Loops
|
|
154
|
+
|
|
155
|
+
Generate repetitive rules:
|
|
156
|
+
|
|
157
|
+
```stylpp
|
|
158
|
+
for i in 1 to 5;
|
|
159
|
+
.column-{i};
|
|
160
|
+
width calc(100% / 5 * i);
|
|
161
|
+
margin-bottom 16px;
|
|
162
|
+
|
|
163
|
+
for size in small, medium, large;
|
|
164
|
+
.text-{size};
|
|
165
|
+
font-size var({size}-font-size);
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### 6. Conditionals and Media Queries
|
|
169
|
+
|
|
170
|
+
Handle responsive design and themes:
|
|
171
|
+
|
|
172
|
+
```stylpp
|
|
173
|
+
.container;
|
|
174
|
+
width 100%;
|
|
175
|
+
|
|
176
|
+
@mobile;
|
|
177
|
+
width 100%;
|
|
178
|
+
padding 8px;
|
|
179
|
+
|
|
180
|
+
@tablet;
|
|
181
|
+
width 100%;
|
|
182
|
+
padding 12px;
|
|
183
|
+
|
|
184
|
+
@desktop;
|
|
185
|
+
max-width 1200px;
|
|
186
|
+
margin 0 auto;
|
|
187
|
+
|
|
188
|
+
@dark;
|
|
189
|
+
background #1e1e1e;
|
|
190
|
+
color white;
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### 7. Responsive Helpers
|
|
194
|
+
|
|
195
|
+
Built-in responsive sizing:
|
|
196
|
+
|
|
197
|
+
```stylpp
|
|
198
|
+
.container;
|
|
199
|
+
width responsive(300px, 1200px);
|
|
200
|
+
|
|
201
|
+
; Becomes: clamp(300px, 50vw + 100px, 1200px)
|
|
202
|
+
|
|
203
|
+
.title;
|
|
204
|
+
font-size fluid(16px, 32px);
|
|
205
|
+
|
|
206
|
+
; Becomes: clamp(16px, 5vw, 32px)
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## Command Line Interface
|
|
210
|
+
|
|
211
|
+
### Compile a File
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
stylpp compile input.stylpp output.css
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Watch for Changes
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
stylpp watch src/ dist/
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Start Development Server
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
stylpp serve --port 3000
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
The dev server provides:
|
|
230
|
+
- Live reloading of `.stylpp` files
|
|
231
|
+
- Automatic compilation
|
|
232
|
+
- WebSocket support for hot module replacement
|
|
233
|
+
|
|
234
|
+
### Lint Your Code
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
stylpp lint **/*.stylpp
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### Format Your Code
|
|
241
|
+
|
|
242
|
+
```bash
|
|
243
|
+
stylpp format **/*.stylpp
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## VS Code Integration
|
|
247
|
+
|
|
248
|
+
Install the STYL++ VS Code extension for:
|
|
249
|
+
|
|
250
|
+
✓ Syntax highlighting
|
|
251
|
+
✓ IntelliSense and code completion
|
|
252
|
+
✓ Format on save
|
|
253
|
+
✓ Compile on save
|
|
254
|
+
✓ Error highlighting
|
|
255
|
+
✓ Snippets
|
|
256
|
+
✓ Go to definition
|
|
257
|
+
|
|
258
|
+
### Keyboard Shortcuts
|
|
259
|
+
|
|
260
|
+
| Shortcut | Command |
|
|
261
|
+
|----------|---------|
|
|
262
|
+
| `Ctrl+Shift+B` (or `Cmd+Shift+B` on Mac) | Compile current file |
|
|
263
|
+
| `Ctrl+K Ctrl+F` | Format document |
|
|
264
|
+
|
|
265
|
+
### Configuration
|
|
266
|
+
|
|
267
|
+
In VS Code settings:
|
|
268
|
+
|
|
269
|
+
```json
|
|
270
|
+
{
|
|
271
|
+
"stylpp.minify": false,
|
|
272
|
+
"stylpp.sourceMap": true,
|
|
273
|
+
"stylpp.vendorPrefix": true,
|
|
274
|
+
"stylpp.formatOnSave": true,
|
|
275
|
+
"stylpp.autoCompile": false,
|
|
276
|
+
"stylpp.outputPath": "dist/"
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
## Browser Usage
|
|
281
|
+
|
|
282
|
+
Include STYL++ in the browser:
|
|
283
|
+
|
|
284
|
+
```html
|
|
285
|
+
<!DOCTYPE html>
|
|
286
|
+
<html>
|
|
287
|
+
<head>
|
|
288
|
+
<script src="stylpp.min.js"></script>
|
|
289
|
+
</head>
|
|
290
|
+
<body>
|
|
291
|
+
<style type="text/stylpp">
|
|
292
|
+
variables;
|
|
293
|
+
primary #007bff;
|
|
294
|
+
|
|
295
|
+
body;
|
|
296
|
+
background var(primary);
|
|
297
|
+
color white;
|
|
298
|
+
</style>
|
|
299
|
+
</body>
|
|
300
|
+
</html>
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
Or compile programmatically:
|
|
304
|
+
|
|
305
|
+
```javascript
|
|
306
|
+
const StylppRuntime = require('stylpp/runtime');
|
|
307
|
+
const runtime = new StylppRuntime();
|
|
308
|
+
|
|
309
|
+
const result = runtime.compile(`
|
|
310
|
+
body;
|
|
311
|
+
background blue;
|
|
312
|
+
`);
|
|
313
|
+
|
|
314
|
+
console.log(result.css);
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
## Programmatic API
|
|
318
|
+
|
|
319
|
+
### Node.js
|
|
320
|
+
|
|
321
|
+
```javascript
|
|
322
|
+
const StylppCompiler = require('stylpp');
|
|
323
|
+
|
|
324
|
+
const compiler = new StylppCompiler({
|
|
325
|
+
minify: false,
|
|
326
|
+
sourceMap: true,
|
|
327
|
+
vendorPrefix: true
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
const code = `
|
|
331
|
+
variables;
|
|
332
|
+
primary #007bff;
|
|
333
|
+
|
|
334
|
+
body;
|
|
335
|
+
color var(primary);
|
|
336
|
+
`;
|
|
337
|
+
|
|
338
|
+
const result = compiler.compile(code);
|
|
339
|
+
|
|
340
|
+
if (result.success) {
|
|
341
|
+
console.log(result.css);
|
|
342
|
+
} else {
|
|
343
|
+
console.error(result.errors);
|
|
344
|
+
}
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
### Browser
|
|
348
|
+
|
|
349
|
+
```javascript
|
|
350
|
+
const runtime = new StylppRuntime({
|
|
351
|
+
hotReload: true,
|
|
352
|
+
autoCompile: true,
|
|
353
|
+
showErrors: true
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
const result = runtime.compile(`
|
|
357
|
+
.button;
|
|
358
|
+
background blue;
|
|
359
|
+
color white;
|
|
360
|
+
`, 'my-styles');
|
|
361
|
+
|
|
362
|
+
console.log(result.css);
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
## Examples
|
|
366
|
+
|
|
367
|
+
Check the `examples/` directory for complete working examples:
|
|
368
|
+
|
|
369
|
+
- `minimal.stylpp` - Basic introduction
|
|
370
|
+
- `dashboard.stylpp` - Complex real-world dashboard with loops, conditionals, and variables
|
|
371
|
+
|
|
372
|
+
## Performance
|
|
373
|
+
|
|
374
|
+
Compilation times:
|
|
375
|
+
|
|
376
|
+
- Small files (< 100 lines): < 10ms
|
|
377
|
+
- Medium files (< 1000 lines): < 100ms
|
|
378
|
+
- Large files (< 10000 lines): < 1000ms
|
|
379
|
+
|
|
380
|
+
Bundle sizes:
|
|
381
|
+
|
|
382
|
+
- Runtime only: < 10KB gzipped
|
|
383
|
+
- Full compiler: < 50KB gzipped
|
|
384
|
+
- VS Code extension: < 5MB
|
|
385
|
+
|
|
386
|
+
## Error Messages
|
|
387
|
+
|
|
388
|
+
STYL++ provides helpful error messages with line numbers:
|
|
389
|
+
|
|
390
|
+
```
|
|
391
|
+
Error: Missing closing selector on line 10
|
|
392
|
+
Expected ';' at end of selector
|
|
393
|
+
.button {
|
|
394
|
+
^
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
## Troubleshooting
|
|
398
|
+
|
|
399
|
+
### Issue: "stylpp command not found"
|
|
400
|
+
|
|
401
|
+
Solution: Install globally
|
|
402
|
+
|
|
403
|
+
```bash
|
|
404
|
+
npm install -g stylpp
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
### Issue: VS Code extension not working
|
|
408
|
+
|
|
409
|
+
Solution: Reload VS Code or reinstall the extension
|
|
410
|
+
|
|
411
|
+
```bash
|
|
412
|
+
code --install-extension path/to/stylpp-1.0.0.vsix
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
### Issue: Weird CSS output
|
|
416
|
+
|
|
417
|
+
Solution: Check that:
|
|
418
|
+
1. Every line ends with `;`
|
|
419
|
+
2. Leading semicolons match indent level
|
|
420
|
+
3. Variables are defined in `variables;` section
|
|
421
|
+
|
|
422
|
+
## Advanced Features: Physics & Effects
|
|
423
|
+
|
|
424
|
+
STYL++ transcends CSS limitations with:
|
|
425
|
+
|
|
426
|
+
### ⚛️ Physics Engine
|
|
427
|
+
- Real Verlet integration physics simulation
|
|
428
|
+
- Spring and rod constraints for natural layouts
|
|
429
|
+
- Gravity, damping, and friction
|
|
430
|
+
- 60 FPS performance
|
|
431
|
+
|
|
432
|
+
### 🎬 Advanced Animations
|
|
433
|
+
- 16+ built-in easing functions (elastic, bounce, expo, etc.)
|
|
434
|
+
- Animation timelines with keyframe sequences
|
|
435
|
+
- Cubic-bezier support
|
|
436
|
+
- Physics-based spring animations
|
|
437
|
+
|
|
438
|
+
### 🌀 3D Transforms
|
|
439
|
+
- Full matrix3d support
|
|
440
|
+
- Perspective and depth
|
|
441
|
+
- 3D rotation on all axes
|
|
442
|
+
- Advanced effects (glassmorphism, neumorphism, glow)
|
|
443
|
+
|
|
444
|
+
### ✨ Particle Systems
|
|
445
|
+
- Programmable particle generation
|
|
446
|
+
- Physics-based particle behavior
|
|
447
|
+
- Fade and scale effects
|
|
448
|
+
- Custom colors and sizes
|
|
449
|
+
|
|
450
|
+
### 📱 Responsive Physics
|
|
451
|
+
- Fluid sizing with `responsive()` function
|
|
452
|
+
- Adaptive layouts with spring constraints
|
|
453
|
+
- Mobile-first physics simulation
|
|
454
|
+
- Media query integration
|
|
455
|
+
|
|
456
|
+
**See [Advanced Features Guide](docs/ADVANCED_FEATURES.md) for complete documentation and examples.**
|
|
457
|
+
|
|
458
|
+
## Contributing
|
|
459
|
+
|
|
460
|
+
Contributions welcome! Please submit pull requests to the [GitHub repository](https://github.com/Francis589-png/STYLPP).
|
|
461
|
+
|
|
462
|
+
## License
|
|
463
|
+
|
|
464
|
+
MIT License - See LICENSE file for details
|
|
465
|
+
|
|
466
|
+
## Support
|
|
467
|
+
|
|
468
|
+
- 📖 [Documentation](https://github.com/Francis589-png/STYLPP/docs)
|
|
469
|
+
- 🐛 [Issue Tracker](https://github.com/Francis589-png/STYLPPp/issues)
|
|
470
|
+
- 💬 [Discussions](https://github.com/Francis589-png/STYLPP/discussions)
|
|
471
|
+
|
|
472
|
+
---
|
|
473
|
+
|
|
474
|
+
Made with ❤️ for web developers everywhere.
|
|
475
|
+
BY FRANCIS JUSU
|
package/bin/stylpp.js
ADDED