fscss 1.1.7 → 1.1.8
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 +5 -8
- package/bin/fscss.js +3 -6
- package/e/{index.html → index.js} +1 -1
- package/lib/functions/all.js +21 -2
- package/lib/processor.js +24 -22
- package/package.json +1 -1
- package/{xfscss.min.js → xfscss.js} +1 -1
- package/e/run.js +0 -44
- package/example.css +0 -9
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# FSCSS
|
|
2
|
-
|
|
2
|
+
FSCSS (Figured Shorthand CSS) is a CSS preprocessor that extends CSS with shorthand utilities, variables, functions, and advanced transformations.
|
|
3
3
|
It works both in the browser and on the backend (Node.js).
|
|
4
4
|
|
|
5
5
|
|
|
@@ -16,14 +16,7 @@ Or locally to your project:
|
|
|
16
16
|
|
|
17
17
|
---
|
|
18
18
|
|
|
19
|
-
## usage
|
|
20
|
-
*command*
|
|
21
|
-
```bash
|
|
22
|
-
fscss input.fscss output.css
|
|
23
19
|
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
---
|
|
27
20
|
|
|
28
21
|
## ✨ Features
|
|
29
22
|
|
|
@@ -50,6 +43,10 @@ Supports:
|
|
|
50
43
|
- Extract string (ext)
|
|
51
44
|
|
|
52
45
|
- Event bindings (event)
|
|
46
|
+
|
|
47
|
+
- count(number)
|
|
48
|
+
|
|
49
|
+
- length(string)
|
|
53
50
|
|
|
54
51
|
- Debug helpers (debug)
|
|
55
52
|
|
package/bin/fscss.js
CHANGED
|
@@ -4,7 +4,7 @@ import path from "path";
|
|
|
4
4
|
import { fileURLToPath } from "url";
|
|
5
5
|
import { processFscss } from "../lib/processor.js";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
const __filename = fileURLToPath(import.meta.url);
|
|
9
9
|
const __dirname = path.dirname(__filename);
|
|
10
10
|
|
|
@@ -21,10 +21,7 @@ const outputPath = path.resolve(process.cwd(), output);
|
|
|
21
21
|
|
|
22
22
|
try {
|
|
23
23
|
const css = fs.readFileSync(inputPath, "utf8");
|
|
24
|
-
|
|
25
|
-
// const processed = processFscss(css);
|
|
26
|
-
|
|
27
|
-
// ✅ NEW (await result)
|
|
24
|
+
|
|
28
25
|
const processed = await processFscss(css);
|
|
29
26
|
|
|
30
27
|
if (typeof processed !== "string") {
|
|
@@ -32,7 +29,7 @@ try {
|
|
|
32
29
|
}
|
|
33
30
|
|
|
34
31
|
fs.writeFileSync(outputPath, processed, "utf8");
|
|
35
|
-
console.log(
|
|
32
|
+
console.log(`[FSCSS] ✔ Compiled ${input} → ${output}`);
|
|
36
33
|
} catch (err) {
|
|
37
34
|
console.error("Error:", err.message);
|
|
38
35
|
process.exit(1);
|
|
@@ -5,4 +5,4 @@ function loadFScript(src, async = true){const script=document.createElement('scr
|
|
|
5
5
|
}function exec({ type = 'text', content, onError, onSuccess }) {if (!content) {const errorText = 'No CSS content or URL provided.';console.error(errorText);if (onError) onError(errorText);
|
|
6
6
|
return;
|
|
7
7
|
}const style=document.createElement('style');const appendStyle=cssText=> {style.textContent = cssText;document.head.appendChild(style);if (onSuccess)onSuccess(style);};if (type==='text'||type==='auto'|| type==='text/fscss'||type==='text/css'){appendStyle(content);}else if (type==='fromUrl'||type==='URL' ||type==='fromURL'||type==='link') {fetch(content).then(res => {if (!res.ok) throw new Error(`HTTP error! Status: ${res.status}`);
|
|
8
|
-
return res.text();}).then(css => appendStyle(css)).catch(err => {console.error(`Failed to load CSS from URL: ${content}`, err);if (onError) onError(err.message);});} else {const errorText = `Unsupported type "${type}". Use "text" or "fromUrl".`;console.error(errorText);if(onError) onError(errorText);}}
|
|
8
|
+
return res.text();}).then(css => appendStyle(css)).catch(err => {console.error(`Failed to load CSS from URL: ${content}`, err);if (onError) onError(err.message);});} else {const errorText = `Unsupported type "${type}". Use "text" or "fromUrl".`;console.error(errorText);if(onError) onError(errorText);}}
|
package/lib/functions/all.js
CHANGED
|
@@ -1,4 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
function procCntInit(ntc,stc){
|
|
2
|
+
const nu = Array(ntc).fill().map((_, i)=>(i+1)*stc);
|
|
3
|
+
return `${nu}`;
|
|
4
|
+
}
|
|
5
|
+
function procCnt(text){
|
|
6
|
+
const reg=/count\((\d+)(?:,(\d+)?)?\)/g;
|
|
7
|
+
text = text.replace(reg, (March, num, step)=>{
|
|
8
|
+
if(step===null)step=1;
|
|
9
|
+
return procCntInit(parseInt(num), parseInt(step?step:1));
|
|
10
|
+
})
|
|
11
|
+
return text;
|
|
12
|
+
}
|
|
13
|
+
function procChe(text) {
|
|
14
|
+
const reg = /length\((?:([^\)]+)|"([^"]*)"|'([^']*)')\)/g;
|
|
15
|
+
text = text.replace(reg, (match, txt, txt2, txt3) => {
|
|
16
|
+
const resTxt = txt || txt2 || txt3;
|
|
17
|
+
return resTxt.length;
|
|
18
|
+
})
|
|
19
|
+
return text;
|
|
20
|
+
}
|
|
2
21
|
function procNum(css){
|
|
3
22
|
const regex = /num\((.*?)\)/g;
|
|
4
23
|
function evaluateExpression(expression) {
|
|
@@ -1055,6 +1074,6 @@ function execObj(css){
|
|
|
1055
1074
|
}
|
|
1056
1075
|
|
|
1057
1076
|
export { initlibraries,
|
|
1058
|
-
impSel, procImp, replaceRe, procExt, procVar,procFun, procArr, procEv, procRan, transformCssValues, procNum,applyFscssTransformations,procExC, execObj
|
|
1077
|
+
impSel, procImp, replaceRe, procExt, procVar,procFun, procArr, procEv, procRan, transformCssValues, procNum,applyFscssTransformations,procExC, procCnt, procChe, execObj
|
|
1059
1078
|
}
|
|
1060
1079
|
|
package/lib/processor.js
CHANGED
|
@@ -12,6 +12,8 @@ import {
|
|
|
12
12
|
procNum,
|
|
13
13
|
applyFscssTransformations,
|
|
14
14
|
procExC,
|
|
15
|
+
procCnt,
|
|
16
|
+
procChe,
|
|
15
17
|
execObj
|
|
16
18
|
} from "./functions/all.js";
|
|
17
19
|
import { procImp } from "./functions/procImp.js";
|
|
@@ -20,28 +22,28 @@ export async function processFscss(css, options = {}) {
|
|
|
20
22
|
const { inputDir = process.cwd() } = options;
|
|
21
23
|
|
|
22
24
|
if (!css.includes("exec.obj.block(all)")) {
|
|
23
|
-
|
|
24
|
-
if
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if
|
|
32
|
-
if
|
|
33
|
-
if
|
|
34
|
-
if
|
|
35
|
-
if
|
|
36
|
-
if
|
|
37
|
-
if
|
|
38
|
-
if
|
|
39
|
-
if
|
|
40
|
-
if
|
|
41
|
-
if
|
|
42
|
-
if
|
|
43
|
-
if
|
|
44
|
-
|
|
25
|
+
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);
|
|
27
|
+
if(!css.includes("exec.obj.block(f import)"))css = await procImp(css);
|
|
28
|
+
|
|
29
|
+
if(!css.includes("exec.obj.block(store:before)")||!css.includes("exec.obj.block(store)"))css = replaceRe(css);
|
|
30
|
+
if(!css.includes("exec.obj.block(ext:before)")||!css.includes("exec.obj.block(ext)"))css = procExt(css);
|
|
31
|
+
if(!css.includes("exec.obj.block(f var)"))css = procVar(css);
|
|
32
|
+
if(!css.includes("exec.obj.block(fun)"))css = procFun(css);
|
|
33
|
+
if(!css.includes("exec.obj.block(length)"))css = procChe(css);
|
|
34
|
+
if(!css.includes("exec.obj.block(count)"))css = procCnt(css);
|
|
35
|
+
if(!css.includes("exec.obj.block(arr)"))css = procArr(css);
|
|
36
|
+
if(!css.includes("exec.obj.block(event)"))css = procEv(css);
|
|
37
|
+
if(!css.includes("exec.obj.block(random)"))css = procRan(css);
|
|
38
|
+
if(!css.includes("exec.obj.block(copy)"))css = transformCssValues(css);
|
|
39
|
+
if(!css.includes("exec.obj.block(store:after)")||!css.includes("exec.obj.block(store)"))css = replaceRe(css);
|
|
40
|
+
if(!css.includes("exec.obj.block(num)"))css = procNum(css);
|
|
41
|
+
if(!css.includes("exec.obj.block(ext:after)")||!css.includes("exec.obj.block(ext)"))css = procExt(css);
|
|
42
|
+
if(!css.includes("exec.obj.block(t group)"))css = applyFscssTransformations(css);
|
|
43
|
+
if(!css.includes("exec.obj.block(length)"))css = procChe(css);
|
|
44
|
+
if(!css.includes("exec.obj.block(count)"))css = procCnt(css);
|
|
45
|
+
if(!css.includes("exec.obj.block(debug)"))css = procExC(css);
|
|
46
|
+
}
|
|
45
47
|
|
|
46
48
|
return execObj(css);
|
|
47
49
|
}
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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
|
|
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");
|
|
3
3
|
AJWinDocStyleElement.innerHTML = `${data}`;
|
|
4
4
|
document.head.appendChild(AJWinDocStyleElement);}).catch(error=>{});}}export{ inf };export{ exec };
|
package/e/run.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import {initlibraries,
|
|
2
|
-
impSel, procImp, replaceRe, procExt, procVar, procFun, procArr, procEv, procRan, transformCssValues, procNum, applyFscssTransformations, procExC, execObj} from "./lib/functions/all.js";
|
|
3
|
-
|
|
4
|
-
async function processStyles() {
|
|
5
|
-
const styleElements = document.querySelectorAll('style');
|
|
6
|
-
|
|
7
|
-
if (!styleElements.length) {
|
|
8
|
-
console.warn('fscss[Obj]\n No <style> elements found.');
|
|
9
|
-
return;
|
|
10
|
-
}for (const element of styleElements) {
|
|
11
|
-
let css = element.textContent;
|
|
12
|
-
if(!css.includes("exec.obj.block(all)")){
|
|
13
|
-
if(!css.includes("exec.obj.block(init lab)"))css = initlibraries(css);
|
|
14
|
-
if(!css.includes("exec.obj.block(f import)")||!css.includes("exec.obj.block(f import pick)"))css = await impSel(css);
|
|
15
|
-
if(!css.includes("exec.obj.block(f import)"))css = await procImp(css);
|
|
16
|
-
|
|
17
|
-
if(!css.includes("exec.obj.block(store:before)")||!css.includes("exec.obj.block(store)"))css = replaceRe(css);
|
|
18
|
-
if(!css.includes("exec.obj.block(ext:before)")||!css.includes("exec.obj.block(ext)"))css = procExt(css);
|
|
19
|
-
if(!css.includes("exec.obj.block(f var)"))css = procVar(css);
|
|
20
|
-
if(!css.includes("exec.obj.block(fun)"))css = procFun(css);
|
|
21
|
-
if(!css.includes("exec.obj.block(arr)"))css = procArr(css);
|
|
22
|
-
if(!css.includes("exec.obj.block(event)"))css = procEv(css);
|
|
23
|
-
if(!css.includes("exec.obj.block(random)"))css = procRan(css);
|
|
24
|
-
if(!css.includes("exec.obj.block(copy)"))css = transformCssValues(css);
|
|
25
|
-
if(!css.includes("exec.obj.block(store:after)")||!css.includes("exec.obj.block(store)"))css = replaceRe(css);
|
|
26
|
-
if(!css.includes("exec.obj.block(num)"))css = procNum(css);
|
|
27
|
-
if(!css.includes("exec.obj.block(ext:after)")||!css.includes("exec.obj.block(ext)"))css = procExt(css);
|
|
28
|
-
if(!css.includes("exec.obj.block(t group)"))css = applyFscssTransformations(css);
|
|
29
|
-
if(!css.includes("exec.obj.block(debug)"))css = procExC(css);
|
|
30
|
-
}
|
|
31
|
-
css=execObj(css);
|
|
32
|
-
element.innerHTML = css;
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
(async () => {
|
|
38
|
-
try {
|
|
39
|
-
await processStyles();
|
|
40
|
-
// This can run after styles are processed
|
|
41
|
-
} catch (error) {
|
|
42
|
-
console.error('Error processing styles or draw elements:', error);
|
|
43
|
-
}
|
|
44
|
-
})();
|
package/example.css
DELETED