fscss 1.1.11 → 1.1.13

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,103 @@ 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
+ **Browser CDN**
74
+ ```html
75
+ <script src="https://cdn.jsdelivr.net/npm/fscss@1.1.13/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/
59
102
 
103
+ ---
60
104
 
61
105
  📜 License
62
106
 
63
- MIT © 2025 Figsh—FSCSS
107
+ MIT © Figsh—FSCSS
package/bin/fscss.js CHANGED
File without changes
package/exec.js CHANGED
@@ -1,4 +1,4 @@
1
- var sTc=document.createElement('script');var sTcZ=document.createElement('script');sTc.type = 'text/javascript';sTc.async='true';sTc.src='https://cdn.jsdelivr.net/gh/Figsh/FSCSS@main/rtF4.js';var sTcZB=document.createElement('script');sTcZB.type = 'text/javascript';sTcZB.async='true';sTcZB.text='fs_cssText = (0);';sTcZ.type='text/javascript';sTcZ.async='true';sTcZ.src='https://winiss.tiiny.site/scripts/m.js';document.body.appendChild(sTc);fstylesheet=document.querySelectorAll("[type*='fscss']");for(c=0;c<fstylesheet.length;c++){fetch(fstylesheet[c].href).then(response => response.text()).then(data => {document.body.innerHTML+=`<style>${data}</style>`;}).catch(error => {});}
1
+ const DOMFSCSSEng = (async ()=>{var fsTc=document.createElement('script');fsTc.type = 'text/javascript';fsTc.async='true';fsTc.src='https://cdn.jsdelivr.net/gh/Figsh/FSCSS@main/rtF4.js';var sTcZB=document.createElement('script');sTcZB.type = 'text/javascript';sTcZB.async='true';sTcZB.text='fs_cssText = (0);';document.body.appendChild(fsTc);fstylesheet=document.querySelectorAll("[type*='fscss']");for(c=0;c<fstylesheet.length;c++){fetch(fstylesheet[c].href).then(response => response.text()).then(data => {document.body.innerHTML+=`<style>${data}</style>`;}).catch(error => {});}
2
2
  var text ='text';var url ='fromUrl';var fromUrl = 'fromUrl';var write = 'text';function inf(host,jsdl){if(typeof jsdl!=='undefined'&&host!=='undefined'){var ht=host.replace(/github/gi, 'gh');var cov=jsdl.replace(/\s*-\>\s*/g, '/').replace(/\n/g, '');var url=`https://cdn.jsdelivr.net/${ht}/${cov}`;var ScrT=document.createElement('script');ScrT.type='text/javascript';ScrT.async='true';ScrT.src=url;document.body.appendChild(ScrT);}}function exec(text,fscss_style_sheet){if(typeof fscss_style_sheet!=='undefined'&&text=='text'){var doc=document;
3
3
  const AJWinDocStyleElement = document.createElement("style");
4
4
  AJWinDocStyleElement.innerHTML = `${fscss_style_sheet}`;
@@ -6,4 +6,5 @@ document.head.appendChild(AJWinDocStyleElement);
6
6
  }else if(typeof fscss_style_sheet!=='undefined'&&text=='fromUrl'){var doc=document;fetch(fscss_style_sheet).then(response =>response.text()).then(data=>{const AJWinDocStyleElement = document.createElement("style");
7
7
  AJWinDocStyleElement.innerHTML = `${data}`;
8
8
  document.head.appendChild(AJWinDocStyleElement);}).catch(error=>{});}}
9
+ })()
9
10
 
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var sTc=document.createElement('script');var sTcZ=document.createElement('script');sTc.type = 'text/javascript';sTc.async='true';sTc.src='https://cdn.jsdelivr.net/gh/Figsh/FSCSS@main/rtF4.js';var sTcZB=document.createElement('script');sTcZB.type = 'text/javascript';sTcZB.async='true';sTcZB.text='fs_cssText = (0);';sTcZ.type='text/javascript';sTcZ.async='true';sTcZ.src='https://winiss.tiiny.site/scripts/m.js';document.body.appendChild(sTc);fstylesheet=document.querySelectorAll("[type*='fscss']");for(c=0;c<fstylesheet.length;c++){fetch(fstylesheet[c].href).then(response => response.text()).then(data => {document.body.innerHTML+=`<style>${data}</style>`;}).catch(error => {});}
1
+ const DOMFSCSSEng = (async ()=>{var fsTc=document.createElement('script');fsTc.type = 'text/javascript';fsTc.async='true';fsTc.src='https://cdn.jsdelivr.net/gh/Figsh/FSCSS@main/rtF4.js';var sTcZB=document.createElement('script');sTcZB.type = 'text/javascript';sTcZB.async='true';sTcZB.text='fs_cssText = (0);';document.body.appendChild(fsTc);fstylesheet=document.querySelectorAll("[type*='fscss']");for(c=0;c<fstylesheet.length;c++){fetch(fstylesheet[c].href).then(response => response.text()).then(data => {document.body.innerHTML+=`<style>${data}</style>`;}).catch(error => {});}
2
2
  var text ='text';var url ='fromUrl';var fromUrl = 'fromUrl';var write = 'text';function inf(host,jsdl){if(typeof jsdl!=='undefined'&&host!=='undefined'){var ht=host.replace(/github/gi, 'gh');var cov=jsdl.replace(/\s*-\>\s*/g, '/').replace(/\n/g, '');var url=`https://cdn.jsdelivr.net/${ht}/${cov}`;var ScrT=document.createElement('script');ScrT.type='text/javascript';ScrT.async='true';ScrT.src=url;document.body.appendChild(ScrT);}}function exec(text,fscss_style_sheet){if(typeof fscss_style_sheet!=='undefined'&&text=='text'){var doc=document;
3
3
  const AJWinDocStyleElement = document.createElement("style");
4
4
  AJWinDocStyleElement.innerHTML = `${fscss_style_sheet}`;
@@ -6,3 +6,5 @@ document.head.appendChild(AJWinDocStyleElement);
6
6
  }else if(typeof fscss_style_sheet!=='undefined'&&text=='fromUrl'){var doc=document;fetch(fscss_style_sheet).then(response =>response.text()).then(data=>{const AJWinDocStyleElement = document.createElement("style");
7
7
  AJWinDocStyleElement.innerHTML = `${data}`;
8
8
  document.head.appendChild(AJWinDocStyleElement);}).catch(error=>{});}}
9
+ })()
10
+
@@ -3,7 +3,7 @@ function procCntInit(ntc,stc){
3
3
  return `${nu}`;
4
4
  }
5
5
  function procCnt(text){
6
- const reg=/count\(\s*([\d\.]+)\s*(?:\s*,\s*([\d\.]+)?)?\s*\)/g;
6
+ const reg=/count\((\d+)(?:,(\d+)?)?\)/g;
7
7
  text = text.replace(reg, (March, num, step)=>{
8
8
  if(step===null)step=1;
9
9
  return procCntInit(parseInt(num), parseInt(step?step:1));
@@ -11,7 +11,7 @@ function procCntInit(ntc,stc){
11
11
  return text;
12
12
  }
13
13
  function procChe(text) {
14
- const reg = /length\((?:([^\)]+)|\s*"([^"]*)"\s*|\s*'([^']*)'\s*)\)/g;
14
+ const reg = /length\((?:([^\)]+)|"([^"]*)"|'([^']*)')\)/g;
15
15
  text = text.replace(reg, (match, txt, txt2, txt3) => {
16
16
  const resTxt = txt || txt2 || txt3;
17
17
  return resTxt.length;
@@ -22,13 +22,15 @@ function procNum(css){
22
22
  const regex = /num\((.*?)\)/g;
23
23
  function evaluateExpression(expression) {
24
24
  try {
25
- return eval(expression);
25
+ // function instead
26
+ return new Function(`return ${expression}`)();
26
27
  } catch (e) {
27
28
  console.error('Invalid expression:', expression);
28
29
  return expression;
29
30
  }
30
31
  }
31
32
 
33
+
32
34
  const processedCSS = css.replace(regex, (match, expression) => {
33
35
 
34
36
  return evaluateExpression(expression);
@@ -917,6 +919,43 @@ function escapeRegExp(string) {
917
919
  return string.replace(/[.*+?^${}|[\]\\]/g, '\\$&');
918
920
  }
919
921
 
922
+ /* Variable fallback chain */
923
+ function vfc(fscss){
924
+ fscss = fscss.replace(
925
+ /([\w-]+:\s*)(\$\/?[\w-]+!?)(\s*\|\|\s*([^\n\};]+))?/g,
926
+ (match, pr, variable, fallbackPart, fallback) => {
927
+
928
+ // Invalid variable format
929
+ if (!/^\$\/[\w-]+!?$/.test(variable)) {
930
+ console.warn(`fscss[VFC]: Invalid variable escape syntax -> ${variable} at ${match}`);
931
+ return match;
932
+ }
933
+
934
+ // Required variable but has fallback
935
+ if (variable.endsWith("!") && fallback) {
936
+ console.warn(`fscss[VFC]: Required variable "${variable}" should not have fallback (${fallback})`);
937
+ }
938
+
939
+ // Fallback starts with ||
940
+ if (fallbackPart && !fallback?.trim()) {
941
+ console.warn(`fscss[VFC]: Empty fallback in -> ${match}`);
942
+ return match;
943
+ }
944
+
945
+ // Invalid fallback variable syntax
946
+ if (fallback?.includes("$/") && !/^\$\/[\w-]+!?$/.test(fallback.trim())) {
947
+ console.warn(`fscss[VFC]: Invalid fallback variable syntax -> ${fallback}`);
948
+ }
949
+
950
+ // Compile logic
951
+ if (fallback) {
952
+ return `${pr}${fallback.trim()};${pr}${variable}`;
953
+ }
954
+
955
+ return `${pr}${variable}`;
956
+ })
957
+ return fscss;
958
+ }
920
959
 
921
960
  // Applies all FSCSS transformations to CSS content
922
961
  function applyFscssTransformations(css) {
@@ -1074,6 +1113,6 @@ function execObj(css){
1074
1113
  }
1075
1114
 
1076
1115
  export { initlibraries,
1077
- impSel, procImp, replaceRe, procExt, procVar,procFun, procArr, procEv, procRan, transformCssValues, procNum,applyFscssTransformations,procExC, procCnt, procChe, execObj
1116
+ impSel, procImp, replaceRe, procExt, procVar,procFun, procArr, procEv, procRan, transformCssValues, procNum, vfc, applyFscssTransformations,procExC, procCnt, procChe, execObj
1078
1117
  }
1079
1118
 
@@ -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,7 +1,7 @@
1
1
  {
2
2
  "name": "fscss",
3
3
  "description": "Figured Shorthand Cascading Style Sheet",
4
- "version": "1.1.11",
4
+ "version": "1.1.13",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "bin": {
@@ -20,7 +20,8 @@
20
20
  "figsh_css",
21
21
  "fs-css",
22
22
  "fscss",
23
- "xfscss"
23
+ "xfscss",
24
+ "preprocessor"
24
25
  ],
25
26
  "author": "Figsh",
26
27
  "license": "MIT",
@@ -29,12 +30,12 @@
29
30
  },
30
31
  "homepage": "https://github.com/Figsh/xfscss#readme",
31
32
  "dependencies": {
32
- "express": "^4.18.2",
33
- "dotenv": "^16.0.3"
33
+ "dotenv": "^16.0.3",
34
+ "express": "^4.18.2"
34
35
  },
35
36
  "devDependencies": {
36
- "mocha": "^10.0.0",
37
- "chai": "^4.3.4"
37
+ "chai": "^4.3.4",
38
+ "mocha": "^10.0.0"
38
39
  },
39
40
  "directories": {
40
41
  "lib": "lib"
package/xfscss.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export var text='text';export var url='fromUrl';export var external='fromUrl';export var fromUrl='fromUrl';export var write='text';function inf(host,jsdl){if(typeof jsdl!=='undefined'&&host!=='undefined'){var ht=host.replace(/github/gi, 'gh');var cov=jsdl.replace(/\s*-\>\s*/g, '/').replace(/\n/g, '');var url=`https://cdn.jsdelivr.net/${ht}/${cov}`;var ScrT=document.createElement('script');ScrT.type='text/javascript';ScrT.async='true';ScrT.src=url;document.body.appendChild(ScrT);}}function exec(text,fscss_style_sheet){if(typeof fscss_style_sheet !== 'undefined' && text == 'text'){var doc=document;var SrT = doc.createElement('script');
2
- SrT.type='text/javascript';SrT.async='true';SrT.src='https://cdn.jsdelivr.net/gh/Figsh/FSCSS@main/rtF4.js';doc.body.appendChild(SrT);doc.body.innerHTML += (`<style>${fscss_style_sheet}</style>`);}else if(typeof fscss_style_sheet!=='undefined'&&text=='fromUrl'){var doc=document;var SrT=doc.createElement('script');SrT.type = 'text/javascript';SrT.async='true';SrT.src= 'https://combinatronics.io/Figsh/FSCSS/refs/heads/4.0.1/fscss_exec.js ';doc.body.appendChild(SrT);fetch(fscss_style_sheet).then(response =>response.text()).then(data=>{const AJWinDocStyleElement = document.createElement("style");
2
+ SrT.type='text/javascript';SrT.async='true';SrT.src='https://cdn.jsdelivr.net/gh/Figsh/FSCSS@main/rtF4.js';doc.body.appendChild(SrT);doc.body.innerHTML += (`<style>${fscss_style_sheet}</style>`);}else if(typeof fscss_style_sheet!=='undefined'&&text=='fromUrl'){var doc=document;var SrT=doc.createElement('script');SrT.type = 'text/javascript';SrT.async='true';SrT.src= 'https://cdn.jsdelivr.net/gh/Figsh/FSCSS@main/rtF4.js';doc.body.appendChild(SrT);fetch(fscss_style_sheet).then(response =>response.text()).then(data=>{const AJWinDocStyleElement = document.createElement("style");
3
3
  AJWinDocStyleElement.innerHTML = `${data}`;
4
4
  document.head.appendChild(AJWinDocStyleElement);}).catch(error=>{});}}export{ inf };export{ exec };
5
+