pinyin-ruby 1.0.0 → 1.0.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.
@@ -10,14 +10,11 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  }
11
11
  return t;
12
12
  };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
13
  Object.defineProperty(exports, "__esModule", { value: true });
17
14
  exports.ruby = ruby;
18
15
  exports.rubyDetails = rubyDetails;
19
16
  exports.rubyHeteonym = rubyHeteonym;
20
- const pinyin_1 = __importDefault(require("pinyin"));
17
+ const pinyin_1 = require("pinyin");
21
18
  /**
22
19
  * 生成单个字符的 Ruby 标签
23
20
  */
@@ -72,7 +69,7 @@ function ruby(text, options) {
72
69
  return '';
73
70
  }
74
71
  const _a = options || {}, { format = 'html', skipNonChinese = true } = _a, pinyinOptions = __rest(_a, ["format", "skipNonChinese"]);
75
- const pinyinResult = (0, pinyin_1.default)(text, pinyinOptions);
72
+ const pinyinResult = (0, pinyin_1.pinyin)(text, pinyinOptions);
76
73
  const result = [];
77
74
  for (let i = 0; i < text.length; i++) {
78
75
  const char = text[i];
@@ -99,7 +96,7 @@ function rubyDetails(text, options) {
99
96
  return [];
100
97
  }
101
98
  const pinyinOptions = Object.assign({}, options);
102
- const pinyinResult = (0, pinyin_1.default)(text, pinyinOptions);
99
+ const pinyinResult = (0, pinyin_1.pinyin)(text, pinyinOptions);
103
100
  const result = [];
104
101
  for (let i = 0; i < text.length; i++) {
105
102
  const char = text[i];
@@ -125,7 +122,7 @@ function rubyHeteonym(text, options) {
125
122
  return '';
126
123
  }
127
124
  const _a = options || {}, { format = 'html', skipNonChinese = true } = _a, pinyinOptions = __rest(_a, ["format", "skipNonChinese"]);
128
- const pinyinResult = (0, pinyin_1.default)(text, Object.assign(Object.assign({}, pinyinOptions), { heteronym: true }));
125
+ const pinyinResult = (0, pinyin_1.pinyin)(text, Object.assign(Object.assign({}, pinyinOptions), { heteronym: true }));
129
126
  const result = [];
130
127
  for (let i = 0; i < text.length; i++) {
131
128
  const char = text[i];
@@ -157,6 +154,7 @@ function rubyHeteonym(text, options) {
157
154
  }
158
155
  return result.join('');
159
156
  }
157
+ // 保留默认导出以保持向后兼容性
160
158
  exports.default = {
161
159
  ruby,
162
160
  rubyDetails,
package/lib/esm/index.js CHANGED
@@ -9,7 +9,7 @@ var __rest = (this && this.__rest) || function (s, e) {
9
9
  }
10
10
  return t;
11
11
  };
12
- import pinyin from 'pinyin';
12
+ import { pinyin } from 'pinyin';
13
13
  /**
14
14
  * 生成单个字符的 Ruby 标签
15
15
  */
@@ -149,6 +149,7 @@ export function rubyHeteonym(text, options) {
149
149
  }
150
150
  return result.join('');
151
151
  }
152
+ // 保留默认导出以保持向后兼容性
152
153
  export default {
153
154
  ruby,
154
155
  rubyDetails,
package/package.json CHANGED
@@ -1,22 +1,22 @@
1
1
  {
2
2
  "name": "pinyin-ruby",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "生成带注音的Ruby标签的拼音工具(支持 HTML <ruby> 输出)",
5
5
  "types": "./lib/types/index.d.ts",
6
- "main": "./lib/cjs/index.js",
6
+ "main": "./lib/cjs/index.cjs",
7
7
  "module": "./lib/esm/index.js",
8
8
  "exports": {
9
9
  ".": {
10
10
  "types": "./lib/types/index.d.ts",
11
11
  "import": "./lib/esm/index.js",
12
- "require": "./lib/cjs/index.js"
12
+ "require": "./lib/cjs/index.cjs"
13
13
  }
14
14
  },
15
15
  "files": [
16
16
  "lib"
17
17
  ],
18
18
  "scripts": {
19
- "build": "tsc -p tsconfig.json && tsc -p tsconfig.esm.json",
19
+ "build": "tsc -p tsconfig.json && tsc -p tsconfig.esm.json && mv lib/cjs/index.js lib/cjs/index.cjs",
20
20
  "test": "jest",
21
21
  "dev": "tsc -p tsconfig.json --watch"
22
22
  },
@@ -24,7 +24,10 @@
24
24
  "pinyin": ">=4.0.0"
25
25
  },
26
26
  "devDependencies": {
27
+ "@types/jest": "^29.0.0",
27
28
  "@types/node": "^20.0.0",
29
+ "jest": "^29.0.0",
30
+ "ts-jest": "^29.0.0",
28
31
  "typescript": "^5.0.0",
29
32
  "pinyin": "^4.0.0"
30
33
  },
@@ -37,6 +40,10 @@
37
40
  "注音"
38
41
  ],
39
42
  "author": "mkoplqq2006",
40
- "license": "MIT"
43
+ "license": "MIT",
44
+ "directories": {
45
+ "example": "examples",
46
+ "lib": "lib",
47
+ "test": "test"
48
+ }
41
49
  }
42
-