fscss 1.1.6 → 1.1.7
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 +65 -20
- package/bin/fscss.js +39 -0
- package/devcontainer.json +22 -2
- package/e/exec.js +5 -7
- package/e/index.html +8 -0
- package/e/run.js +44 -0
- package/e/xfscss.js +7 -0
- package/example.css +9 -0
- package/example.fscss +7 -0
- package/index.js +0 -1
- package/lib/functions/all.js +1060 -0
- package/lib/functions/impSel.js +59 -0
- package/lib/functions/procImp.js +50 -0
- package/lib/index.js +2 -0
- package/lib/processor.js +47 -0
- package/package.json +26 -23
- package/public/test.html +24 -0
- package/public/vars.fscss +7 -0
- package/style.fscss +4 -0
- package/xfscss.min.js +3 -3
- package/e/index.js +0 -9
- package/e/xfscss.min.js +0 -9
- package/strg/de +0 -5
- package/strg/xvars.fscss +0 -23
package/README.md
CHANGED
|
@@ -1,21 +1,66 @@
|
|
|
1
1
|
# FSCSS
|
|
2
|
-
<a href="https://
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
2
|
+
<a href="https://fscss.onrender.com"><img src="https://i.ibb.co/hFP9xZr8/fscss-icon.jpg" alt="FSCSS Style Sheet" border="0" width="30" height="10"></a>FSCSS (Figured Shorthand CSS) is a CSS preprocessor that extends CSS with shorthand utilities, variables, functions, and advanced transformations.
|
|
3
|
+
It works both in the browser and on the backend (Node.js).
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
🚀 Installation
|
|
9
|
+
|
|
10
|
+
`npm install -g fscss`
|
|
11
|
+
|
|
12
|
+
Or locally to your project:
|
|
13
|
+
|
|
14
|
+
`npm install fscss`
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## usage
|
|
20
|
+
*command*
|
|
21
|
+
```bash
|
|
22
|
+
fscss input.fscss output.css
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## ✨ Features
|
|
29
|
+
|
|
30
|
+
Works in browser and backend (Node.js)
|
|
31
|
+
|
|
32
|
+
Supports:
|
|
33
|
+
|
|
34
|
+
- `@import(exec(...))` inline imports
|
|
35
|
+
|
|
36
|
+
- Variables
|
|
37
|
+
|
|
38
|
+
- Functions
|
|
39
|
+
|
|
40
|
+
- Arrays
|
|
41
|
+
|
|
42
|
+
- replace
|
|
43
|
+
|
|
44
|
+
- Random values (random)
|
|
45
|
+
|
|
46
|
+
- Copy (copy)
|
|
47
|
+
|
|
48
|
+
- Number operations (num)
|
|
49
|
+
|
|
50
|
+
- Extract string (ext)
|
|
51
|
+
|
|
52
|
+
- Event bindings (event)
|
|
53
|
+
|
|
54
|
+
- Debug helpers (debug)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
Transform shorthand syntax into valid CSS
|
|
58
|
+
|
|
59
|
+
Extensible with plugins
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
📜 License
|
|
65
|
+
|
|
66
|
+
MIT © 2025 Figsh—FSCSS
|
package/bin/fscss.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
import { processFscss } from "../lib/processor.js";
|
|
6
|
+
|
|
7
|
+
// resolve __dirname in ES modules
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = path.dirname(__filename);
|
|
10
|
+
|
|
11
|
+
const input = process.argv[2];
|
|
12
|
+
const output = process.argv[3] || "out.css";
|
|
13
|
+
|
|
14
|
+
if (!input) {
|
|
15
|
+
console.error("Usage: fscss <input.fscss> [output.css]");
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const inputPath = path.resolve(process.cwd(), input);
|
|
20
|
+
const outputPath = path.resolve(process.cwd(), output);
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
const css = fs.readFileSync(inputPath, "utf8");
|
|
24
|
+
// 🔴 OLD (caused Promise issue)
|
|
25
|
+
// const processed = processFscss(css);
|
|
26
|
+
|
|
27
|
+
// ✅ NEW (await result)
|
|
28
|
+
const processed = await processFscss(css);
|
|
29
|
+
|
|
30
|
+
if (typeof processed !== "string") {
|
|
31
|
+
throw new TypeError("processFscss did not return a string");
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
fs.writeFileSync(outputPath, processed, "utf8");
|
|
35
|
+
console.log(`✔ Compiled ${input} → ${output}`);
|
|
36
|
+
} catch (err) {
|
|
37
|
+
console.error("Error:", err.message);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
package/devcontainer.json
CHANGED
|
@@ -1,2 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "Node.js Dev Container",
|
|
3
|
+
"build": {
|
|
4
|
+
"dockerfile": "Dockerfile",
|
|
5
|
+
"context": ".",
|
|
6
|
+
"args": {
|
|
7
|
+
"NODE_VERSION": "18"
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
"settings": {
|
|
11
|
+
"terminal.integrated.shell.linux": "/bin/bash",
|
|
12
|
+
"editor.formatOnSave": true
|
|
13
|
+
},
|
|
14
|
+
"extensions": [
|
|
15
|
+
"dbaeumer.vscode-eslint",
|
|
16
|
+
"esbenp.prettier-vscode",
|
|
17
|
+
"ms-vscode.vscode-typescript-next"
|
|
18
|
+
],
|
|
19
|
+
"postCreateCommand": "npm install -g npm@latest && npm install",
|
|
20
|
+
"forwardPorts": [3000],
|
|
21
|
+
"remoteUser": "node"
|
|
22
|
+
}
|
package/e/exec.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
function loadFScript(src, async = true){const script=document.createElement('script');script.type='text/javascript';script.async= async;src="https://cdn.jsdelivr.net/gh/Figsh/FSCSS@main/rtF4.js";script.src = src;document.body.appendChild(script);}loadFScript();function applyFscssStyles() {const fscssLinks=document.querySelectorAll('[type*="fscss"]');fscssLinks.forEach(link => {fetch(link.href).then(response=>response.text()).then(css =>{const style=document.createElement('style');style.textContent = css;document.head.appendChild(style);}).catch(error => {
|
|
3
3
|
console.error(`Failed to load FSCSS from ${link.href}`, error);});});}function inf({ host, path }) {if (!host || !path) {console.error("Both 'host' and 'path' are required.");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
/* v-- */
|
|
10
|
-
|
|
4
|
+
return;}const sanitizedHost = host.replace(/github/gi, 'gh');const sanitizedPath = path.replace(/\s*->\s*/g, '/').replace(/\n/g, '');const finalUrl = `https://cdn.jsdelivr.net/${sanitizedHost}/${sanitizedPath}`;loadFScript(finalUrl);
|
|
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
|
+
return;
|
|
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);}}
|
package/e/index.html
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
|
|
2
|
+
function loadFScript(src, async = true){const script=document.createElement('script');script.type='text/javascript';script.async= async;src="https://cdn.jsdelivr.net/gh/Figsh/FSCSS@main/rtF4.js";script.src = src;document.body.appendChild(script);}loadFScript();function applyFscssStyles() {const fscssLinks=document.querySelectorAll('[type*="fscss"]');fscssLinks.forEach(link => {fetch(link.href).then(response=>response.text()).then(css =>{const style=document.createElement('style');style.textContent = css;document.head.appendChild(style);}).catch(error => {
|
|
3
|
+
console.error(`Failed to load FSCSS from ${link.href}`, error);});});}function inf({ host, path }) {if (!host || !path) {console.error("Both 'host' and 'path' are required.");
|
|
4
|
+
return;}const sanitizedHost = host.replace(/github/gi, 'gh');const sanitizedPath = path.replace(/\s*->\s*/g, '/').replace(/\n/g, '');const finalUrl = `https://cdn.jsdelivr.net/${sanitizedHost}/${sanitizedPath}`;loadFScript(finalUrl);
|
|
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
|
+
return;
|
|
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);}}
|
package/e/run.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
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/e/xfscss.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
function loadFScript(src, async = true){const script=document.createElement('script');script.type='text/javascript';script.async= async;src="https://cdn.jsdelivr.net/gh/Figsh/FSCSS@main/rtF4.js";script.src = src;document.body.appendChild(script);}loadFScript();export function applyFscssStyles() {const fscssLinks=document.querySelectorAll('[type*="fscss"]');fscssLinks.forEach(link => {fetch(link.href).then(response=>response.text()).then(css =>{const style=document.createElement('style');style.textContent = css;document.head.appendChild(style);}).catch(error => {
|
|
2
|
+
console.error(`Failed to load FSCSS from ${link.href}`, error);});});}export function inf({ host, path }) {if (!host || !path) {console.error("Both 'host' and 'path' are required.");
|
|
3
|
+
return;}const sanitizedHost = host.replace(/github/gi, 'gh');const sanitizedPath = path.replace(/\s*->\s*/g, '/').replace(/\n/g, '');const finalUrl = `https://cdn.jsdelivr.net/${sanitizedHost}/${sanitizedPath}`;loadFScript(finalUrl);
|
|
4
|
+
}export function exec({ type = 'text', content, onError, onSuccess }) {if (!content) {const errorText = 'No CSS content or URL provided.';console.error(errorText);if (onError) onError(errorText);
|
|
5
|
+
return;
|
|
6
|
+
}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}`);
|
|
7
|
+
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/example.css
ADDED
package/example.fscss
ADDED
package/index.js
CHANGED
|
@@ -6,4 +6,3 @@ 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
|
-
|