@melcanz85/chaincss 1.5.10 → 1.5.27

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.
@@ -0,0 +1,22 @@
1
+ name: Publish Package
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+
8
+ permissions:
9
+ id-token: write
10
+ contents: read
11
+
12
+ jobs:
13
+ publish:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - uses: actions/setup-node@v4
18
+ with:
19
+ node-version: '24'
20
+ registry-url: 'https://registry.npmjs.org'
21
+ - run: npm ci
22
+ - run: npm publish
package/README.md CHANGED
@@ -60,11 +60,12 @@ try {
60
60
 
61
61
  💻 Code Examples
62
62
 
63
- --Chaining File (chaincss/chain.jcss):
63
+ //*** This is where the chaining happens all codes here are in javascript syntax, the methods are the css properties but in javascript form it follows the camelCase standard. Example the css property font-family is fontFamily in chaincss and your css selector is the value of the block() method which is always at the end of the chain.
64
64
 
65
- *** This is where the chaining happens all codes here are in javascript syntax, the methods are the css properties but in javascript form it follows the camelCase syntax. Example the property font-family is fontFamily in chaincss and your css selector is the value of the block() method which is always at the end of the chain.
65
+ //*** The property method are the same as the css property but background is an exception because it's a long word so it is shorten to bg only. Example background-color is bgColor() in chaincss etc.
66
66
 
67
- *** The property method are the same as the css property but background is an exception because it's a long word so it is shorten to bg only. Example background-color is bgColor() in chaincss etc.
67
+
68
+ //--Chaining File (chaincss/chain.jcss):
68
69
 
69
70
  // Variables for consistent styling
70
71
  const bodyBgColor = '#f0f0f0';
@@ -109,7 +110,7 @@ module.exports = {
109
110
  };
110
111
 
111
112
 
112
- --Main File (chaincss/main.jcss):
113
+ //--Main File (chaincss/main.jcss):
113
114
 
114
115
  <@
115
116
  // Import chaining definitions
package/chaincss.js CHANGED
@@ -8,15 +8,16 @@ const chokidar = require('chokidar');
8
8
  const CleanCSS = require('clean-css');
9
9
  const transpilerModule = require('./transpiler.js');
10
10
 
11
- // FUNCTION TO PROCESS CHUNKS OF SCRIPTS FROM THE INPUT FILE USING THE VM MODULE
12
11
  const processScript = (scriptBlock) => {
12
+ //const output = 'cssOutput = undefined;';
13
13
  const context = vm.createContext({
14
- ...transpilerModule
14
+ ...transpilerModule // Only expose what's needed
15
15
  });
16
- const jsCode = scriptBlock.trim();
16
+
17
+ const jsCode = scriptBlock.trim(); //`(function() { ${scriptBlock.trim()} })();`; Wrap script in IIFE
17
18
  const chainScript = new vm.Script(jsCode);
18
- chainScript.runInContext(context);
19
- return context.chain.cssOutput;
19
+ chainScript.runInContext(context); // Execute in isolated context
20
+ return context.chain.cssOutput; // Return the processed output
20
21
  };
21
22
 
22
23
  // CSS Minification Function
@@ -31,12 +32,12 @@ const minifyCss = (css) => {
31
32
 
32
33
  // FUNCTION TO CONVERT JS CODES TO CSS CODE
33
34
  const processor = (inputFile, outputFile) => {
34
- const allowedExtensions = ['.jcss'];
35
+ /*const allowedExtensions = ['.jcss'];
35
36
  const fileExt = path.extname(inputFile).toLowerCase();
36
37
 
37
38
  if (!allowedExtensions.includes(fileExt)) {
38
39
  throw new Error(`Invalid file extension: ${fileExt}. Only .jcss files are allowed.`);
39
- }
40
+ }*/
40
41
  const input = path.resolve(inputFile);
41
42
  const content = fs.readFileSync(input, 'utf8');
42
43
  const blocks = content.split(/<@([\s\S]*?)@>/gm);
@@ -61,7 +62,7 @@ const processor = (inputFile, outputFile) => {
61
62
  const outputDir = path.resolve(outputFile);
62
63
  const trimmedCSS = outputCSS.trim();
63
64
  const minCSS = minifyCss(trimmedCSS);
64
- fs.writeFileSync(outputDir, minCSS, 'utf8');
65
+ fs.writeFileSync(outputDir, minCSS, 'utf8'); // Write processed CSS
65
66
  };
66
67
 
67
68
  // Watch function
package/package.json CHANGED
@@ -1,10 +1,19 @@
1
1
  {
2
2
  "name": "@melcanz85/chaincss",
3
- "version": "1.5.10",
3
+ "version": "1.5.27",
4
4
  "description": "A simple package transpiler for js to css",
5
5
  "main": "chaincss.js",
6
+ "publishConfig": {
7
+ "access": "public",
8
+ "registry": "https://registry.npmjs.org/"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/melcanz08/chaincss.git"
13
+ },
14
+ "homepage": "https://github.com/melcanz08/chaincss",
6
15
  "bin": {
7
- "chaincss": "./chaincss.js"
16
+ "chaincss": "chaincss.js"
8
17
  },
9
18
  "dependencies": {
10
19
  "chokidar": "^3.5.3",
package/transpiler.js CHANGED
@@ -12,6 +12,54 @@ const chain = {
12
12
  bgAttachment(bga){ this.catcher.backgroundAttachment = bga; return this; },
13
13
  bgPosition(bgp){ this.catcher.backgroundPosition = bgp; return this; },
14
14
 
15
+ // Border
16
+ border(b){ this.catcher.border = b; return this; },
17
+ borderStyle(bs){ this.catcher.borderStyle = bs; return this; },
18
+ borderWidth(bw){ this.catcher.borderWidth = bw; return this; },
19
+ borderColor(bc){ this.catcher.borderColor = bc; return this; },
20
+ borderRadius(br){ this.catcher.borderRadius = br; return this; },
21
+ borderSideStyle(side, value){
22
+ if (side === 'top') {
23
+ this.catcher.borderTopStyle = value;
24
+ } else if (side === 'right') {
25
+ this.catcher.borderRightStyle = value;
26
+ } else if (side === 'bottom') {
27
+ this.catcher.borderBottomStyle = value;
28
+ } else if (side === 'left') {
29
+ this.catcher.borderLeftStyle = value;
30
+ }
31
+ return this;
32
+ },
33
+
34
+ // Margin
35
+ margin(m){ this.catcher.margin = m; return this; },
36
+ marginTop(mt){ this.catcher.marginTop = mt; return this; },
37
+ marginRight(mr){ this.catcher.marginRight = mr; return this; },
38
+ marginBottom(mb){ this.catcher.marginBottom = mb; return this; },
39
+ marginLeft(ml){ this.catcher.marginLeft = ml; return this; },
40
+
41
+ // Padding
42
+ padding(p){ this.catcher.padding = p; return this; },
43
+ paddingTop(pt){ this.catcher.paddingTop = pt; return this; },
44
+ paddingRight(pr){ this.catcher.paddingRight = pr; return this; },
45
+ paddingBottom(pb){ this.catcher.paddingBottom = pb; return this; },
46
+ paddingLeft(pl){ this.catcher.paddingLeft = pl; return this; },
47
+
48
+ // Height, Width and Max-width
49
+ width(w){ this.catcher.width = w; return this; },
50
+ minWidth(mnw){ this.catcher.minWidth = mnw; return this; },
51
+ maxWidth(mxw){ this.catcher.maxWidth = mxw; return this; },
52
+ height(h){ this.catcher.height = h; return this; },
53
+ minHeight(mnh){ this.catcher.minHeight = mnh; return this; },
54
+ maxHeight(mxh){ this.catcher.maxHeight = mxh; return this; },
55
+
56
+ // Outline
57
+ outline(o){ this.catcher.outline = o; return this; },
58
+ outlineColor(oc){ this.catcher.outlineColor = oc; return this; },
59
+ outlineStyle(os){ this.catcher.outlineStyle = os; return this; },
60
+ outlineWidth(ow){ this.catcher.outlineWidth = ow; return this; },
61
+ outlineOffset(oo){ this.catcher.outlineOffset = oo; return this; },
62
+
15
63
  // Text
16
64
  color(c){ this.catcher.color = c; return this; },
17
65
  direction(d){ this.catcher.direction = d; return this; },
@@ -37,31 +85,19 @@ const chain = {
37
85
  wordSpacing(ws){ this.catcher.wordSpacing = ws; return this; },
38
86
  whiteSpace(sws){ this.catcher.whiteSpace = sws; return this; },
39
87
 
40
- // Border
41
- border(b){ this.catcher.border = b; return this; },
42
- borderStyle(bs){ this.catcher.borderStyle = bs; return this; },
43
- borderWidth(bw){ this.catcher.borderWidth = bw; return this; },
44
- borderColor(bc){ this.catcher.borderColor = bc; return this; },
45
- borderRadius(br){ this.catcher.borderRadius = br; return this; },
46
- borderSideStyle(side, value){
47
- if (side === 'top') {
48
- this.catcher.borderTopStyle = value;
49
- } else if (side === 'right') {
50
- this.catcher.borderRightStyle = value;
51
- } else if (side === 'bottom') {
52
- this.catcher.borderBottomStyle = value;
53
- } else if (side === 'left') {
54
- this.catcher.borderLeftStyle = value;
55
- }
56
- return this;
57
- },
58
-
59
88
  // Font
60
- fontFamily(f){ this.catcher.fontFamily = f; return this; },
61
- fontStyle(s){ this.catcher.fontStyle = s; return this; },
62
- fontWeight(w){ this.catcher.fontWeight = w; return this; },
63
- fontVariant(v){ this.catcher.fontVariant = v; return this; },
64
- fontSize(si){ this.catcher.fontSize = si; return this; },
89
+ font(f){ this.catcher.font = f; return this; },
90
+ fontFamily(ff){ this.catcher.fontFamily = ff; return this; },
91
+ fontStyle(fs){ this.catcher.fontStyle = fs; return this; },
92
+ fontWeight(fw){ this.catcher.fontWeight = fw; return this; },
93
+ fontVariant(fv){ this.catcher.fontVariant = fv; return this; },
94
+ fontSize(fsz){ this.catcher.fontSize = fsz; return this; },
95
+
96
+ // List Style
97
+ listStyle(ls){ this.catcher.listStyle = ls; return this; },
98
+ listStyleType(lst){ this.catcher.listStyleType = lst; return this; },
99
+ listStyleImage(lsi){ this.catcher.listStyleImage = lsi; return this; },
100
+ listStylePosition(lsp){ this.catcher.listStylePosition = lsp; return this; },
65
101
 
66
102
  // Display
67
103
  display(d){ this.catcher.display = d; return this; },
@@ -76,27 +112,11 @@ const chain = {
76
112
  order(o){ this.catcher.order = o; return this; },
77
113
  visibility(v){ this.catcher.visibility = v; return this; },
78
114
 
79
- // Height, Width and Max-width
80
- width(w){ this.catcher.width = w; return this; },
81
- minWidth(mnw){ this.catcher.minWidth = mnw; return this; },
82
- maxWidth(mxw){ this.catcher.maxWidth = mxw; return this; },
83
- height(h){ this.catcher.height = h; return this; },
84
- minHeight(mnh){ this.catcher.minHeight = mnh; return this; },
85
- maxHeight(mxh){ this.catcher.maxHeight = mxh; return this; },
86
-
87
- // Padding
88
- padding(p){ this.catcher.padding = p; return this; },
89
- paddingTop(pt){ this.catcher.paddingTop = pt; return this; },
90
- paddingRight(pr){ this.catcher.paddingRight = pr; return this; },
91
- paddingBottom(pb){ this.catcher.paddingBottom = pb; return this; },
92
- paddingLeft(pl){ this.catcher.paddingLeft = pl; return this; },
93
-
94
- // Margin
95
- margin(m){ this.catcher.margin = m; return this; },
96
- marginTop(mt){ this.catcher.marginTop = mt; return this; },
97
- marginRight(mr){ this.catcher.marginRight = mr; return this; },
98
- marginBottom(mb){ this.catcher.marginBottom = mb; return this; },
99
- marginLeft(ml){ this.catcher.marginLeft = ml; return this; },
115
+ // Position
116
+ position(p){ this.catcher.position = p; return this; },
117
+ top(t){ this.catcher.top = t; return this; },
118
+ left(l){ this.catcher.left = l; return this; },
119
+ bottom(b){ this.catcher.bottom = b; return this; },
100
120
 
101
121
  // Overflow
102
122
  overflow(o){ this.catcher.overflow = o; return this; },
@@ -104,28 +124,18 @@ const chain = {
104
124
  overflowY(oy){ this.catcher.overflowY = oy; return this; },
105
125
  overflowWrap(ow){ this.catcher.overflowWrap = ow; return this; },
106
126
 
107
- // List Style
108
- listStyle(ls){ this.catcher.listStyle = ls; return this; },
109
- listStyleType(lst){ this.catcher.listStyleType = lst; return this; },
110
- listStyleImage(lsi){ this.catcher.listStyleImage = lsi; return this; },
111
- listStylePosition(lsp){ this.catcher.listStylePosition = lsp; return this; },
112
-
113
- // Outline
114
- outline(o){ this.catcher.outline = o; return this; },
115
- outlineColor(oc){ this.catcher.outlineColor = oc; return this; },
116
- outlineStyle(os){ this.catcher.outlineStyle = os; return this; },
117
- outlineWidth(ow){ this.catcher.outlineWidth = ow; return this; },
118
- outlineOffset(oo){ this.catcher.outlineOffset = oo; return this; },
127
+ textFillColor(tfc){ this.catcher.textFillColor = tfc; return this; },
128
+ backgroundClip(bc){ this.catcher.backgroundClip = bc; return this; },
129
+ gridTemplateColumns(gtc){ this.catcher.gridTemplateColumns = gtc; return this; },
130
+ right(r){ this.catcher.right = r; return this; },
131
+ transform(tf){ this.catcher.transform = tf; return this; },
132
+ boxShadow(bs){ this.catcher.boxShadow = bs; return this; },
133
+ backdropFilter(bf){ this.catcher.backdropFilter = bf; return this; },
134
+ gap(g){ this.catcher.gap = g; return this; },
119
135
 
120
136
  // Float
121
137
  float(f){ this.catcher.float = f; return this; },
122
138
  clear(c){ this.catcher.clear = c; return this; },
123
-
124
- // Position
125
- position(p){ this.catcher.position = p; return this; },
126
- top(t){ this.catcher.top = t; return this; },
127
- left(l){ this.catcher.left = l; return this; },
128
- bottom(b){ this.catcher.bottom = b; return this; },
129
139
 
130
140
  // Z-index
131
141
  zIndex(zi){ this.catcher.zIndex = zi; return this; },
@@ -197,9 +207,6 @@ const compile = (obj) => {
197
207
  const element = obj[key];
198
208
  let selectors = element.selectors || []; // Provide default empty array if selectors is undefined
199
209
  let elementCSS = '';
200
- console.log('Problematic element:', element);
201
- console.log('Type of element:', typeof element);
202
- console.log('Is element null?', element === null);
203
210
  for (let prop in element) {
204
211
 
205
212
  if (element.hasOwnProperty(prop) && prop !== 'selectors') {
@@ -218,9 +225,6 @@ const compile = (obj) => {
218
225
  };
219
226
 
220
227
  const get = (filename) => {
221
- console.log('get() called with:', filename);
222
- console.log('Current working directory:', process.cwd());
223
-
224
228
  const fileExt = path.extname(filename).toLowerCase();
225
229
  if (fileExt !== '.jcss') {
226
230
  throw new Error(`Import error: ${filename} must have .jcss extension`);
@@ -228,11 +232,9 @@ const get = (filename) => {
228
232
 
229
233
  // Try to resolve the path
230
234
  const resolvedPath = path.resolve(process.cwd(), filename);
231
- console.log('Resolved path:', resolvedPath);
232
235
 
233
236
  // Check if file exists
234
237
  const exists = fs.existsSync(resolvedPath);
235
- console.log('File exists?', exists);
236
238
 
237
239
  if (!exists) {
238
240
  throw new Error(`File not found: ${filename} (resolved to: ${resolvedPath})`);
@@ -245,7 +247,6 @@ if (typeof global !== 'undefined') {
245
247
  global.chain = chain;
246
248
  }
247
249
 
248
-
249
250
  module.exports = {
250
251
  chain,
251
252
  run,