kempo-css 1.3.13 → 2.0.0

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/scripts/build.js CHANGED
@@ -1,174 +1,174 @@
1
- #!/usr/bin/env node
2
-
3
- import { execSync } from 'child_process';
4
- import fs from 'fs';
5
- import path from 'path';
6
- import { minify } from 'terser';
7
-
8
- // Check for watch flag
9
- const isWatchMode = process.argv.includes('--watch');
10
-
11
- if (isWatchMode) {
12
- console.log('Watch mode enabled - monitoring CSS files for changes...\n');
13
- } else {
14
- console.log('Building Kempo CSS...\n');
15
- }
16
-
17
- // Define input and output files
18
- const inputFiles = [
19
- 'src/kempo.css',
20
- 'src/kempo-hljs.css'
21
- ];
22
-
23
- const outputDir = 'dist';
24
- const outputFiles = [
25
- 'kempo.min.css',
26
- 'kempo-hljs.min.css'
27
- ];
28
-
29
- // Create dist directory if it doesn't exist
30
- if (!fs.existsSync(outputDir)) {
31
- fs.mkdirSync(outputDir);
32
- console.log(`Created ${outputDir}/ directory`);
33
- }
34
-
35
- // Minify each CSS file
36
- inputFiles.forEach((inputFile, index) => {
37
- const outputFile = path.join(outputDir, outputFiles[index]);
38
-
39
- try {
40
- // Check if input file exists
41
- if (!fs.existsSync(inputFile)) {
42
- console.log(`Skipping ${inputFile} (file not found)`);
43
- return;
44
- }
45
-
46
- // Get file size before minification
47
- const originalSize = fs.statSync(inputFile).size;
48
-
49
- // Minify the CSS using clean-css-cli
50
- console.log(`Minifying ${inputFile}...`);
51
- execSync(`npx cleancss -o ${outputFile} ${inputFile}`, { stdio: 'inherit' });
52
-
53
- // Get file size after minification
54
- const minifiedSize = fs.statSync(outputFile).size;
55
- const savings = ((originalSize - minifiedSize) / originalSize * 100).toFixed(1);
56
-
57
- console.log(`${inputFile} → ${outputFile}`);
58
- console.log(` Original: ${(originalSize / 1024).toFixed(1)}KB`);
59
- console.log(` Minified: ${(minifiedSize / 1024).toFixed(1)}KB`);
60
- console.log(` Savings: ${savings}%\n`);
61
- } catch (error) {
62
- console.error(`Error minifying ${inputFile}:`, error.message);
63
- }
64
- });
65
-
66
- // Process and minify components
67
- async function processComponents(){
68
- const componentsDir = 'src/components';
69
- const docsComponentsDir = 'docs/components';
70
-
71
- if(!fs.existsSync(componentsDir)){
72
- return;
73
- }
74
-
75
- if(!fs.existsSync(docsComponentsDir)){
76
- fs.mkdirSync(docsComponentsDir, { recursive: true });
77
- console.log(`Created ${docsComponentsDir}/ directory`);
78
- }
79
-
80
- const componentFiles = fs.readdirSync(componentsDir).filter(file => file.endsWith('.js'));
81
-
82
- console.log('\nProcessing JavaScript files...');
83
- for(const file of componentFiles){
84
- const srcPath = path.join(componentsDir, file);
85
- const destPath = path.join(docsComponentsDir, file);
86
-
87
- try{
88
- const code = fs.readFileSync(srcPath, 'utf-8');
89
-
90
- if(file.endsWith('.min.js')){
91
- fs.writeFileSync(destPath, code);
92
- console.log(`Copied ${srcPath} → ${destPath} (already minified)`);
93
- }else{
94
- console.log(`Minifying ${srcPath}...`);
95
- const result = await minify(code);
96
- fs.writeFileSync(destPath, result.code);
97
- const originalSize = Buffer.byteLength(code, 'utf-8');
98
- const minifiedSize = Buffer.byteLength(result.code, 'utf-8');
99
- const savings = ((originalSize - minifiedSize) / originalSize * 100).toFixed(1);
100
- console.log(` Original: ${(originalSize / 1024).toFixed(1)}KB`);
101
- console.log(` Minified: ${(minifiedSize / 1024).toFixed(1)}KB`);
102
- console.log(` Savings: ${savings}%`);
103
- }
104
- }catch(error){
105
- console.error(`Error processing ${srcPath}:`, error.message);
106
- }
107
- }
108
- }
109
-
110
- processComponents().then(() => {
111
-
112
- // Copy CSS to docs
113
- const cssFiles = ['src/kempo.css', 'src/kempo-hljs.css'];
114
- const docsDir = 'docs';
115
-
116
- cssFiles.forEach(file => {
117
- if(fs.existsSync(file)){
118
- const fileName = path.basename(file);
119
- const destPath = path.join(docsDir, fileName);
120
- fs.copyFileSync(file, destPath);
121
- console.log(`Copied ${file} → ${destPath}`);
122
- }
123
- });
124
-
125
- // Copy minified CSS to docs
126
- const minifiedFiles = fs.readdirSync(outputDir).filter(file => file.endsWith('.css'));
127
- minifiedFiles.forEach(file => {
128
- const srcPath = path.join(outputDir, file);
129
- const destPath = path.join(docsDir, file);
130
- fs.copyFileSync(srcPath, destPath);
131
- console.log(`Copied ${srcPath} → ${destPath}`);
132
- });
133
-
134
- console.log('\nBuild complete!');
135
- console.log(`Minified files are in the ${outputDir}/ directory`);
136
- }).catch(error => {
137
- console.error('Build error:', error);
138
- process.exit(1);
139
- });
140
-
141
- // Watch mode functionality
142
- if (isWatchMode) {
143
- console.log('Watching for changes... (Press Ctrl+C to stop)\n');
144
-
145
- inputFiles.forEach(inputFile => {
146
- if (fs.existsSync(inputFile)) {
147
- fs.watchFile(inputFile, { interval: 1000 }, (curr, prev) => {
148
- if (curr.mtime !== prev.mtime) {
149
- console.log(`\n${inputFile} changed, rebuilding...`);
150
-
151
- // Find the corresponding output file
152
- const index = inputFiles.indexOf(inputFile);
153
- const outputFile = path.join(outputDir, outputFiles[index]);
154
- try {
155
- const originalSize = fs.statSync(inputFile).size;
156
- console.log(`Minifying ${inputFile}...`);
157
- execSync(`npx cleancss -o ${outputFile} ${inputFile}`, { stdio: 'inherit' });
158
-
159
- const minifiedSize = fs.statSync(outputFile).size;
160
- const savings = ((originalSize - minifiedSize) / originalSize * 100).toFixed(1);
161
-
162
- console.log(`${inputFile} → ${outputFile}`);
163
- console.log(` Original: ${(originalSize / 1024).toFixed(1)}KB`);
164
- console.log(` Minified: ${(minifiedSize / 1024).toFixed(1)}KB`);
165
- console.log(` Savings: ${savings}%`);
166
- console.log('\nWatching for changes...');
167
- } catch (error) {
168
- console.error(`Error minifying ${inputFile}:`, error.message);
169
- }
170
- }
171
- });
172
- }
173
- });
1
+ #!/usr/bin/env node
2
+
3
+ import { execSync } from 'child_process';
4
+ import fs from 'fs';
5
+ import path from 'path';
6
+ import { minify } from 'terser';
7
+
8
+ // Check for watch flag
9
+ const isWatchMode = process.argv.includes('--watch');
10
+
11
+ if (isWatchMode) {
12
+ console.log('Watch mode enabled - monitoring CSS files for changes...\n');
13
+ } else {
14
+ console.log('Building Kempo CSS...\n');
15
+ }
16
+
17
+ // Define input and output files
18
+ const inputFiles = [
19
+ 'src/kempo.css',
20
+ 'src/kempo-hljs.css'
21
+ ];
22
+
23
+ const outputDir = 'dist';
24
+ const outputFiles = [
25
+ 'kempo.min.css',
26
+ 'kempo-hljs.min.css'
27
+ ];
28
+
29
+ // Create dist directory if it doesn't exist
30
+ if (!fs.existsSync(outputDir)) {
31
+ fs.mkdirSync(outputDir);
32
+ console.log(`Created ${outputDir}/ directory`);
33
+ }
34
+
35
+ // Minify each CSS file
36
+ inputFiles.forEach((inputFile, index) => {
37
+ const outputFile = path.join(outputDir, outputFiles[index]);
38
+
39
+ try {
40
+ // Check if input file exists
41
+ if (!fs.existsSync(inputFile)) {
42
+ console.log(`Skipping ${inputFile} (file not found)`);
43
+ return;
44
+ }
45
+
46
+ // Get file size before minification
47
+ const originalSize = fs.statSync(inputFile).size;
48
+
49
+ // Minify the CSS using clean-css-cli
50
+ console.log(`Minifying ${inputFile}...`);
51
+ execSync(`npx cleancss -o ${outputFile} ${inputFile}`, { stdio: 'inherit' });
52
+
53
+ // Get file size after minification
54
+ const minifiedSize = fs.statSync(outputFile).size;
55
+ const savings = ((originalSize - minifiedSize) / originalSize * 100).toFixed(1);
56
+
57
+ console.log(`${inputFile} → ${outputFile}`);
58
+ console.log(` Original: ${(originalSize / 1024).toFixed(1)}KB`);
59
+ console.log(` Minified: ${(minifiedSize / 1024).toFixed(1)}KB`);
60
+ console.log(` Savings: ${savings}%\n`);
61
+ } catch (error) {
62
+ console.error(`Error minifying ${inputFile}:`, error.message);
63
+ }
64
+ });
65
+
66
+ // Process and minify components
67
+ async function processComponents(){
68
+ const componentsDir = 'src/components';
69
+ const docsComponentsDir = 'docs/components';
70
+
71
+ if(!fs.existsSync(componentsDir)){
72
+ return;
73
+ }
74
+
75
+ if(!fs.existsSync(docsComponentsDir)){
76
+ fs.mkdirSync(docsComponentsDir, { recursive: true });
77
+ console.log(`Created ${docsComponentsDir}/ directory`);
78
+ }
79
+
80
+ const componentFiles = fs.readdirSync(componentsDir).filter(file => file.endsWith('.js'));
81
+
82
+ console.log('\nProcessing JavaScript files...');
83
+ for(const file of componentFiles){
84
+ const srcPath = path.join(componentsDir, file);
85
+ const destPath = path.join(docsComponentsDir, file);
86
+
87
+ try{
88
+ const code = fs.readFileSync(srcPath, 'utf-8');
89
+
90
+ if(file.endsWith('.min.js')){
91
+ fs.writeFileSync(destPath, code);
92
+ console.log(`Copied ${srcPath} → ${destPath} (already minified)`);
93
+ }else{
94
+ console.log(`Minifying ${srcPath}...`);
95
+ const result = await minify(code);
96
+ fs.writeFileSync(destPath, result.code);
97
+ const originalSize = Buffer.byteLength(code, 'utf-8');
98
+ const minifiedSize = Buffer.byteLength(result.code, 'utf-8');
99
+ const savings = ((originalSize - minifiedSize) / originalSize * 100).toFixed(1);
100
+ console.log(` Original: ${(originalSize / 1024).toFixed(1)}KB`);
101
+ console.log(` Minified: ${(minifiedSize / 1024).toFixed(1)}KB`);
102
+ console.log(` Savings: ${savings}%`);
103
+ }
104
+ }catch(error){
105
+ console.error(`Error processing ${srcPath}:`, error.message);
106
+ }
107
+ }
108
+ }
109
+
110
+ processComponents().then(() => {
111
+
112
+ // Copy CSS to docs
113
+ const cssFiles = ['src/kempo.css', 'src/kempo-hljs.css'];
114
+ const docsDir = 'docs';
115
+
116
+ cssFiles.forEach(file => {
117
+ if(fs.existsSync(file)){
118
+ const fileName = path.basename(file);
119
+ const destPath = path.join(docsDir, fileName);
120
+ fs.copyFileSync(file, destPath);
121
+ console.log(`Copied ${file} → ${destPath}`);
122
+ }
123
+ });
124
+
125
+ // Copy minified CSS to docs
126
+ const minifiedFiles = fs.readdirSync(outputDir).filter(file => file.endsWith('.css'));
127
+ minifiedFiles.forEach(file => {
128
+ const srcPath = path.join(outputDir, file);
129
+ const destPath = path.join(docsDir, file);
130
+ fs.copyFileSync(srcPath, destPath);
131
+ console.log(`Copied ${srcPath} → ${destPath}`);
132
+ });
133
+
134
+ console.log('\nBuild complete!');
135
+ console.log(`Minified files are in the ${outputDir}/ directory`);
136
+ }).catch(error => {
137
+ console.error('Build error:', error);
138
+ process.exit(1);
139
+ });
140
+
141
+ // Watch mode functionality
142
+ if (isWatchMode) {
143
+ console.log('Watching for changes... (Press Ctrl+C to stop)\n');
144
+
145
+ inputFiles.forEach(inputFile => {
146
+ if (fs.existsSync(inputFile)) {
147
+ fs.watchFile(inputFile, { interval: 1000 }, (curr, prev) => {
148
+ if (curr.mtime !== prev.mtime) {
149
+ console.log(`\n${inputFile} changed, rebuilding...`);
150
+
151
+ // Find the corresponding output file
152
+ const index = inputFiles.indexOf(inputFile);
153
+ const outputFile = path.join(outputDir, outputFiles[index]);
154
+ try {
155
+ const originalSize = fs.statSync(inputFile).size;
156
+ console.log(`Minifying ${inputFile}...`);
157
+ execSync(`npx cleancss -o ${outputFile} ${inputFile}`, { stdio: 'inherit' });
158
+
159
+ const minifiedSize = fs.statSync(outputFile).size;
160
+ const savings = ((originalSize - minifiedSize) / originalSize * 100).toFixed(1);
161
+
162
+ console.log(`${inputFile} → ${outputFile}`);
163
+ console.log(` Original: ${(originalSize / 1024).toFixed(1)}KB`);
164
+ console.log(` Minified: ${(minifiedSize / 1024).toFixed(1)}KB`);
165
+ console.log(` Savings: ${savings}%`);
166
+ console.log('\nWatching for changes...');
167
+ } catch (error) {
168
+ console.error(`Error minifying ${inputFile}:`, error.message);
169
+ }
170
+ }
171
+ });
172
+ }
173
+ });
174
174
  }
@@ -1,125 +1,125 @@
1
- :root {
2
- --c_text: light-dark(#000000, #DCDCDC);
3
- --c_keyword: light-dark(#0000ff, #569CD6);
4
- --c_builtin: light-dark(#00b0e8, #4EC9B0);
5
- --c_number: light-dark(#709756, #B8D7A3);
6
- --c_string: light-dark(#a31515, #D69D85);
7
- --c_regex: light-dark(#914525, #9A5334);
8
- --c_function: inherit;
9
- --c_comment: light-dark(#008000, #57A64A);
10
- --c_doc: light-dark(#808080, #608B4E);
11
- --c_tag: light-dark(#7d7d7d, #9B9B9B);
12
- --c_var: light-dark(#b436bf, #BD63C5);
13
- --c_attr: light-dark(#ff0000, #9CDCFE);
14
- --c_section: light-dark(#a31515, #ffd700);
15
- --c_selector: light-dark(#0000ff, #569CD6);
16
- --c_addition: light-dark(#a31515, #144212);
17
- --c_deletion: light-dark(#2b91af, #600);
18
- --c_caret: light-dark(black, white);
19
- }
20
-
21
- .hljs {
22
- display: block;
23
- overflow-x: auto;
24
- color: var(--c_text);
25
- }
26
-
27
- .hljs-keyword,
28
- .hljs-literal,
29
- .hljs-symbol,
30
- .hljs-name,
31
- .hljs-link {
32
- color: var(--c_keyword);
33
- }
34
-
35
- .hljs-link {
36
- text-decoration: underline;
37
- }
38
-
39
- .hljs-built_in,
40
- .hljs-type {
41
- color: var(--c_builtin);
42
- }
43
-
44
- .hljs-number,
45
- .hljs-class {
46
- color: var(--c_number);
47
- }
48
-
49
- .hljs-string,
50
- .hljs-meta-string {
51
- color: var(--c_string);
52
- }
53
-
54
- .hljs-regexp,
55
- .hljs-template-tag {
56
- color: var(--c_regex);
57
- }
58
-
59
- .hljs-subst,
60
- .hljs-function,
61
- .hljs-title,
62
- .hljs-params,
63
- .hljs-formula {
64
- color: var(--c_function);
65
- }
66
-
67
- .hljs-comment,
68
- .hljs-quote {
69
- color: var(--c_comment);
70
- font-style: italic
71
- }
72
-
73
- .hljs-doctag {
74
- color: var(--c_doc);
75
- }
76
-
77
- .hljs-meta,
78
- .hljs-meta-keyword,
79
- .hljs-tag {
80
- color: var(--c_tag);
81
- }
82
-
83
- .hljs-variable,
84
- .hljs-template-variable {
85
- color: var(--c_var);
86
- }
87
-
88
- .hljs-attr,
89
- .hljs-attribute,
90
- .hljs-builtin-name {
91
- color: var(--c_attr);
92
- }
93
-
94
- .hljs-section {
95
- color: var(--c_section);
96
- }
97
-
98
- .hljs-emphasis {
99
- font-style: italic
100
- }
101
-
102
- .hljs-strong {
103
- font-weight: bold
104
- }
105
-
106
- .hljs-bullet,
107
- .hljs-selector-tag,
108
- .hljs-selector-id,
109
- .hljs-selector-class,
110
- .hljs-selector-attr,
111
- .hljs-selector-pseudo {
112
- color: var(--c_selector);
113
- }
114
-
115
- .hljs-addition {
116
- background-color: var(--c_addition);
117
- display: inline-block;
118
- width: 100%
119
- }
120
-
121
- .hljs-deletion {
122
- background-color: var(--c_deletion);
123
- display: inline-block;
124
- width: 100%
1
+ :root {
2
+ --c_text: light-dark(#000000, #DCDCDC);
3
+ --c_keyword: light-dark(#0000ff, #569CD6);
4
+ --c_builtin: light-dark(#00b0e8, #4EC9B0);
5
+ --c_number: light-dark(#709756, #B8D7A3);
6
+ --c_string: light-dark(#a31515, #D69D85);
7
+ --c_regex: light-dark(#914525, #9A5334);
8
+ --c_function: inherit;
9
+ --c_comment: light-dark(#008000, #57A64A);
10
+ --c_doc: light-dark(#808080, #608B4E);
11
+ --c_tag: light-dark(#7d7d7d, #9B9B9B);
12
+ --c_var: light-dark(#b436bf, #BD63C5);
13
+ --c_attr: light-dark(#ff0000, #9CDCFE);
14
+ --c_section: light-dark(#a31515, #ffd700);
15
+ --c_selector: light-dark(#0000ff, #569CD6);
16
+ --c_addition: light-dark(#a31515, #144212);
17
+ --c_deletion: light-dark(#2b91af, #600);
18
+ --c_caret: light-dark(black, white);
19
+ }
20
+
21
+ .hljs {
22
+ display: block;
23
+ overflow-x: auto;
24
+ color: var(--c_text);
25
+ }
26
+
27
+ .hljs-keyword,
28
+ .hljs-literal,
29
+ .hljs-symbol,
30
+ .hljs-name,
31
+ .hljs-link {
32
+ color: var(--c_keyword);
33
+ }
34
+
35
+ .hljs-link {
36
+ text-decoration: underline;
37
+ }
38
+
39
+ .hljs-built_in,
40
+ .hljs-type {
41
+ color: var(--c_builtin);
42
+ }
43
+
44
+ .hljs-number,
45
+ .hljs-class {
46
+ color: var(--c_number);
47
+ }
48
+
49
+ .hljs-string,
50
+ .hljs-meta-string {
51
+ color: var(--c_string);
52
+ }
53
+
54
+ .hljs-regexp,
55
+ .hljs-template-tag {
56
+ color: var(--c_regex);
57
+ }
58
+
59
+ .hljs-subst,
60
+ .hljs-function,
61
+ .hljs-title,
62
+ .hljs-params,
63
+ .hljs-formula {
64
+ color: var(--c_function);
65
+ }
66
+
67
+ .hljs-comment,
68
+ .hljs-quote {
69
+ color: var(--c_comment);
70
+ font-style: italic
71
+ }
72
+
73
+ .hljs-doctag {
74
+ color: var(--c_doc);
75
+ }
76
+
77
+ .hljs-meta,
78
+ .hljs-meta-keyword,
79
+ .hljs-tag {
80
+ color: var(--c_tag);
81
+ }
82
+
83
+ .hljs-variable,
84
+ .hljs-template-variable {
85
+ color: var(--c_var);
86
+ }
87
+
88
+ .hljs-attr,
89
+ .hljs-attribute,
90
+ .hljs-builtin-name {
91
+ color: var(--c_attr);
92
+ }
93
+
94
+ .hljs-section {
95
+ color: var(--c_section);
96
+ }
97
+
98
+ .hljs-emphasis {
99
+ font-style: italic
100
+ }
101
+
102
+ .hljs-strong {
103
+ font-weight: bold
104
+ }
105
+
106
+ .hljs-bullet,
107
+ .hljs-selector-tag,
108
+ .hljs-selector-id,
109
+ .hljs-selector-class,
110
+ .hljs-selector-attr,
111
+ .hljs-selector-pseudo {
112
+ color: var(--c_selector);
113
+ }
114
+
115
+ .hljs-addition {
116
+ background-color: var(--c_addition);
117
+ display: inline-block;
118
+ width: 100%
119
+ }
120
+
121
+ .hljs-deletion {
122
+ background-color: var(--c_deletion);
123
+ display: inline-block;
124
+ width: 100%
125
125
  }