dozy 1.0.78 → 1.0.80

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/dist/index.d.ts CHANGED
@@ -552,17 +552,35 @@ declare function isNowAroundUtcHour(targetHour: number): boolean;
552
552
  */
553
553
  declare function $purifyBase64(input: string | Null): string | null;
554
554
  /**
555
- * 基于“纯 base64”推断图片 mime 类型。
555
+ * 基于“纯 base64”推断文件 mime 类型。
556
556
  *
557
557
  * 说明:
558
- * - 自动支持:jpeg/png/gif/webp/bmp/tiff/avif/heic/x-icon。
558
+ * - 图片:jpeg/png/gif/webp/bmp/tiff/avif/heic/x-icon/svg+xml
559
+ * - 音频:mpeg(mp3)/wav/ogg/flac/aac/m4a。
560
+ * - 视频:mp4/webm/quicktime(mov)/x-msvideo(avi)/x-matroska(mkv)。
561
+ * - 文档:pdf/msword(doc)/vnd.ms-excel(xls)/vnd.ms-powerpoint(ppt)/
562
+ * vnd.openxmlformats-officedocument.*(docx/xlsx/pptx)。
563
+ * - 压缩包:zip/x-rar-compressed/x-7z-compressed/gzip/x-tar。
564
+ * - 其它:xml。
559
565
  * - 输入可为纯 base64 或 data URL,内部会先清洗。
560
- * - 无法识别时回退为 `image/png`。
566
+ * - 无法识别时回退为 `application/octet-stream`。
561
567
  *
562
568
  * 返回值约定:
563
569
  * - 一定返回非空 mime 字符串(不会返回 null/undefined/空串)。
564
570
  */
565
- declare function $inferMimeTypeFormPureBase64(pureBase64: string | Null): "image/png" | "image/jpeg" | "image/gif" | "image/webp" | "image/bmp" | "image/tiff" | "image/avif" | "image/heic" | "image/x-icon";
571
+ declare function $inferMimeTypeFormPureBase64(pureBase64: string | Null): "application/xml" | "image/svg+xml" | "application/octet-stream" | "image/jpeg" | "image/png" | "image/gif" | "image/bmp" | "image/tiff" | "image/x-icon" | "image/webp" | "audio/wav" | "video/x-msvideo" | "image/avif" | "image/heic" | "video/quicktime" | "audio/mp4" | "video/mp4" | "video/webm" | "video/x-matroska" | "audio/ogg" | "audio/flac" | "audio/mpeg" | "audio/aac" | "application/pdf" | "application/x-cfb" | "application/vnd.openxmlformats-officedocument.wordprocessingml.document" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" | "application/vnd.openxmlformats-officedocument.presentationml.presentation" | "application/zip" | "application/x-rar-compressed" | "application/x-7z-compressed" | "application/gzip" | "application/x-tar";
572
+ /**
573
+ * 基于“纯 base64”推断文件后缀。
574
+ *
575
+ * 说明:
576
+ * - 覆盖 `$inferMimeTypeFormPureBase64` 支持的全部类型。
577
+ * - 输入可为纯 base64 或 data URL,内部会先清洗。
578
+ * - 无法识别时回退为 `bin`。
579
+ *
580
+ * 返回值约定:
581
+ * - 一定返回非空后缀字符串(不含点号,不会返回 null/undefined/空串)。
582
+ */
583
+ declare function $inferExtensionFormPureBase64(pureBase64: string | Null): "xml" | "jpg" | "png" | "gif" | "bmp" | "svg" | "webp" | "mp3" | "wav" | "ogg" | "aac" | "flac" | "m4a" | "mp4" | "webm" | "mov" | "avi" | "mkv" | "avif" | "heic" | "tiff" | "ico" | "pdf" | "doc" | "docx" | "xlsx" | "pptx" | "zip" | "rar" | "7z" | "gz" | "tar" | "bin";
566
584
  /**
567
585
  * 将“纯 base64 或 data URL”统一转成标准 data URL。
568
586
  *
@@ -896,7 +914,7 @@ declare class StringObfuscator {
896
914
  * - 支持自动处理 Base64 编码/解码(GitHub API 要求文件内容使用 Base64 编码)
897
915
  * - 内置冲突重试机制(HTTP 409 冲突时自动重试)
898
916
  * - 提供原始模式和文本模式的切换(raw 参数)
899
- * - 可通过重写 `_prind` 和 `path` 方法实现自定义处理(如加密、路径映射等)
917
+ * - 可通过重写 `_process` 和 `path` 方法实现自定义处理(如加密、路径映射等)
900
918
  *
901
919
  * @example
902
920
  * ```typescript
@@ -952,13 +970,13 @@ declare class RepoStore {
952
970
  * @example
953
971
  * ```typescript
954
972
  * class EncryptedRepoStore extends RepoStore {
955
- * _prind(content: string, en: boolean) {
973
+ * _process(content: string, en: boolean) {
956
974
  * return en ? encrypt(content) : decrypt(content)
957
975
  * }
958
976
  * }
959
977
  * ```
960
978
  */
961
- _prind(content: string, en: boolean): string;
979
+ _process(content: string, en: boolean): string;
962
980
  /**
963
981
  * 路径处理方法(可重写)
964
982
  *
@@ -1014,7 +1032,7 @@ declare class RepoStore {
1014
1032
  * - `true`:返回 GitHub API 响应的原始 Base64 编码内容
1015
1033
  * @returns
1016
1034
  * - 当 `raw=true`:返回 Base64 编码的字符串
1017
- * - 当 `raw=false` 且内容是文本:返回解码后的 Unicode 字符串(会经过 `_prind` 处理)
1035
+ * - 当 `raw=false` 且内容是文本:返回解码后的 Unicode 字符串(会经过 `_process` 处理)
1018
1036
  * - 当 `raw=false` 且内容是二进制:返回 `ArrayBuffer`
1019
1037
  * - 当 `data.content` 为空时:返回完整的 API 响应数据(可能是目录列表或文件元数据)
1020
1038
  *
@@ -1024,7 +1042,7 @@ declare class RepoStore {
1024
1042
  * - 文本内容会尝试使用 `$decodeBase64ToUnicode` 解码,失败则使用 `$decodeBase64ToBinary` 解码
1025
1043
  * - 返回目录列表时,`data.content` 为空,此时返回原始响应数据
1026
1044
  * - 会自动应用 `path()` 方法处理路径
1027
- * - 解码后的文本会经过 `_prind(content, false)` 处理
1045
+ * - 解码后的文本会经过 `_process(content, false)` 处理
1028
1046
  *
1029
1047
  * @see https://docs.github.com/en/rest/repos/contents
1030
1048
  *
@@ -1069,7 +1087,7 @@ declare class RepoStore {
1069
1087
  * @param path - 文件路径(相对于仓库根目录)
1070
1088
  * @param content - 要存储的内容(字符串)
1071
1089
  * @param raw - 原始模式标志
1072
- * - `false`(默认):将内容视为文本,经过 `_prind` 处理后 Base64 编码再存储
1090
+ * - `false`(默认):将内容视为文本,经过 `_process` 处理后 Base64 编码再存储
1073
1091
  * - `true`:假定 content 已经是 Base64 编码,直接存储(跳过编码步骤)
1074
1092
  * @returns 无返回值
1075
1093
  *
@@ -1078,7 +1096,7 @@ declare class RepoStore {
1078
1096
  * @remarks
1079
1097
  * - **冲突处理**:当遇到 HTTP 409(冲突)错误时,会自动重试一次(递归调用自身)
1080
1098
  * - **SHA 处理**:如果文件已存在,会自动获取其 SHA 值用于 API 调用(GitHub API 要求提供 SHA 以更新文件)
1081
- * - **编码流程**:非 raw 模式下,内容会先经过 `_prind(content, true)` 处理,然后 Base64 编码
1099
+ * - **编码流程**:非 raw 模式下,内容会先经过 `_process(content, true)` 处理,然后 Base64 编码
1082
1100
  * - **空文件检测**:使用 `det()` 方法检查文件是否存在,不存在时 sha 为 undefined(创建新文件)
1083
1101
  * - 会自动应用 `path()` 方法处理路径
1084
1102
  *
@@ -1140,7 +1158,7 @@ declare class RepoStore {
1140
1158
  *
1141
1159
  * @remarks
1142
1160
  * - 仅在 HTTP 状态码为 404 时静默失败,其他错误会正常抛出
1143
- * - 内部调用 `getJson` 方法,因此会经过 Base64 解码和 `_prind` 处理
1161
+ * - 内部调用 `getJson` 方法,因此会经过 Base64 解码和 `_process` 处理
1144
1162
  *
1145
1163
  * @example
1146
1164
  * ```typescript
@@ -1165,7 +1183,7 @@ declare class RepoStore {
1165
1183
  * @throws {Error} 当文件不存在、读取失败或 JSON 解析失败时抛出异常
1166
1184
  *
1167
1185
  * @remarks
1168
- * - 内部调用 `get()` 方法获取内容,因此会经过 Base64 解码和 `_prind` 处理
1186
+ * - 内部调用 `get()` 方法获取内容,因此会经过 Base64 解码和 `_process` 处理
1169
1187
  * - 使用 `$jsonParse` 进行解析(可能包含自定义的 JSON 解析逻辑,如日期恢复等)
1170
1188
  * - 如果文件内容不是有效的 JSON,会抛出异常
1171
1189
  *
@@ -1285,7 +1303,7 @@ declare class RepoStore {
1285
1303
  constructor(x0: string, user: string, repo: string);
1286
1304
  }
1287
1305
 
1288
- declare function $escapeHTML(str: string): string;
1306
+ declare function $escapeHTML(str?: string): string;
1289
1307
  declare class RainbowGen {
1290
1308
  i: number;
1291
1309
  ten: number;
@@ -1377,6 +1395,6 @@ declare function toRgbString(input: string | Color | any): string | undefined;
1377
1395
  */
1378
1396
  declare function toHslString(input: string | Color | any): string | undefined;
1379
1397
 
1380
- declare const DOZY = "1.0.78";
1398
+ declare const DOZY = "1.0.80";
1381
1399
 
1382
- export { $Headers, $Request, $Response, $URL, $URLSearchParams, $arrayFrom, $arrayIsArray, $assign, $backgroundColor, $borderColor, $capitalize, $checkValidEmailWithUnicode, $clamp, $clearInterval, $clearTimeout, $clone, $compressImage, $compressImageBase64, $compressImageDefaultOptions, $copy, $crypto, $date, $decodeBase64ToBinary, $decodeBase64ToUnicode, $deepClone, $defineProperty, $document, $encodeUnicodeToBase64, $entries, $escapeHTML, $fallbackCopy, $fetch, $fileToBase64, $formatDate, $formatPoints, $formatPointsWithChange, $formatWithCommas, $freeze, $genSSF, $getFileType, $getHue, $getTimeString, $hasKey, $if, $inRange, $inRange2, $inferMimeTypeFormPureBase64, $is, $isObject, $isPlainClass, $isValidEmailWithUnicode, $isValidOrBriefURL, $jsonParse, $jsonStringify, $keys, $lastIndex, $lindex, $loadOpt, $location, $log, $lplus, $magic, $math, $now, $numberIsFinite, $numberIsNaN, $oc, $open, $parseParams, $promise, $pureText, $purifyBase64, $randomByte, $replaceHolesWithUndefined, $rmvSlash, $rsValue, $rsetValue, $rvalue, $s, $sc, $setInterval, $setRange, $setTimeout, $stringFromCharCode, $stringFromCodePoint, $stringToRange, $strings, $toDataUrlFromBase64, $validName, $values, $window, type Any, type Atoa, type Coord, type Coord3, DOZY, type DozyConfig, type DozyConfigItem, type FileType, Gens, type Hel, type IOpt, type Items, type Null, type Nullable, RainbowGen, RepoStore, type ScaleComputer, type ScaleIniter, StringObfuscator, type UNumber, __GensDirectives, _res, boxShadow, dozy, enableScaler, err403, errArg, errCode, errContent, errMsg, errNotLoggedIn, errToString, getBrightness, getColorMap, isNowAroundUtcHour, isNull, isValidColor, maybeString, registerCustomColor, s, shanghaiDateFormatter, smallChance, smartParse, smartString, standardIniter, textShadow, toHexString, toHslString, toRgbString, toRgbaArray, web$enableHttpsRedirect, web$enableProdProtector, web$encodeURI, web$pathStartData, web$redirectToDomain, web$setPathTarget, xtrim };
1400
+ export { $Headers, $Request, $Response, $URL, $URLSearchParams, $arrayFrom, $arrayIsArray, $assign, $backgroundColor, $borderColor, $capitalize, $checkValidEmailWithUnicode, $clamp, $clearInterval, $clearTimeout, $clone, $compressImage, $compressImageBase64, $compressImageDefaultOptions, $copy, $crypto, $date, $decodeBase64ToBinary, $decodeBase64ToUnicode, $deepClone, $defineProperty, $document, $encodeUnicodeToBase64, $entries, $escapeHTML, $fallbackCopy, $fetch, $fileToBase64, $formatDate, $formatPoints, $formatPointsWithChange, $formatWithCommas, $freeze, $genSSF, $getFileType, $getHue, $getTimeString, $hasKey, $if, $inRange, $inRange2, $inferExtensionFormPureBase64, $inferMimeTypeFormPureBase64, $is, $isObject, $isPlainClass, $isValidEmailWithUnicode, $isValidOrBriefURL, $jsonParse, $jsonStringify, $keys, $lastIndex, $lindex, $loadOpt, $location, $log, $lplus, $magic, $math, $now, $numberIsFinite, $numberIsNaN, $oc, $open, $parseParams, $promise, $pureText, $purifyBase64, $randomByte, $replaceHolesWithUndefined, $rmvSlash, $rsValue, $rsetValue, $rvalue, $s, $sc, $setInterval, $setRange, $setTimeout, $stringFromCharCode, $stringFromCodePoint, $stringToRange, $strings, $toDataUrlFromBase64, $validName, $values, $window, type Any, type Atoa, type Coord, type Coord3, DOZY, type DozyConfig, type DozyConfigItem, type FileType, Gens, type Hel, type IOpt, type Items, type Null, type Nullable, RainbowGen, RepoStore, type ScaleComputer, type ScaleIniter, StringObfuscator, type UNumber, __GensDirectives, _res, boxShadow, dozy, enableScaler, err403, errArg, errCode, errContent, errMsg, errNotLoggedIn, errToString, getBrightness, getColorMap, isNowAroundUtcHour, isNull, isValidColor, maybeString, registerCustomColor, s, shanghaiDateFormatter, smallChance, smartParse, smartString, standardIniter, textShadow, toHexString, toHslString, toRgbString, toRgbaArray, web$enableHttpsRedirect, web$enableProdProtector, web$encodeURI, web$pathStartData, web$redirectToDomain, web$setPathTarget, xtrim };