@tiny-codes/react-easy 1.4.7 → 1.4.9

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 (80) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/es/assets/request-camera-en.js +1 -1
  3. package/es/assets/request-camera-zh.js +1 -1
  4. package/es/assets/request-microphone-en.js +1 -1
  5. package/es/assets/request-microphone-zh.js +1 -1
  6. package/es/assets/reset-camera-en.js +1 -1
  7. package/es/assets/reset-camera-zh.js +1 -1
  8. package/es/assets/reset-microphone-en.js +1 -1
  9. package/es/assets/reset-microphone-zh.js +1 -1
  10. package/es/assets/save-default-audio1-en.js +1 -1
  11. package/es/assets/save-default-audio1-zh.js +1 -1
  12. package/es/assets/save-default-audio2-en.js +1 -1
  13. package/es/assets/save-default-audio2-zh.js +1 -1
  14. package/es/hooks/index.d.ts +6 -0
  15. package/es/hooks/index.js +6 -0
  16. package/es/hooks/index.js.map +1 -1
  17. package/es/hooks/useAudioPlayer.d.ts +7 -0
  18. package/es/hooks/useAudioPlayer.js +13 -0
  19. package/es/hooks/useAudioPlayer.js.map +1 -0
  20. package/es/hooks/useSSE.d.ts +26 -0
  21. package/es/hooks/useSSE.js +147 -0
  22. package/es/hooks/useSSE.js.map +1 -0
  23. package/es/hooks/useStompSocket.d.ts +63 -0
  24. package/es/hooks/useStompSocket.js +182 -0
  25. package/es/hooks/useStompSocket.js.map +1 -0
  26. package/es/hooks/useUserMedia.js +12 -24
  27. package/es/hooks/useUserMedia.js.map +1 -1
  28. package/es/locales/index.d.ts +6 -0
  29. package/es/locales/langs/en-US.d.ts +2 -0
  30. package/es/locales/langs/en-US.js +3 -1
  31. package/es/locales/langs/en-US.js.map +1 -1
  32. package/es/locales/langs/zh-CN.d.ts +2 -0
  33. package/es/locales/langs/zh-CN.js +3 -1
  34. package/es/locales/langs/zh-CN.js.map +1 -1
  35. package/es/utils/AudioPlayer.d.ts +159 -0
  36. package/es/utils/AudioPlayer.js +433 -0
  37. package/es/utils/AudioPlayer.js.map +1 -0
  38. package/es/utils/base64.d.ts +48 -0
  39. package/es/utils/base64.js +139 -0
  40. package/es/utils/base64.js.map +1 -0
  41. package/es/utils/crypto.d.ts +0 -30
  42. package/es/utils/crypto.js +8 -93
  43. package/es/utils/crypto.js.map +1 -1
  44. package/es/utils/index.d.ts +5 -1
  45. package/es/utils/index.js +5 -1
  46. package/es/utils/index.js.map +1 -1
  47. package/lib/hooks/index.d.ts +6 -0
  48. package/lib/hooks/index.js +17 -1
  49. package/lib/hooks/index.js.map +2 -2
  50. package/lib/hooks/useAudioPlayer.d.ts +7 -0
  51. package/lib/hooks/useAudioPlayer.js +42 -0
  52. package/lib/hooks/useAudioPlayer.js.map +7 -0
  53. package/lib/hooks/useSSE.d.ts +26 -0
  54. package/lib/hooks/useSSE.js +128 -0
  55. package/lib/hooks/useSSE.js.map +7 -0
  56. package/lib/hooks/useStompSocket.d.ts +63 -0
  57. package/lib/hooks/useStompSocket.js +154 -0
  58. package/lib/hooks/useStompSocket.js.map +7 -0
  59. package/lib/hooks/useUserMedia.js +12 -24
  60. package/lib/hooks/useUserMedia.js.map +2 -2
  61. package/lib/locales/index.d.ts +6 -0
  62. package/lib/locales/langs/en-US.d.ts +2 -0
  63. package/lib/locales/langs/en-US.js +3 -1
  64. package/lib/locales/langs/en-US.js.map +2 -2
  65. package/lib/locales/langs/zh-CN.d.ts +2 -0
  66. package/lib/locales/langs/zh-CN.js +3 -1
  67. package/lib/locales/langs/zh-CN.js.map +2 -2
  68. package/lib/utils/AudioPlayer.d.ts +159 -0
  69. package/lib/utils/AudioPlayer.js +284 -0
  70. package/lib/utils/AudioPlayer.js.map +7 -0
  71. package/lib/utils/base64.d.ts +48 -0
  72. package/lib/utils/base64.js +120 -0
  73. package/lib/utils/base64.js.map +7 -0
  74. package/lib/utils/crypto.d.ts +0 -30
  75. package/lib/utils/crypto.js +7 -66
  76. package/lib/utils/crypto.js.map +2 -2
  77. package/lib/utils/index.d.ts +5 -1
  78. package/lib/utils/index.js +28 -3
  79. package/lib/utils/index.js.map +2 -2
  80. package/package.json +10 -3
@@ -24,33 +24,3 @@ export declare function encryptAES(text: string, key: string): Promise<string>;
24
24
  * @returns The decrypted text
25
25
  */
26
26
  export declare function decryptAES(encryptedText: string, key: string): Promise<string>;
27
- /**
28
- * - **EN:** Encode a UTF-8 string into Base64 (standard or URL-safe).
29
- * - **CN:** 将 UTF-8 字符串编码为 Base64(标准或 URL 安全格式)。
30
- *
31
- * @param content Input text to encode | 要编码的输入文本
32
- *
33
- * @returns Base64 encoded string | Base64 编码后的字符串
34
- */
35
- export declare function toBase64(content: string, opts?: {
36
- /**
37
- * - **EN:** Use URL-safe Base64 if true (replace +/ with -_ and strip =)
38
- * - **CN:** 为 true 时使用 URL 安全 Base64(将 +/ 替换为 -_ 并去掉 =)
39
- */
40
- urlSafe?: boolean;
41
- }): string;
42
- /**
43
- * - EN: Decode a Base64 (standard or URL-safe) string into UTF-8 text.
44
- * - CN: 将(标准或 URL 安全)Base64 字符串解码为 UTF-8 文本。
45
- *
46
- * @param content Base64 encoded string | Base64 编码字符串
47
- *
48
- * @returns Decoded UTF-8 string | 解码后的 UTF-8 字符串
49
- */
50
- export declare function fromBase64(content: string, opts?: {
51
- /**
52
- * - **EN:** Use URL-safe Base64 if true (replace +/ with -_ and strip =)
53
- * - **CN:** 为 true 时使用 URL 安全 Base64(将 +/ 替换为 -_ 并去掉 =)
54
- */
55
- urlSafe?: boolean;
56
- }): string;
@@ -22,29 +22,28 @@ __export(crypto_exports, {
22
22
  advancedDecrypt: () => advancedDecrypt,
23
23
  advancedEncrypt: () => advancedEncrypt,
24
24
  decryptAES: () => decryptAES,
25
- encryptAES: () => encryptAES,
26
- fromBase64: () => fromBase64,
27
- toBase64: () => toBase64
25
+ encryptAES: () => encryptAES
28
26
  });
29
27
  module.exports = __toCommonJS(crypto_exports);
28
+ var import_base64 = require("./base64");
30
29
  var import_math = require("./math");
31
30
  var import_string = require("./string");
32
31
  async function advancedEncrypt(plainText, key) {
33
32
  const k1 = (0, import_string.randomChars)(36);
34
33
  let e = await encryptAES(plainText, k1);
35
- const b = toBase64(k1);
34
+ const b = (0, import_base64.stringToBase64)(k1);
36
35
  const l = b.length;
37
36
  const s = (0, import_math.random)(0, e.length);
38
37
  e = e.substring(0, s) + b + e.substring(s);
39
- const r = toBase64(`${s}-${l}`);
38
+ const r = (0, import_base64.stringToBase64)(`${s}-${l}`);
40
39
  const t = `${e}.${r}`;
41
40
  return encryptAES(t, key);
42
41
  }
43
42
  async function advancedDecrypt(encryptedText, key) {
44
43
  const decrypted = await decryptAES(encryptedText, key);
45
44
  const [e, r] = decrypted.split(".");
46
- const [s, l] = fromBase64(r).split("-").map(Number);
47
- const k1 = fromBase64(e.substring(s, s + l));
45
+ const [s, l] = (0, import_base64.base64ToString)(r).split("-").map(Number);
46
+ const k1 = (0, import_base64.base64ToString)(e.substring(s, s + l));
48
47
  return decryptAES(e.substring(0, s) + e.substring(s + l), k1);
49
48
  }
50
49
  async function encryptAES(text, key) {
@@ -107,69 +106,11 @@ async function decryptAES(encryptedText, key) {
107
106
  return "";
108
107
  }
109
108
  }
110
- function toBase64(content, opts = {}) {
111
- const { urlSafe = false } = opts;
112
- if (content == null || content === "")
113
- return "";
114
- let base64;
115
- const hasBuffer = typeof Buffer !== "undefined" && typeof Buffer.from === "function";
116
- if (hasBuffer) {
117
- base64 = Buffer.from(content, "utf8").toString("base64");
118
- } else {
119
- const encoder = new TextEncoder();
120
- const bytes = encoder.encode(content);
121
- let binary = "";
122
- for (const i of bytes) {
123
- binary += String.fromCharCode(i);
124
- }
125
- base64 = btoa(binary);
126
- }
127
- if (urlSafe) {
128
- base64 = base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/u, "");
129
- }
130
- return base64;
131
- }
132
- function fromBase64(content, opts = {}) {
133
- const { urlSafe = false } = opts;
134
- if (content == null || content === "")
135
- return "";
136
- let normalized = content;
137
- if (urlSafe) {
138
- normalized = normalized.replace(/-/g, "+").replace(/_/g, "/");
139
- }
140
- const padNeeded = normalized.length % 4;
141
- if (padNeeded === 2)
142
- normalized += "==";
143
- else if (padNeeded === 3)
144
- normalized += "=";
145
- else if (padNeeded === 1) {
146
- throw new Error("Invalid Base64 string length");
147
- }
148
- const hasBuffer = typeof Buffer !== "undefined" && typeof Buffer.from === "function";
149
- try {
150
- if (hasBuffer) {
151
- return Buffer.from(normalized, "base64").toString("utf8");
152
- } else {
153
- const binary = atob(normalized);
154
- const len = binary.length;
155
- const bytes = new Uint8Array(len);
156
- for (let i = 0; i < len; i++) {
157
- bytes[i] = binary.charCodeAt(i);
158
- }
159
- const decoder = new TextDecoder();
160
- return decoder.decode(bytes);
161
- }
162
- } catch (e) {
163
- throw new Error("Failed to decode Base64: " + (e instanceof Error ? e.message : String(e)));
164
- }
165
- }
166
109
  // Annotate the CommonJS export names for ESM import in node:
167
110
  0 && (module.exports = {
168
111
  advancedDecrypt,
169
112
  advancedEncrypt,
170
113
  decryptAES,
171
- encryptAES,
172
- fromBase64,
173
- toBase64
114
+ encryptAES
174
115
  });
175
116
  //# sourceMappingURL=crypto.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/crypto.ts"],
4
- "sourcesContent": ["import { random } from './math';\nimport { randomChars } from './string';\n\n/** Secret. No description provided */\nexport async function advancedEncrypt(plainText: string, key: string) {\n const k1 = randomChars(36);\n let e = await encryptAES(plainText, k1);\n const b = toBase64(k1);\n const l = b.length;\n const s = random(0, e.length);\n e = e.substring(0, s) + b + e.substring(s);\n const r = toBase64(`${s}-${l}`);\n const t = `${e}.${r}`;\n return encryptAES(t, key);\n}\n\n/** Secret. No description provided */\nexport async function advancedDecrypt(encryptedText: string, key: string) {\n const decrypted = await decryptAES(encryptedText, key);\n const [e, r] = decrypted.split('.');\n const [s, l] = fromBase64(r).split('-').map(Number);\n const k1 = fromBase64(e.substring(s, s + l));\n return decryptAES(e.substring(0, s) + e.substring(s + l), k1);\n}\n\n/**\n * **EN**: General AES encryption function - supports both Node.js and browser environments\n *\n * **CN**: 通用 AES 加密函数 - 同时支持 Node.js 和浏览器环境\n *\n * @param {string} text The text to be encrypted | 要加密的文本\n * @param {string} key The encryption key | 加密密钥\n *\n * @returns {Promise<string>} The encrypted text | 加密后的文本\n */\nexport async function encryptAES(text: string, key: string): Promise<string> {\n const isNode = typeof process !== 'undefined' && process.versions != null && process.versions.node != null;\n\n if (isNode) {\n // Node.js\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const crypto = require('crypto');\n const derivedKey = crypto.createHash('sha256').update(key).digest();\n const iv = crypto.randomBytes(16);\n const cipher = crypto.createCipheriv('aes-256-cbc', derivedKey, iv);\n let encrypted = cipher.update(text, 'utf8', 'base64');\n encrypted += cipher.final('base64');\n return `${iv.toString('base64')}:${encrypted}`;\n } else {\n // Browsers\n try {\n const iv = crypto.getRandomValues(new Uint8Array(16));\n const encoder = new TextEncoder();\n const keyData = encoder.encode(key);\n const hashBuffer = await crypto.subtle.digest('SHA-256', keyData);\n const cryptoKey = await crypto.subtle.importKey('raw', hashBuffer, { name: 'AES-CBC' }, false, ['encrypt']);\n const textBytes = encoder.encode(text);\n const encryptedBuffer = await crypto.subtle.encrypt({ name: 'AES-CBC', iv }, cryptoKey, textBytes);\n const ivBase64 = btoa(String.fromCharCode(...iv));\n const encryptedBase64 = btoa(String.fromCharCode(...new Uint8Array(encryptedBuffer)));\n return `${ivBase64}:${encryptedBase64}`;\n } catch (error) {\n console.error('Encryption error:', error);\n throw error;\n }\n }\n}\n\n/**\n * **EN**: General AES decryption function - supports both Node.js and browser environments\n *\n * **CN**: 通用 AES 解密函数 - 同时支持 Node.js 和浏览器环境\n *\n * @param encryptedText The encrypted text (format: iv:encryptedContent, base64 encoded)\n * @param key The decryption key\n *\n * @returns The decrypted text\n */\nexport async function decryptAES(encryptedText: string, key: string): Promise<string> {\n const isNode = typeof process !== 'undefined' && process.versions != null && process.versions.node != null;\n try {\n const [ivBase64, encryptedBase64] = encryptedText.split(':');\n if (!ivBase64 || !encryptedBase64) {\n throw new Error('Invalid encrypted format');\n }\n if (isNode) {\n // Node.js\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const crypto = require('crypto');\n const iv = Buffer.from(ivBase64, 'base64');\n const encryptedBuffer = Buffer.from(encryptedBase64, 'base64');\n const derivedKey = crypto.createHash('sha256').update(key).digest();\n const decipher = crypto.createDecipheriv('aes-256-cbc', derivedKey, iv);\n let decrypted = decipher.update(encryptedBuffer);\n decrypted = Buffer.concat([decrypted, decipher.final()]);\n return decrypted.toString('utf8');\n } else {\n // Browsers\n const iv = Uint8Array.from(atob(ivBase64), (c) => c.charCodeAt(0));\n const encryptedData = Uint8Array.from(atob(encryptedBase64), (c) => c.charCodeAt(0));\n const encoder = new TextEncoder();\n const keyData = encoder.encode(key);\n const hashBuffer = await crypto.subtle.digest('SHA-256', keyData);\n const cryptoKey = await crypto.subtle.importKey('raw', hashBuffer, { name: 'AES-CBC' }, false, ['decrypt']);\n const decryptedBuffer = await crypto.subtle.decrypt({ name: 'AES-CBC', iv }, cryptoKey, encryptedData);\n const decoder = new TextDecoder();\n return decoder.decode(decryptedBuffer);\n }\n } catch (error) {\n console.error('Decryption error:', error);\n return '';\n }\n}\n\n/**\n * - **EN:** Encode a UTF-8 string into Base64 (standard or URL-safe).\n * - **CN:** 将 UTF-8 字符串编码为 Base64(标准或 URL 安全格式)。\n *\n * @param content Input text to encode | 要编码的输入文本\n *\n * @returns Base64 encoded string | Base64 编码后的字符串\n */\nexport function toBase64(\n content: string,\n opts: {\n /**\n * - **EN:** Use URL-safe Base64 if true (replace +/ with -_ and strip =)\n * - **CN:** 为 true 时使用 URL 安全 Base64(将 +/ 替换为 -_ 并去掉 =)\n */\n urlSafe?: boolean;\n } = {}\n): string {\n const { urlSafe = false } = opts;\n if (content == null || content === '') return '';\n\n let base64: string;\n const hasBuffer = typeof Buffer !== 'undefined' && typeof Buffer.from === 'function';\n if (hasBuffer) {\n // Node.js\n base64 = Buffer.from(content, 'utf8').toString('base64');\n } else {\n // Browser\n const encoder = new TextEncoder();\n const bytes = encoder.encode(content);\n let binary = '';\n for (const i of bytes) {\n binary += String.fromCharCode(i);\n }\n base64 = btoa(binary);\n }\n\n if (urlSafe) {\n // Replace chars and strip padding for URL-safe variant\n base64 = base64.replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=+$/u, '');\n }\n return base64;\n}\n\n/**\n * - EN: Decode a Base64 (standard or URL-safe) string into UTF-8 text.\n * - CN: 将(标准或 URL 安全)Base64 字符串解码为 UTF-8 文本。\n *\n * @param content Base64 encoded string | Base64 编码字符串\n *\n * @returns Decoded UTF-8 string | 解码后的 UTF-8 字符串\n */\nexport function fromBase64(\n content: string,\n opts: {\n /**\n * - **EN:** Use URL-safe Base64 if true (replace +/ with -_ and strip =)\n * - **CN:** 为 true 时使用 URL 安全 Base64(将 +/ 替换为 -_ 并去掉 =)\n */\n urlSafe?: boolean;\n } = {}\n): string {\n const { urlSafe = false } = opts;\n if (content == null || content === '') return '';\n\n let normalized = content;\n if (urlSafe) {\n normalized = normalized.replace(/-/g, '+').replace(/_/g, '/');\n }\n // Restore padding if stripped\n const padNeeded = normalized.length % 4;\n if (padNeeded === 2) normalized += '==';\n else if (padNeeded === 3) normalized += '=';\n else if (padNeeded === 1) {\n throw new Error('Invalid Base64 string length');\n }\n\n const hasBuffer = typeof Buffer !== 'undefined' && typeof Buffer.from === 'function';\n try {\n if (hasBuffer) {\n return Buffer.from(normalized, 'base64').toString('utf8');\n } else {\n const binary = atob(normalized);\n const len = binary.length;\n const bytes = new Uint8Array(len);\n for (let i = 0; i < len; i++) {\n bytes[i] = binary.charCodeAt(i);\n }\n const decoder = new TextDecoder();\n return decoder.decode(bytes);\n }\n } catch (e) {\n throw new Error('Failed to decode Base64: ' + (e instanceof Error ? e.message : String(e)));\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;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jC;AACA,aAAS,KAAK,MAAM;AAAA,EACtB;AAEA,MAAI,SAAS;AAEX,aAAS,OAAO,QAAQ,OAAO,GAAG,EAAE,QAAQ,OAAO,GAAG,EAAE,QAAQ,QAAQ,EAAE;AAAA,EAC5E;AACA,SAAO;AACT;AAUO,SAAS,WACd,SACA,OAMI,CAAC,GACG;AACR,QAAM,EAAE,UAAU,MAAM,IAAI;AAC5B,MAAI,WAAW,QAAQ,YAAY;AAAI,WAAO;AAE9C,MAAI,aAAa;AACjB,MAAI,SAAS;AACX,iBAAa,WAAW,QAAQ,MAAM,GAAG,EAAE,QAAQ,MAAM,GAAG;AAAA,EAC9D;AAEA,QAAM,YAAY,WAAW,SAAS;AACtC,MAAI,cAAc;AAAG,kBAAc;AAAA,WAC1B,cAAc;AAAG,kBAAc;AAAA,WAC/B,cAAc,GAAG;AACxB,UAAM,IAAI,MAAM,8BAA8B;AAAA,EAChD;AAEA,QAAM,YAAY,OAAO,WAAW,eAAe,OAAO,OAAO,SAAS;AAC1E,MAAI;AACF,QAAI,WAAW;AACb,aAAO,OAAO,KAAK,YAAY,QAAQ,EAAE,SAAS,MAAM;AAAA,IAC1D,OAAO;AACL,YAAM,SAAS,KAAK,UAAU;AAC9B,YAAM,MAAM,OAAO;AACnB,YAAM,QAAQ,IAAI,WAAW,GAAG;AAChC,eAAS,IAAI,GAAG,IAAI,KAAK,KAAK;AAC5B,cAAM,CAAC,IAAI,OAAO,WAAW,CAAC;AAAA,MAChC;AACA,YAAM,UAAU,IAAI,YAAY;AAChC,aAAO,QAAQ,OAAO,KAAK;AAAA,IAC7B;AAAA,EACF,SAAS,GAAP;AACA,UAAM,IAAI,MAAM,+BAA+B,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC,EAAE;AAAA,EAC5F;AACF;",
4
+ "sourcesContent": ["import { base64ToString, stringToBase64 } from './base64';\nimport { random } from './math';\nimport { randomChars } from './string';\n\n/** Secret. No description provided */\nexport async function advancedEncrypt(plainText: string, key: string) {\n const k1 = randomChars(36);\n let e = await encryptAES(plainText, k1);\n const b = stringToBase64(k1);\n const l = b.length;\n const s = random(0, e.length);\n e = e.substring(0, s) + b + e.substring(s);\n const r = stringToBase64(`${s}-${l}`);\n const t = `${e}.${r}`;\n return encryptAES(t, key);\n}\n\n/** Secret. No description provided */\nexport async function advancedDecrypt(encryptedText: string, key: string) {\n const decrypted = await decryptAES(encryptedText, key);\n const [e, r] = decrypted.split('.');\n const [s, l] = base64ToString(r).split('-').map(Number);\n const k1 = base64ToString(e.substring(s, s + l));\n return decryptAES(e.substring(0, s) + e.substring(s + l), k1);\n}\n\n/**\n * **EN**: General AES encryption function - supports both Node.js and browser environments\n *\n * **CN**: 通用 AES 加密函数 - 同时支持 Node.js 和浏览器环境\n *\n * @param {string} text The text to be encrypted | 要加密的文本\n * @param {string} key The encryption key | 加密密钥\n *\n * @returns {Promise<string>} The encrypted text | 加密后的文本\n */\nexport async function encryptAES(text: string, key: string): Promise<string> {\n const isNode = typeof process !== 'undefined' && process.versions != null && process.versions.node != null;\n\n if (isNode) {\n // Node.js\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const crypto = require('crypto');\n const derivedKey = crypto.createHash('sha256').update(key).digest();\n const iv = crypto.randomBytes(16);\n const cipher = crypto.createCipheriv('aes-256-cbc', derivedKey, iv);\n let encrypted = cipher.update(text, 'utf8', 'base64');\n encrypted += cipher.final('base64');\n return `${iv.toString('base64')}:${encrypted}`;\n } else {\n // Browsers\n try {\n const iv = crypto.getRandomValues(new Uint8Array(16));\n const encoder = new TextEncoder();\n const keyData = encoder.encode(key);\n const hashBuffer = await crypto.subtle.digest('SHA-256', keyData);\n const cryptoKey = await crypto.subtle.importKey('raw', hashBuffer, { name: 'AES-CBC' }, false, ['encrypt']);\n const textBytes = encoder.encode(text);\n const encryptedBuffer = await crypto.subtle.encrypt({ name: 'AES-CBC', iv }, cryptoKey, textBytes);\n const ivBase64 = btoa(String.fromCharCode(...iv));\n const encryptedBase64 = btoa(String.fromCharCode(...new Uint8Array(encryptedBuffer)));\n return `${ivBase64}:${encryptedBase64}`;\n } catch (error) {\n console.error('Encryption error:', error);\n throw error;\n }\n }\n}\n\n/**\n * **EN**: General AES decryption function - supports both Node.js and browser environments\n *\n * **CN**: 通用 AES 解密函数 - 同时支持 Node.js 和浏览器环境\n *\n * @param encryptedText The encrypted text (format: iv:encryptedContent, base64 encoded)\n * @param key The decryption key\n *\n * @returns The decrypted text\n */\nexport async function decryptAES(encryptedText: string, key: string): Promise<string> {\n const isNode = typeof process !== 'undefined' && process.versions != null && process.versions.node != null;\n try {\n const [ivBase64, encryptedBase64] = encryptedText.split(':');\n if (!ivBase64 || !encryptedBase64) {\n throw new Error('Invalid encrypted format');\n }\n if (isNode) {\n // Node.js\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const crypto = require('crypto');\n const iv = Buffer.from(ivBase64, 'base64');\n const encryptedBuffer = Buffer.from(encryptedBase64, 'base64');\n const derivedKey = crypto.createHash('sha256').update(key).digest();\n const decipher = crypto.createDecipheriv('aes-256-cbc', derivedKey, iv);\n let decrypted = decipher.update(encryptedBuffer);\n decrypted = Buffer.concat([decrypted, decipher.final()]);\n return decrypted.toString('utf8');\n } else {\n // Browsers\n const iv = Uint8Array.from(atob(ivBase64), (c) => c.charCodeAt(0));\n const encryptedData = Uint8Array.from(atob(encryptedBase64), (c) => c.charCodeAt(0));\n const encoder = new TextEncoder();\n const keyData = encoder.encode(key);\n const hashBuffer = await crypto.subtle.digest('SHA-256', keyData);\n const cryptoKey = await crypto.subtle.importKey('raw', hashBuffer, { name: 'AES-CBC' }, false, ['decrypt']);\n const decryptedBuffer = await crypto.subtle.decrypt({ name: 'AES-CBC', iv }, cryptoKey, encryptedData);\n const decoder = new TextDecoder();\n return decoder.decode(decryptedBuffer);\n }\n } catch (error) {\n console.error('Decryption error:', error);\n return '';\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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AE;AACtE,UAAI,YAAY,SAAS,OAAO,eAAe;AAC/C,kBAAY,OAAO,OAAO,CAAC,WAAW,SAAS,MAAM,CAAC,CAAC;AACvD,aAAO,UAAU,SAAS,MAAM;AAAA,IAClC,OAAO;AAEL,YAAM,KAAK,WAAW,KAAK,KAAK,QAAQ,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AACjE,YAAM,gBAAgB,WAAW,KAAK,KAAK,eAAe,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AACnF,YAAM,UAAU,IAAI,YAAY;AAChC,YAAM,UAAU,QAAQ,OAAO,GAAG;AAClC,YAAM,aAAa,MAAM,OAAO,OAAO,OAAO,WAAW,OAAO;AAChE,YAAM,YAAY,MAAM,OAAO,OAAO,UAAU,OAAO,YAAY,EAAE,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC;AAC1G,YAAM,kBAAkB,MAAM,OAAO,OAAO,QAAQ,EAAE,MAAM,WAAW,GAAG,GAAG,WAAW,aAAa;AACrG,YAAM,UAAU,IAAI,YAAY;AAChC,aAAO,QAAQ,OAAO,eAAe;AAAA,IACvC;AAAA,EACF,SAAS,OAAP;AACA,YAAQ,MAAM,qBAAqB,KAAK;AACxC,WAAO;AAAA,EACT;AACF;",
6
6
  "names": ["crypto"]
7
7
  }
@@ -1,4 +1,8 @@
1
+ export * from './AudioPlayer';
2
+ export { default as AudioPlayer } from './AudioPlayer';
3
+ export * from './base64';
1
4
  export * from './color';
5
+ export * from './crypto';
2
6
  export * from './math';
7
+ export * from './stream';
3
8
  export * from './string';
4
- export * from './crypto';
@@ -1,7 +1,13 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
4
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
5
11
  var __copyProps = (to, from, except, desc) => {
6
12
  if (from && typeof from === "object" || typeof from === "function") {
7
13
  for (let key of __getOwnPropNames(from))
@@ -11,20 +17,39 @@ var __copyProps = (to, from, except, desc) => {
11
17
  return to;
12
18
  };
13
19
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
14
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
29
 
16
30
  // src/utils/index.ts
17
31
  var utils_exports = {};
32
+ __export(utils_exports, {
33
+ AudioPlayer: () => import_AudioPlayer.default
34
+ });
18
35
  module.exports = __toCommonJS(utils_exports);
36
+ __reExport(utils_exports, require("./AudioPlayer"), module.exports);
37
+ var import_AudioPlayer = __toESM(require("./AudioPlayer"));
38
+ __reExport(utils_exports, require("./base64"), module.exports);
19
39
  __reExport(utils_exports, require("./color"), module.exports);
40
+ __reExport(utils_exports, require("./crypto"), module.exports);
20
41
  __reExport(utils_exports, require("./math"), module.exports);
42
+ __reExport(utils_exports, require("./stream"), module.exports);
21
43
  __reExport(utils_exports, require("./string"), module.exports);
22
- __reExport(utils_exports, require("./crypto"), module.exports);
23
44
  // Annotate the CommonJS export names for ESM import in node:
24
45
  0 && (module.exports = {
46
+ AudioPlayer,
47
+ ...require("./AudioPlayer"),
48
+ ...require("./base64"),
25
49
  ...require("./color"),
50
+ ...require("./crypto"),
26
51
  ...require("./math"),
27
- ...require("./string"),
28
- ...require("./crypto")
52
+ ...require("./stream"),
53
+ ...require("./string")
29
54
  });
30
55
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/index.ts"],
4
- "sourcesContent": ["export * from './color';\nexport * from './math';\nexport * from './string';\nexport * from './crypto';\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc,oBAAd;AACA,0BAAc,mBADd;AAEA,0BAAc,qBAFd;AAGA,0BAAc,qBAHd;",
4
+ "sourcesContent": ["export * from './AudioPlayer';\nexport { default as AudioPlayer } from './AudioPlayer';\nexport * from './base64';\nexport * from './color';\nexport * from './crypto';\nexport * from './math';\nexport * from './stream';\nexport * from './string';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAc,0BAAd;AACA,yBAAuC;AACvC,0BAAc,qBAFd;AAGA,0BAAc,oBAHd;AAIA,0BAAc,qBAJd;AAKA,0BAAc,mBALd;AAMA,0BAAc,qBANd;AAOA,0BAAc,qBAPd;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiny-codes/react-easy",
3
- "version": "1.4.7",
3
+ "version": "1.4.9",
4
4
  "description": "Simplify React and AntDesign development with practical components and hooks",
5
5
  "keywords": [
6
6
  "react",
@@ -31,15 +31,20 @@
31
31
  "README.zh-CN.md"
32
32
  ],
33
33
  "scripts": {
34
- "build": "father build",
34
+ "build": "run-s build-core correct-sourcemap",
35
+ "build-core": "father build",
36
+ "correct-sourcemap": "tsx scripts/correct-sourcemap.ts",
35
37
  "prepare": "husky",
36
38
  "prepublishOnly": "npm run build"
37
39
  },
38
40
  "dependencies": {
39
41
  "@lexical/react": "^0.33.1",
42
+ "@microsoft/fetch-event-source": "^2.0.1",
43
+ "@stomp/stompjs": "^7.1.1",
40
44
  "i18next": "^24.2.3",
41
45
  "lexical": "^0.33.1",
42
- "react-contexify": "^6.0.0"
46
+ "react-contexify": "^6.0.0",
47
+ "sockjs-client": "^1.6.1"
43
48
  },
44
49
  "devDependencies": {
45
50
  "@tiny-codes/code-style-all-in-one": "^1.1.5",
@@ -49,6 +54,7 @@
49
54
  "@types/react": "^19.0.12",
50
55
  "@types/react-dom": "^19.0.4",
51
56
  "@types/react-is": "^19.0.0",
57
+ "@types/sockjs-client": "^1.5.4",
52
58
  "antd": "^5.24.5",
53
59
  "father": "^4.5.2",
54
60
  "jest": "^29.7.0",
@@ -57,6 +63,7 @@
57
63
  "react-dom": "^19.0.0",
58
64
  "react-is": "^19.0.0",
59
65
  "ts-jest": "^29.3.0",
66
+ "tsx": "^4.20.5",
60
67
  "typescript": "^5.8.2"
61
68
  },
62
69
  "peerDependencies": {