@tiny-codes/react-easy 1.4.19 → 1.4.21
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/CHANGELOG.md +19 -0
- package/es/components/Animation/Pulse/index.d.ts +52 -0
- package/es/components/Animation/Pulse/index.js +71 -0
- package/es/components/Animation/Pulse/index.js.map +1 -0
- package/es/components/Animation/Pulse/style/index.d.ts +3 -0
- package/es/components/Animation/Pulse/style/index.js +37 -0
- package/es/components/Animation/Pulse/style/index.js.map +1 -0
- package/es/components/ModalAction/index.d.ts +1 -1
- package/es/components/ModalAction/index.js.map +1 -1
- package/es/components/index.d.ts +2 -0
- package/es/components/index.js +1 -0
- package/es/components/index.js.map +1 -1
- package/es/hooks/index.d.ts +4 -0
- package/es/hooks/index.js +4 -0
- package/es/hooks/index.js.map +1 -1
- package/es/hooks/useMovable.d.ts +36 -0
- package/es/hooks/useMovable.js +146 -0
- package/es/hooks/useMovable.js.map +1 -0
- package/es/hooks/useProcessingText.d.ts +38 -0
- package/es/hooks/useProcessingText.js +57 -0
- package/es/hooks/useProcessingText.js.map +1 -0
- package/es/utils/base64.d.ts +7 -1
- package/es/utils/base64.js +30 -9
- package/es/utils/base64.js.map +1 -1
- package/lib/components/Animation/Pulse/index.d.ts +52 -0
- package/lib/components/Animation/Pulse/index.js +88 -0
- package/lib/components/Animation/Pulse/index.js.map +7 -0
- package/lib/components/Animation/Pulse/style/index.d.ts +3 -0
- package/lib/components/Animation/Pulse/style/index.js +55 -0
- package/lib/components/Animation/Pulse/style/index.js.map +7 -0
- package/lib/components/ModalAction/index.d.ts +1 -1
- package/lib/components/ModalAction/index.js.map +1 -1
- package/lib/components/index.d.ts +2 -0
- package/lib/components/index.js +3 -0
- package/lib/components/index.js.map +2 -2
- package/lib/hooks/index.d.ts +4 -0
- package/lib/hooks/index.js +10 -0
- package/lib/hooks/index.js.map +2 -2
- package/lib/hooks/useMovable.d.ts +36 -0
- package/lib/hooks/useMovable.js +133 -0
- package/lib/hooks/useMovable.js.map +7 -0
- package/lib/hooks/useProcessingText.d.ts +38 -0
- package/lib/hooks/useProcessingText.js +51 -0
- package/lib/hooks/useProcessingText.js.map +7 -0
- package/lib/utils/base64.d.ts +7 -1
- package/lib/utils/base64.js +30 -10
- package/lib/utils/base64.js.map +2 -2
- package/package.json +2 -1
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/hooks/useProcessingText.ts
|
|
20
|
+
var useProcessingText_exports = {};
|
|
21
|
+
__export(useProcessingText_exports, {
|
|
22
|
+
default: () => useProcessingText_default
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(useProcessingText_exports);
|
|
25
|
+
var import_react = require("react");
|
|
26
|
+
function useProcessingText(props) {
|
|
27
|
+
const { enabled = true, prefixText = "", dotText = ".", interval = 300, maxDots = 3 } = props || {};
|
|
28
|
+
const [dots, setDots] = (0, import_react.useState)(0);
|
|
29
|
+
const timerRef = (0, import_react.useRef)(0);
|
|
30
|
+
(0, import_react.useEffect)(() => {
|
|
31
|
+
if (enabled) {
|
|
32
|
+
timerRef.current = window.setInterval(() => {
|
|
33
|
+
setDots((prev) => (prev + 1) % (maxDots + 1));
|
|
34
|
+
}, interval);
|
|
35
|
+
} else {
|
|
36
|
+
setDots(0);
|
|
37
|
+
if (timerRef.current) {
|
|
38
|
+
clearInterval(timerRef.current);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return () => {
|
|
42
|
+
if (timerRef.current) {
|
|
43
|
+
clearInterval(timerRef.current);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}, [enabled, interval, maxDots]);
|
|
47
|
+
const text = prefixText + dotText.repeat(dots);
|
|
48
|
+
return text;
|
|
49
|
+
}
|
|
50
|
+
var useProcessingText_default = useProcessingText;
|
|
51
|
+
//# sourceMappingURL=useProcessingText.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/hooks/useProcessingText.ts"],
|
|
4
|
+
"sourcesContent": ["import { useEffect, useRef, useState } from 'react';\n\nexport interface UseProcessingTextProps {\n /**\n * - **EN:** Whether the animation is enabled, default is `true`\n * - **CN:** 是否启用,默认`true`\n */\n enabled?: boolean;\n /**\n * - **EN:** Prefix text (e.g., \"Processing\"), default is `\"\"`\n * - **CN:** 前缀文本(例如 \"处理中\"),默认`\"\"`\n */\n prefixText?: string;\n /**\n * - **EN:** Dot text (e.g., \".\"), default is `\".\"`\n * - **CN:** 点文本(例如 \".\"),默认`\".\"`\n */\n dotText?: string;\n /**\n * - **EN:** Animation interval (milliseconds), default is `300`\n * - **CN:** 动画间隔(毫秒),默认`300`\n */\n interval?: number;\n /**\n * - **EN:** Maximum number of dots, default is `3`\n * - **CN:** 最大点数,默认`3`\n */\n maxDots?: number;\n}\n/**\n * - **EN:** Hook to create a processing text animation (e.g., \"Processing.\", \"Processing..\",\n * \"Processing...\")\n * - **CN:** 创建处理文本动画的钩子(例如 \"处理中.\"、\"处理中..\"、\"处理中...\")\n *\n * @param props Configuration options\n *\n * @returns Animated processing text\n */\nfunction useProcessingText(props?: UseProcessingTextProps) {\n const { enabled = true, prefixText = '', dotText = '.', interval = 300, maxDots = 3 } = props || {};\n const [dots, setDots] = useState(0);\n const timerRef = useRef(0);\n\n useEffect(() => {\n if (enabled) {\n timerRef.current = window.setInterval(() => {\n setDots((prev) => (prev + 1) % (maxDots + 1));\n }, interval);\n } else {\n setDots(0);\n if (timerRef.current) {\n clearInterval(timerRef.current);\n }\n }\n return () => {\n if (timerRef.current) {\n clearInterval(timerRef.current);\n }\n };\n }, [enabled, interval, maxDots]);\n\n const text = prefixText + dotText.repeat(dots);\n return text;\n}\n\nexport default useProcessingText;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA4C;AAsC5C,SAAS,kBAAkB,OAAgC;AACzD,QAAM,EAAE,UAAU,MAAM,aAAa,IAAI,UAAU,KAAK,WAAW,KAAK,UAAU,EAAE,IAAI,SAAS,CAAC;AAClG,QAAM,CAAC,MAAM,OAAO,QAAI,uBAAS,CAAC;AAClC,QAAM,eAAW,qBAAO,CAAC;AAEzB,8BAAU,MAAM;AACd,QAAI,SAAS;AACX,eAAS,UAAU,OAAO,YAAY,MAAM;AAC1C,gBAAQ,CAAC,UAAU,OAAO,MAAM,UAAU,EAAE;AAAA,MAC9C,GAAG,QAAQ;AAAA,IACb,OAAO;AACL,cAAQ,CAAC;AACT,UAAI,SAAS,SAAS;AACpB,sBAAc,SAAS,OAAO;AAAA,MAChC;AAAA,IACF;AACA,WAAO,MAAM;AACX,UAAI,SAAS,SAAS;AACpB,sBAAc,SAAS,OAAO;AAAA,MAChC;AAAA,IACF;AAAA,EACF,GAAG,CAAC,SAAS,UAAU,OAAO,CAAC;AAE/B,QAAM,OAAO,aAAa,QAAQ,OAAO,IAAI;AAC7C,SAAO;AACT;AAEA,IAAO,4BAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/lib/utils/base64.d.ts
CHANGED
|
@@ -45,4 +45,10 @@ export declare function arrayBufferToBase64(buf: ArrayBuffer): string;
|
|
|
45
45
|
*
|
|
46
46
|
* @returns The decoded ArrayBuffer | 解码后的 ArrayBuffer
|
|
47
47
|
*/
|
|
48
|
-
export declare function base64ToArrayBuffer(base64: string
|
|
48
|
+
export declare function base64ToArrayBuffer(base64: string, opts?: {
|
|
49
|
+
/**
|
|
50
|
+
* - EN: Use URL-safe Base64 if true (replace -_ back to +/ and restore padding)
|
|
51
|
+
* - CN: 为 true 时按 URL 安全 Base64 进行规范化(将 -_ 还原为 +/ 并补齐 =)
|
|
52
|
+
*/
|
|
53
|
+
urlSafe?: boolean;
|
|
54
|
+
}): ArrayBuffer;
|
package/lib/utils/base64.js
CHANGED
|
@@ -97,18 +97,38 @@ function arrayBufferToBase64(buf) {
|
|
|
97
97
|
base64 += "=".repeat(padding);
|
|
98
98
|
return base64;
|
|
99
99
|
}
|
|
100
|
-
function base64ToArrayBuffer(base64) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return
|
|
100
|
+
function base64ToArrayBuffer(base64, opts = {}) {
|
|
101
|
+
const { urlSafe = false } = opts;
|
|
102
|
+
if (base64 == null || base64 === "")
|
|
103
|
+
return new ArrayBuffer(0);
|
|
104
|
+
let normalized = base64;
|
|
105
|
+
if (urlSafe) {
|
|
106
|
+
normalized = normalized.replace(/-/g, "+").replace(/_/g, "/");
|
|
107
|
+
}
|
|
108
|
+
const padNeeded = normalized.length % 4;
|
|
109
|
+
if (padNeeded === 2)
|
|
110
|
+
normalized += "==";
|
|
111
|
+
else if (padNeeded === 3)
|
|
112
|
+
normalized += "=";
|
|
113
|
+
else if (padNeeded === 1) {
|
|
114
|
+
throw new Error("Invalid Base64 string length");
|
|
104
115
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
116
|
+
try {
|
|
117
|
+
if (typeof Buffer !== "undefined" && typeof Buffer.from === "function") {
|
|
118
|
+
const buf = Buffer.from(normalized, "base64");
|
|
119
|
+
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
|
|
120
|
+
} else {
|
|
121
|
+
const binary = atob(normalized);
|
|
122
|
+
const len = binary.length;
|
|
123
|
+
const bytes = new Uint8Array(len);
|
|
124
|
+
for (let i = 0; i < len; i++) {
|
|
125
|
+
bytes[i] = binary.charCodeAt(i);
|
|
126
|
+
}
|
|
127
|
+
return bytes.buffer;
|
|
128
|
+
}
|
|
129
|
+
} catch (e) {
|
|
130
|
+
throw new Error("Failed to decode Base64: " + (e instanceof Error ? e.message : String(e)));
|
|
110
131
|
}
|
|
111
|
-
return bytes.buffer;
|
|
112
132
|
}
|
|
113
133
|
// Annotate the CommonJS export names for ESM import in node:
|
|
114
134
|
0 && (module.exports = {
|
package/lib/utils/base64.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/base64.ts"],
|
|
4
|
-
"sourcesContent": ["/**\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 stringToBase64(\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 base64ToString(\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\n/**\n * - **EN:** Convert an ArrayBuffer to a Base64 encoded string.\n * - **CN:** 将 ArrayBuffer 转换为 Base64 编码的字符串。\n *\n * @param buf The ArrayBuffer to convert | 要转换的 ArrayBuffer\n *\n * @returns The Base64 encoded string | Base64 编码的字符串\n */\nexport function arrayBufferToBase64(buf: ArrayBuffer): string {\n if (typeof Buffer !== 'undefined') {\n return Buffer.from(buf).toString('base64');\n }\n const bytes = new Uint8Array(buf);\n const chunk = 0x8000;\n let binary = '';\n for (let i = 0; i < bytes.length; i += chunk) {\n binary += String.fromCharCode(...bytes.subarray(i, i + chunk));\n }\n let base64 = btoa(binary);\n // Add padding for Base64\n const padding = (4 - (base64.length % 4)) % 4;\n if (padding) base64 += '='.repeat(padding);\n return base64;\n}\n\n/**\n * - **EN:** Decode a Base64 (standard or URL-safe) string into an ArrayBuffer.\n * - **CN:** 将(标准或 URL 安全)Base64 字符串解码为 ArrayBuffer。\n *\n * @param base64 The Base64 encoded string | Base64 编码的字符串\n *\n * @returns The decoded ArrayBuffer | 解码后的 ArrayBuffer\n */\nexport function base64ToArrayBuffer(base64: string): ArrayBuffer {\n if (typeof Buffer !== 'undefined') {\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQO,SAAS,eACd,SACA,OAMI,CAAC,GACG;AACR,QAAM,EAAE,UAAU,MAAM,IAAI;AAC5B,MAAI,WAAW,QAAQ,YAAY;AAAI,WAAO;AAE9C,MAAI;AACJ,QAAM,YAAY,OAAO,WAAW,eAAe,OAAO,OAAO,SAAS;AAC1E,MAAI,WAAW;AAEb,aAAS,OAAO,KAAK,SAAS,MAAM,EAAE,SAAS,QAAQ;AAAA,EACzD,OAAO;AAEL,UAAM,UAAU,IAAI,YAAY;AAChC,UAAM,QAAQ,QAAQ,OAAO,OAAO;AACpC,QAAI,SAAS;AACb,eAAW,KAAK,OAAO;AACrB,gBAAU,OAAO,aAAa,CAAC;AAAA,IACjC;AACA,aAAS,KAAK,MAAM;AAAA,EACtB;AAEA,MAAI,SAAS;AAEX,aAAS,OAAO,QAAQ,OAAO,GAAG,EAAE,QAAQ,OAAO,GAAG,EAAE,QAAQ,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,OAAO,aAAa,GAAG,MAAM,SAAS,GAAG,IAAI,KAAK,CAAC;AAAA,EAC/D;AACA,MAAI,SAAS,KAAK,MAAM;AAExB,QAAM,WAAW,IAAK,OAAO,SAAS,KAAM;AAC5C,MAAI;AAAS,cAAU,IAAI,OAAO,OAAO;AACzC,SAAO;AACT;AAUO,SAAS,
|
|
4
|
+
"sourcesContent": ["/**\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 stringToBase64(\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 base64ToString(\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\n/**\n * - **EN:** Convert an ArrayBuffer to a Base64 encoded string.\n * - **CN:** 将 ArrayBuffer 转换为 Base64 编码的字符串。\n *\n * @param buf The ArrayBuffer to convert | 要转换的 ArrayBuffer\n *\n * @returns The Base64 encoded string | Base64 编码的字符串\n */\nexport function arrayBufferToBase64(buf: ArrayBuffer): string {\n if (typeof Buffer !== 'undefined') {\n return Buffer.from(buf).toString('base64');\n }\n const bytes = new Uint8Array(buf);\n const chunk = 0x8000;\n let binary = '';\n for (let i = 0; i < bytes.length; i += chunk) {\n binary += String.fromCharCode(...bytes.subarray(i, i + chunk));\n }\n let base64 = btoa(binary);\n // Add padding for Base64\n const padding = (4 - (base64.length % 4)) % 4;\n if (padding) base64 += '='.repeat(padding);\n return base64;\n}\n\n/**\n * - **EN:** Decode a Base64 (standard or URL-safe) string into an ArrayBuffer.\n * - **CN:** 将(标准或 URL 安全)Base64 字符串解码为 ArrayBuffer。\n *\n * @param base64 The Base64 encoded string | Base64 编码的字符串\n *\n * @returns The decoded ArrayBuffer | 解码后的 ArrayBuffer\n */\nexport function base64ToArrayBuffer(\n base64: string,\n opts: {\n /**\n * - EN: Use URL-safe Base64 if true (replace -_ back to +/ and restore padding)\n * - CN: 为 true 时按 URL 安全 Base64 进行规范化(将 -_ 还原为 +/ 并补齐 =)\n */\n urlSafe?: boolean;\n } = {}\n): ArrayBuffer {\n const { urlSafe = false } = opts;\n if (base64 == null || base64 === '') return new ArrayBuffer(0);\n\n // Normalize to standard Base64 (align with base64ToString)\n let normalized = base64;\n if (urlSafe) {\n normalized = normalized.replace(/-/g, '+').replace(/_/g, '/');\n }\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 try {\n if (typeof Buffer !== 'undefined' && typeof Buffer.from === 'function') {\n // Node.js / environments with Buffer\n const buf = Buffer.from(normalized, 'base64');\n return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);\n } else {\n // Browser\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 return bytes.buffer;\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;AAAA;AAAA;AAAA;AAAA;AAAA;AAQO,SAAS,eACd,SACA,OAMI,CAAC,GACG;AACR,QAAM,EAAE,UAAU,MAAM,IAAI;AAC5B,MAAI,WAAW,QAAQ,YAAY;AAAI,WAAO;AAE9C,MAAI;AACJ,QAAM,YAAY,OAAO,WAAW,eAAe,OAAO,OAAO,SAAS;AAC1E,MAAI,WAAW;AAEb,aAAS,OAAO,KAAK,SAAS,MAAM,EAAE,SAAS,QAAQ;AAAA,EACzD,OAAO;AAEL,UAAM,UAAU,IAAI,YAA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W,CAAC;AAAA,MAChC;AACA,aAAO,MAAM;AAAA,IACf;AAAA,EACF,SAAS,GAAP;AACA,UAAM,IAAI,MAAM,+BAA+B,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC,EAAE;AAAA,EAC5F;AACF;",
|
|
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.
|
|
3
|
+
"version": "1.4.21",
|
|
4
4
|
"description": "Simplify React and AntDesign development with practical components and hooks",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"crypto-js": "^4.2.0",
|
|
45
45
|
"lexical": "^0.33.1",
|
|
46
46
|
"react-contexify": "^6.0.0",
|
|
47
|
+
"react-use": "^17.6.0",
|
|
47
48
|
"sockjs-client": "^1.6.1"
|
|
48
49
|
},
|
|
49
50
|
"devDependencies": {
|