fscss 1.1.10 → 1.1.12

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 CHANGED
@@ -5,59 +5,104 @@ It works both in the browser and on the backend (Node.js).
5
5
 
6
6
  ---
7
7
 
8
- 🚀 Installation
9
8
 
10
- `npm install -g fscss`
11
9
 
12
- Or locally to your project:
10
+ ## Features
13
11
 
14
- `npm install fscss`
12
+ Works in browser and backend (Node.js)
13
+
14
+ Supports:
15
15
 
16
+ - Variables ($var, str()) → define reusable values
16
17
 
17
- ---
18
+ - Style Replacement (%n()) → shorthand repeated properties
19
+ - Repeat Function (rpt()) → repeat values quickly
18
20
 
21
+ - Copy Function (copy()) → copy parts of values
19
22
 
23
+ - String Extractor (@ext()) → extract substrings from values
20
24
 
21
- ## Features
25
+ - Drops / Shared Properties → reuse style groups
22
26
 
23
- Works in browser and backend (Node.js)
27
+ - Attribute Selectors dynamic selectors
24
28
 
25
- Supports:
29
+ - Keyframes ($(@keyframes …)) → generate animations easily
30
+
31
+ - Vendor Prefixing (-*) → auto add prefixes
26
32
 
27
- - `@import(exec(...))` inline imports
33
+ - Function-based (@fun) reusable function-like blocks
28
34
 
29
- - Variables
35
+ - Array Methods (@arr) → define & loop arrays
30
36
 
31
- - Functions
37
+ - Random Function (@random()) → random values at runtime
32
38
 
33
- - Arrays
34
-
35
- - replace
36
-
37
- - Random values (random)
39
+ - Number Calculation (num()) → evaluate math expressions
38
40
 
39
- - Copy (copy)
41
+ - Import (@import) → include external FSCSS files
40
42
 
41
- - Number operations (num)
43
+ - @event event-based styling logic
42
44
 
43
- - Extract string (ext)
45
+ - exec() debugging and runtime helpers
46
+
47
+ - Variable fallback chain (property: $/var || fallback;)
44
48
 
45
- - Event bindings (event)
46
-
47
- - count(number)
48
49
 
49
- - length(string)
50
+ ### Example
51
+ ```css
52
+ /* FSCSS, Animation compact */
53
+ $(@keyframes trans, .box .card &[3s ease-in infinite]) {
54
+ from {
55
+ %2(width, height [: 0;])
56
+ background: red;
57
+ }
58
+ to {
59
+ %2(width, height [: 200px;])
60
+ background: blue;
61
+ }
62
+ }
63
+ ```
50
64
 
51
- - Debug helpers (debug)
65
+ ### 📦 Installation
66
+
67
+ `npm install -g fscss`
68
+
69
+ Or locally to your project:
70
+
71
+ `npm install fscss`
72
+
73
+ **CDN**
74
+ ```html
75
+ <script src="https://cdn.jsdelivr.net/npm/fscss@1.1.12/exec.min.js" defer></script>
76
+ ```
77
+ Usage
78
+
79
+ Link FSCSS files directly:
80
+ ```html
81
+ <link type="text/fscss" href="style.fscss">
82
+ ```
83
+ Or import inside a style block:
84
+ ```html
85
+ <style>
86
+ @import(exec(style.fscss))
87
+ </style>
88
+ ```
89
+ **⚡ Async or defer is required for script loading.**
90
+
91
+
92
+ ---
52
93
 
53
94
 
54
95
  Transform shorthand syntax into valid CSS
55
96
 
56
97
  Extensible with plugins
57
98
 
99
+ ---
58
100
 
101
+ ### https://fscss.devtem.org/
102
+ ### https://opencollective.com/fscss
59
103
 
104
+ ---
60
105
 
61
106
  📜 License
62
107
 
63
- MIT © 2025 Figsh—FSCSS
108
+ MIT © Figsh—FSCSS
package/bin/fscss.js CHANGED
File without changes
@@ -917,6 +917,43 @@ function escapeRegExp(string) {
917
917
  return string.replace(/[.*+?^${}|[\]\\]/g, '\\$&');
918
918
  }
919
919
 
920
+ /* Variable fallback chain */
921
+ function vfc(fscss){
922
+ fscss = fscss.replace(
923
+ /([\w-]+:\s*)(\$\/?[\w-]+!?)(\s*\|\|\s*([^\n\};]+))?/g,
924
+ (match, pr, variable, fallbackPart, fallback) => {
925
+
926
+ // Invalid variable format
927
+ if (!/^\$\/[\w-]+!?$/.test(variable)) {
928
+ console.warn(`fscss[VFC]: Invalid variable escape syntax -> ${variable} at ${match}`);
929
+ return match;
930
+ }
931
+
932
+ // Required variable but has fallback
933
+ if (variable.endsWith("!") && fallback) {
934
+ console.warn(`fscss[VFC]: Required variable "${variable}" should not have fallback (${fallback})`);
935
+ }
936
+
937
+ // Fallback starts with ||
938
+ if (fallbackPart && !fallback?.trim()) {
939
+ console.warn(`fscss[VFC]: Empty fallback in -> ${match}`);
940
+ return match;
941
+ }
942
+
943
+ // Invalid fallback variable syntax
944
+ if (fallback?.includes("$/") && !/^\$\/[\w-]+!?$/.test(fallback.trim())) {
945
+ console.warn(`fscss[VFC]: Invalid fallback variable syntax -> ${fallback}`);
946
+ }
947
+
948
+ // Compile logic
949
+ if (fallback) {
950
+ return `${pr}${fallback.trim()};${pr}${variable}`;
951
+ }
952
+
953
+ return `${pr}${variable}`;
954
+ })
955
+ return fscss;
956
+ }
920
957
 
921
958
  // Applies all FSCSS transformations to CSS content
922
959
  function applyFscssTransformations(css) {
@@ -1074,6 +1111,6 @@ function execObj(css){
1074
1111
  }
1075
1112
 
1076
1113
  export { initlibraries,
1077
- impSel, procImp, replaceRe, procExt, procVar,procFun, procArr, procEv, procRan, transformCssValues, procNum,applyFscssTransformations,procExC, procCnt, procChe, execObj
1114
+ impSel, procImp, replaceRe, procExt, procVar,procFun, procArr, procEv, procRan, transformCssValues, procNum, vfc, applyFscssTransformations,procExC, procCnt, procChe, execObj
1078
1115
  }
1079
1116
 
@@ -37,7 +37,7 @@ export async function procImp(css, { inputDir }) {
37
37
  }
38
38
  importedContent = fs.readFileSync(absPath, "utf8");
39
39
 
40
- // 🔁 recursive support (nested imports)
40
+ // recursive support (nested imports)
41
41
  importedContent = await procImp(importedContent, {
42
42
  inputDir: path.dirname(absPath),
43
43
  });
package/lib/processor.js CHANGED
@@ -10,6 +10,7 @@ import {
10
10
  procRan,
11
11
  transformCssValues,
12
12
  procNum,
13
+ vfc,
13
14
  applyFscssTransformations,
14
15
  procExC,
15
16
  procCnt,
@@ -18,14 +19,17 @@ import {
18
19
  } from "./functions/all.js";
19
20
  import { procImp } from "./functions/procImp.js";
20
21
  import { impSel } from "./functions/impSel.js";
21
- export async function processFscss(css, options = {}){
22
+ export async function processFscss(css, options = {}) {
22
23
  const { inputDir = process.cwd() } = options;
23
24
 
24
25
  if (!css.includes("exec.obj.block(all)")) {
25
26
  if(!css.includes("exec.obj.block(init lab)"))css = initlibraries(css);
26
- if(!css.includes("exec.obj.block(f import)")||!css.includes("exec.obj.block(f import pick)")){css = await impSel(css, {inputDir})};
27
- if(!css.includes("exec.obj.block(f import)")){css = await procImp(css, {inputDir});}
28
-
27
+ if(!css.includes("exec.obj.block(f import)")||!css.includes("exec.obj.block(f import pick)")){css = await impSel(css, {inputDir});}
28
+ if(!css.includes("exec.obj.block(f import)")){css = await procImp(css, {inputDir});}
29
+ if(!css.includes("exec.obj.block(init lab)")||css.includes("exec.obj.block(exInit lab)"))css = initlibraries(css);
30
+ if(!css.includes("exec.obj.block(f import)")||!css.includes("exec.obj.block(f import pick)")){css = await impSel(css, {inputDir});}
31
+ if(!css.includes("exec.obj.block(f import)")){css = await procImp(css, {inputDir});}
32
+ if(!css.includes("exec.obj.block(vfc)")) css = vfc(css);
29
33
  if(!css.includes("exec.obj.block(store:before)")||!css.includes("exec.obj.block(store)"))css = replaceRe(css);
30
34
  if(!css.includes("exec.obj.block(ext:before)")||!css.includes("exec.obj.block(ext)"))css = procExt(css);
31
35
  if(!css.includes("exec.obj.block(f var)"))css = procVar(css);
package/package.json CHANGED
@@ -1,33 +1,37 @@
1
1
  {
2
2
  "name": "fscss",
3
+ "version": "1.1.12",
3
4
  "description": "Figured Shorthand Cascading Style Sheet",
4
- "version": "1.1.10",
5
- "type": "module",
6
- "main": "lib/index.js",
7
- "bin": {
8
- "fscss": "bin/fscss.js"
9
- },
10
- "scripts": {
11
- "start": "node index.js",
12
- "test": "node bin/fscss.js example.fscss example.css"
13
- },
14
- "repository": {
15
- "type": "git",
16
- "url": "git+https://github.com/Figsh/xfscss.git"
17
- },
18
5
  "keywords": [
19
6
  "node",
20
7
  "figsh_css",
21
8
  "fs-css",
22
9
  "fscss",
23
- "xfscss"
10
+ "xfscss",
11
+ "preprocessor"
24
12
  ],
25
- "author": "Figsh",
26
- "license": "MIT",
13
+ "homepage": "https://github.com/Figsh/xfscss#readme",
27
14
  "bugs": {
28
15
  "url": "https://github.com/Figsh/xfscss/issues"
29
16
  },
30
- "homepage": "https://github.com/Figsh/xfscss#readme",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/Figsh/xfscss.git"
20
+ },
21
+ "license": "MIT",
22
+ "author": "Figsh",
23
+ "type": "module",
24
+ "main": "lib/index.js",
25
+ "bin": {
26
+ "fscss": "bin/fscss.js"
27
+ },
28
+ "directories": {
29
+ "lib": "lib"
30
+ },
31
+ "scripts": {
32
+ "start": "node index.js",
33
+ "test": "node bin/fscss.js example.fscss example.css"
34
+ },
31
35
  "dependencies": {
32
36
  "express": "^4.18.2",
33
37
  "dotenv": "^16.0.3"
@@ -35,8 +39,5 @@
35
39
  "devDependencies": {
36
40
  "mocha": "^10.0.0",
37
41
  "chai": "^4.3.4"
38
- },
39
- "directories": {
40
- "lib": "lib"
41
42
  }
42
43
  }
package/style.css ADDED
@@ -0,0 +1,9 @@
1
+ body{
2
+ Background: #f8f8f8;
3
+ color: blue;
4
+ }
5
+ div{
6
+ background: linear-gradient(to bottom, #228B22, #8B4513);
7
+ width: 200px; height: 200px;
8
+ clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
9
+ }