fscss 1.1.6 → 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 CHANGED
@@ -1,21 +1,63 @@
1
1
  # FSCSS
2
- <a href="https://opencollective.com/fscss"><img src="https://i.ibb.co/hFP9xZr8/fscss-icon.jpg" alt="FSCSS Style Sheet" border="0" width="30" height="10"></a>
3
- Figured Shorthand Cascading Style Sheet (FSCSS)
4
- <br>
5
- <small>
6
- For simplifying CSS coding by introducing shorthand syntax and variables.
7
- </small>
8
- <br>
9
- <b>example usage</b>
10
- <pre><code>
11
- exec({
12
- type: 'text',
13
- content: 'body { background: #0%2([f]); }',
14
- onSuccess: (styleElement) => console.log('CSS applied:', styleElement),
15
- onError: (msg) => console.warn('Error applying CSS:', msg)
16
- });
17
- </code>
18
- </pre>
19
-
20
-
21
-
2
+ 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
+
20
+
21
+ ## ✨ Features
22
+
23
+ Works in browser and backend (Node.js)
24
+
25
+ Supports:
26
+
27
+ - `@import(exec(...))` inline imports
28
+
29
+ - Variables
30
+
31
+ - Functions
32
+
33
+ - Arrays
34
+
35
+ - replace
36
+
37
+ - Random values (random)
38
+
39
+ - Copy (copy)
40
+
41
+ - Number operations (num)
42
+
43
+ - Extract string (ext)
44
+
45
+ - Event bindings (event)
46
+
47
+ - count(number)
48
+
49
+ - length(string)
50
+
51
+ - Debug helpers (debug)
52
+
53
+
54
+ Transform shorthand syntax into valid CSS
55
+
56
+ Extensible with plugins
57
+
58
+
59
+
60
+
61
+ 📜 License
62
+
63
+ MIT © 2025 Figsh—FSCSS
package/bin/fscss.js ADDED
@@ -0,0 +1,36 @@
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
+
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
+
25
+ const processed = await processFscss(css);
26
+
27
+ if (typeof processed !== "string") {
28
+ throw new TypeError("processFscss did not return a string");
29
+ }
30
+
31
+ fs.writeFileSync(outputPath, processed, "utf8");
32
+ console.log(`[FSCSS] ✔ Compiled ${input} → ${output}`);
33
+ } catch (err) {
34
+ console.error("Error:", err.message);
35
+ process.exit(1);
36
+ }
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
- 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);}}
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.js CHANGED
@@ -1,9 +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
- 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);}}
9
- /* v-- */
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/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.fscss ADDED
@@ -0,0 +1,7 @@
1
+ @import(exec(_init themes))
2
+ @import(exec(style.fscss).pick(body))
3
+ div{
4
+ background: @event.theme(forest);
5
+ %2(width, height[: 200px;])
6
+ tr Shape: @event.shape(star);
7
+ }
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
-