styimat 1.11.0 → 1.11.1

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.
Files changed (2) hide show
  1. package/convert-styimat.js +18 -16
  2. package/package.json +1 -1
@@ -38,17 +38,17 @@ async function main() {
38
38
 
39
39
  function showHelp() {
40
40
  console.log(`
41
- 用法: huecss-converter [选项] [输入文件] [输出文件]
41
+ 用法: styimat [选项] [输入文件] [输出文件]
42
42
 
43
43
  选项:
44
44
  -w, --watch 监控输入文件变化并自动转换
45
45
  -h, --help 显示帮助信息
46
46
 
47
47
  示例:
48
- huecss-converter # 从 stdin 读取,输出到 stdout
49
- huecss-converter input.css # 从文件读取,输出到 stdout
50
- huecss-converter input.css output.css # 从文件读取,输出到文件
51
- huecss-converter -w input.css output.css # 监控并自动转换
48
+ styimat # 从 stdin 读取,输出到 stdout
49
+ styimat input.css # 从文件读取,输出到 stdout
50
+ styimat input.css output.css # 从文件读取,输出到文件
51
+ styimat -w input.css output.css # 监控并自动转换
52
52
  `);
53
53
  }
54
54
 
@@ -104,7 +104,8 @@ async function main() {
104
104
 
105
105
  // 处理进程终止
106
106
  process.on('SIGINT', () => {
107
- console.log('\n停止监控...');
107
+ console.log('
108
+ 停止监控...');
108
109
  watcher.close();
109
110
  process.exit(0);
110
111
  });
@@ -119,7 +120,7 @@ async function main() {
119
120
  async function convertFile(inputFilePath, outputFilePath) {
120
121
  try {
121
122
  const inputContent = fs.readFileSync(inputFilePath, 'utf8');
122
- const outputContent = await convertHuecss(inputContent);
123
+ const outputContent = await convertStyimat(inputContent);
123
124
  fs.writeFileSync(outputFilePath, outputContent, 'utf8');
124
125
  console.log(`${new Date().toLocaleTimeString()} - 转换完成: ${inputFilePath} -> ${outputFilePath}`);
125
126
  } catch (error) {
@@ -129,12 +130,13 @@ async function convertFile(inputFilePath, outputFilePath) {
129
130
 
130
131
  async function convertAndOutput(inputContent, outputFile) {
131
132
  try {
132
- const outputContent = await convertHuecss(inputContent);
133
+ const outputContent = await convertStyimat(inputContent);
133
134
 
134
135
  if (outputFile) {
135
136
  fs.writeFileSync(outputFile, outputContent, 'utf8');
136
137
  } else {
137
- process.stdout.write(outputContent + '\n');
138
+ process.stdout.write(outputContent + '
139
+ ');
138
140
  }
139
141
  } catch (error) {
140
142
  console.error('转换错误:', error.message);
@@ -142,7 +144,7 @@ async function convertAndOutput(inputContent, outputFile) {
142
144
  }
143
145
  }
144
146
 
145
- async function convertHuecss(inputContent) {
147
+ async function convertStyimat(inputContent) {
146
148
  // 尝试从多个位置加载 styimat.js
147
149
  const possiblePaths = [
148
150
  path.join(__dirname, 'styimat.js'),
@@ -150,11 +152,11 @@ async function convertHuecss(inputContent) {
150
152
  path.join(process.cwd(), 'node_modules', 'styimat', 'styimat.js')
151
153
  ];
152
154
 
153
- let huecssModule = null;
155
+ let styimatModule = null;
154
156
  for (const modulePath of possiblePaths) {
155
157
  try {
156
158
  if (fs.existsSync(modulePath)) {
157
- huecssModule = require(modulePath);
159
+ styimatModule = require(modulePath);
158
160
  break;
159
161
  }
160
162
  } catch (e) {
@@ -162,19 +164,19 @@ async function convertHuecss(inputContent) {
162
164
  }
163
165
  }
164
166
 
165
- if (!huecssModule) {
167
+ if (!styimatModule) {
166
168
  throw new Error('找不到 styimat.js 模块');
167
169
  }
168
170
 
169
171
  // 获取转换函数
170
- const huecss = huecssModule.huecss || huecssModule;
172
+ const styimat = styimatModule.styimat || styimatModule;
171
173
 
172
- if (typeof huecss.convert !== 'function') {
174
+ if (typeof styimat.convert !== 'function') {
173
175
  throw new Error('styimat.convert 不是函数');
174
176
  }
175
177
 
176
178
  // 执行转换
177
- return await huecss.convert(inputContent);
179
+ return await styimat.convert(inputContent);
178
180
  }
179
181
 
180
182
  // 处理 promise 错误
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "styimat",
3
- "version": "1.11.0",
3
+ "version": "1.11.1",
4
4
  "description": "一个高效的CSS变量预处理库,支持Lab/LCH颜色空间自动转换、嵌套选择器和Display P3广色域,让现代CSS开发更简洁强大。",
5
5
  "keywords": [
6
6
  "css",