fscss 1.1.4 → 1.1.6

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
@@ -6,6 +6,16 @@ Figured Shorthand Cascading Style Sheet (FSCSS)
6
6
  For simplifying CSS coding by introducing shorthand syntax and variables.
7
7
  </small>
8
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>
9
19
 
10
20
 
11
21
 
package/e/exec.js ADDED
@@ -0,0 +1,10 @@
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);}}
9
+ /* v-- */
10
+
package/e/index.js ADDED
@@ -0,0 +1,9 @@
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);}}
9
+ /* v-- */
@@ -0,0 +1,9 @@
1
+ /* v-- */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);}}
8
+
9
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fscss",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
4
4
  "description": "Figured Shorthand Cascading Style Sheet",
5
5
  "keywords": [
6
6
  "node",
@@ -30,7 +30,7 @@
30
30
  "dependencies": {
31
31
  "dotenv": "^16.0.3",
32
32
  "express": "^4.18.2",
33
- "fscss": "^1.1.4"
33
+ "fscss": "^1.1.6"
34
34
  },
35
35
  "devDependencies": {
36
36
  "chai": "^4.3.4",