@zero-library/common 2.2.10 → 2.2.12
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.cjs.js +55 -19
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.mts +55 -10
- package/dist/index.d.ts +55 -10
- package/dist/index.esm.js +51 -20
- package/dist/index.esm.js.map +1 -1
- package/package.json +7 -1
package/dist/index.d.mts
CHANGED
|
@@ -950,9 +950,7 @@ declare const getWebSocketUrl: (path: string, customHost?: string) => string;
|
|
|
950
950
|
* )
|
|
951
951
|
* // => { x: 1, y: 3 }
|
|
952
952
|
*/
|
|
953
|
-
declare
|
|
954
|
-
[K in keyof U]: keyof T | ((source: T) => U[K]) | U[K];
|
|
955
|
-
}): U;
|
|
953
|
+
declare const transform: <T extends object, U extends object>(source: T, fieldMap: { [K in keyof U]: keyof T | ((source: T) => U[K]) | U[K]; }) => U;
|
|
956
954
|
/**
|
|
957
955
|
* 批量对象转换函数
|
|
958
956
|
* @param sources - 源对象数组
|
|
@@ -963,9 +961,7 @@ declare function transform<T extends object, U extends object>(source: T, fieldM
|
|
|
963
961
|
* transforms([{ a: 1 }], { x: 'a' })
|
|
964
962
|
* // => [{ x: 1 }]
|
|
965
963
|
*/
|
|
966
|
-
declare
|
|
967
|
-
[K in keyof U]: keyof T | ((source: T) => U[K]) | U[K];
|
|
968
|
-
}): U[];
|
|
964
|
+
declare const transforms: <T extends object, U extends object>(sources: T[], fieldMap: { [K in keyof U]: keyof T | ((source: T) => U[K]) | U[K]; }) => U[];
|
|
969
965
|
/**
|
|
970
966
|
* 将数字金额转换为中文大写金额
|
|
971
967
|
*
|
|
@@ -1122,14 +1118,14 @@ declare const executeScript: (script: string, params: {
|
|
|
1122
1118
|
* @returns 加密后的字符串
|
|
1123
1119
|
* @throws 当密钥为空或加密过程失败时抛出错误
|
|
1124
1120
|
*/
|
|
1125
|
-
declare
|
|
1121
|
+
declare const aesEncrypt: <T = any>(data: T, key: string) => string;
|
|
1126
1122
|
/**
|
|
1127
1123
|
* AES 解密
|
|
1128
1124
|
* @param data - 加密后的字符串
|
|
1129
1125
|
* @param key - 解密密钥
|
|
1130
1126
|
* @returns 解密后的数据,解密失败时返回null
|
|
1131
1127
|
*/
|
|
1132
|
-
declare
|
|
1128
|
+
declare const aesDecrypt: <T = any>(data: string, key: string) => T | null;
|
|
1133
1129
|
type SizeUnit = 'B' | 'KB' | 'MB' | 'GB' | 'TB' | 'PB';
|
|
1134
1130
|
interface FormatSizeOptions {
|
|
1135
1131
|
/** 起始单位,默认 KB */
|
|
@@ -1166,7 +1162,7 @@ interface FormatSizeOptions {
|
|
|
1166
1162
|
* @remarks
|
|
1167
1163
|
* - 支持从 B, KB, MB, GB, TB, PB 等单位开始转换
|
|
1168
1164
|
*/
|
|
1169
|
-
declare
|
|
1165
|
+
declare const formatSize: (value: number | string, options?: FormatSizeOptions) => number | string;
|
|
1170
1166
|
/**
|
|
1171
1167
|
* Markdown转纯文本
|
|
1172
1168
|
* @param markdown - 原始 Markdown 内容
|
|
@@ -1176,6 +1172,55 @@ declare function formatSize(value: number | string, options?: FormatSizeOptions)
|
|
|
1176
1172
|
* markdownToText('## 标题\n\n- 列表项1\n- 列表项2 <div>123</div>') // '标题 列表项1 列表项2 123'
|
|
1177
1173
|
*/
|
|
1178
1174
|
declare const markdownToText: (markdown: string) => string;
|
|
1175
|
+
interface FindTreeNodesOptions {
|
|
1176
|
+
/** 树的id字段名,默认 "id" */
|
|
1177
|
+
id?: string;
|
|
1178
|
+
/** 子节点字段名,默认 "children" */
|
|
1179
|
+
children?: string;
|
|
1180
|
+
}
|
|
1181
|
+
/**
|
|
1182
|
+
* 从树结构中查找指定id列表的节点,并以自定义结构返回
|
|
1183
|
+
* - 支持跳过某些id(通过formatFn返回null/undefined)
|
|
1184
|
+
* - 支持自定义字段名
|
|
1185
|
+
*
|
|
1186
|
+
* @template T - 树节点类型,必须是键值对对象
|
|
1187
|
+
* @template R - 返回节点类型,默认与T相同
|
|
1188
|
+
* @param tree - 树结构数组
|
|
1189
|
+
* @param ids - 要查找的节点ID列表
|
|
1190
|
+
* @param formatFn - 可选的节点格式化函数,用于自定义返回节点的结构
|
|
1191
|
+
* @param options - 配置选项
|
|
1192
|
+
* @param options.id - ID字段名,默认为 "id"
|
|
1193
|
+
* @param options.children - 子节点字段名,默认为 "children"
|
|
1194
|
+
* @returns 符合ID列表的节点数组,按formatFn格式化后返回
|
|
1195
|
+
*
|
|
1196
|
+
* @example
|
|
1197
|
+
* // 基本用法
|
|
1198
|
+
* const tree = [
|
|
1199
|
+
* { id: 1, name: 'Node 1', children: [{ id: 2, name: 'Node 1-1' }] },
|
|
1200
|
+
* { id: 3, name: 'Node 2', children: [] }
|
|
1201
|
+
* ]
|
|
1202
|
+
* const result = findTreeNodesByIds(tree, [1, 2])
|
|
1203
|
+
* // => [{ id: 1, name: 'Node 1' }, { id: 2, name: 'Node 1-1' }]
|
|
1204
|
+
*
|
|
1205
|
+
* @example
|
|
1206
|
+
* // 使用格式化函数
|
|
1207
|
+
* const result = findTreeNodesByIds(tree, [1], (node) => ({ label: node.name, value: node.id }))
|
|
1208
|
+
* // => [{ label: 'Node 1', value: 1 }]
|
|
1209
|
+
*
|
|
1210
|
+
* @example
|
|
1211
|
+
* // 自定义字段名
|
|
1212
|
+
* const treeWithCustomFields = [
|
|
1213
|
+
* { key: 'a', title: 'Node A', subItems: [{ key: 'b', title: 'Node B' }] }
|
|
1214
|
+
* ]
|
|
1215
|
+
* const result = findTreeNodesByIds(
|
|
1216
|
+
* treeWithCustomFields,
|
|
1217
|
+
* ['a'],
|
|
1218
|
+
* undefined,
|
|
1219
|
+
* { id: 'key', children: 'subItems' }
|
|
1220
|
+
* )
|
|
1221
|
+
* // => [{ key: 'a', title: 'Node A', subItems: undefined }]
|
|
1222
|
+
*/
|
|
1223
|
+
declare const findTreeNodesByIds: <T extends Record<string, any>, R = T>(tree: T[], ids?: T[keyof T][], formatFn?: (node: T) => R | null | undefined, options?: FindTreeNodesOptions) => R[];
|
|
1179
1224
|
|
|
1180
1225
|
type DateType = string | number | Date | dayjs.Dayjs | null;
|
|
1181
1226
|
/** 默认日期时间格式:年-月-日 时:分:秒 */
|
|
@@ -2268,4 +2313,4 @@ declare function createTokenManager({ key, storage }: TokenManagerProps): {
|
|
|
2268
2313
|
clear: () => void;
|
|
2269
2314
|
};
|
|
2270
2315
|
|
|
2271
|
-
export { _default$p as AudioPlayer, type AudioPlayerProps, BusinessCode, type CacheMessage, type ComponentMapType, DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT, DEFAULT_YEAR_MONTH_DAY_FORMAT, DEFAULT_YEAR_MONTH_FORMAT, _default$o as DocxPreview, type DocxPreviewProps, _default$n as FileIcon, type FileIconProps, _default$m as FilePreview, _default$l as FilePreviewDrawer, type FilePreviewDrawerProps, type FilePreviewProps, type FormatSizeOptions, HttpStatus, _default$h as Iframe, type IframeProps, _default$g as LazyComponent, type LazyComponentProps, _default$f as MarkdownEditor, type MarkdownEditorProps, _default$k as MarkdownPreview, type MarkdownPreviewProps, MultiEmailValidator, _default$j as PdfPreview, type PdfPreviewProps, PhoneOrMobileValidator, RegBankCardNo, RegDetailAddress, RegEmail, RegFixedTelePhone, RegIdentityCardNo, RegMobile, RegNumNo, RegPassword, RegSmsCode, RegTaxNo, RegTelePhone, type RenderControl, _default$e as RenderMarkdown, type RenderMarkdownProps, _default$d as RenderWrapper, type RenderWrapperProps, type RequestConfig, type SecureManagerProps, type SetIntervalType, type SizeUnit, _default$b as SpeechButton, type SpeechPermission, type SpeechProps, ThanNumLengthValidator, ThanNumValidator, type TokenManagerProps, _default$a as UserAvatar, type UserAvatarProps, _default$i as VideoPlayer, type VideoPlayerProps, type WebSocketProps, type WebSocketType, absVal, addUrlLastSlash, aesDecrypt, aesEncrypt, arrToObj, buildUrlParams, cachedMessage, calculate, compareNum, convertCurrency, convertNewlineToBr, copyText, createRequest, createSecureManager, createTokenManager, decimalPlaces, deepCopy, deepEqual, deepMerge, dividedBy, downloadFile, emit, emitToChild, executeScript, formatDate, formatNumberWithCommas, formatSize, genNonDuplicateID, generateRandomNumbers, getAllUrlParams, getDeviceId, getEndOfTimestamp, getFileName, getFileSuffixName, getRowSpanCount, getStartOfTimestamp, getTimestamp, getWebSocketUrl, importThirdPartyFile, is, isArray, isBlob, isBoolean, isDate, isDef, isElement, isEmpty, isEmptyObj, isExpire, isExternal, isFunction, isInteger, isJson, isLocalhost, isMap, isNegative, isNull, isNullOrUnDef, isNumber, isNumberNoNaN, isObject, isPromise, isReferenceType, isRegExp, isScriptSafe, isSet, isString, isUnDef, isWindow, markdownToText, minus, objToOptions, plus, precision, processItemList, propsMerge, setInterval, setUrlMainSource, shouldRender, times, toFixed, transform, transforms, _default$8 as useAutoRefresh, _default$7 as useCountDown, _default$6 as useCreateValtioContext, _default$5 as useDebounce, _default$4 as useDeepEffect, _default$9 as useIframeRelayBridge, _default$3 as useRefState, _default$c as useSpeech, _default$2 as useSyncInput, _default$1 as useThrottle, _default as useWebSocket };
|
|
2316
|
+
export { _default$p as AudioPlayer, type AudioPlayerProps, BusinessCode, type CacheMessage, type ComponentMapType, DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT, DEFAULT_YEAR_MONTH_DAY_FORMAT, DEFAULT_YEAR_MONTH_FORMAT, _default$o as DocxPreview, type DocxPreviewProps, _default$n as FileIcon, type FileIconProps, _default$m as FilePreview, _default$l as FilePreviewDrawer, type FilePreviewDrawerProps, type FilePreviewProps, type FindTreeNodesOptions, type FormatSizeOptions, HttpStatus, _default$h as Iframe, type IframeProps, _default$g as LazyComponent, type LazyComponentProps, _default$f as MarkdownEditor, type MarkdownEditorProps, _default$k as MarkdownPreview, type MarkdownPreviewProps, MultiEmailValidator, _default$j as PdfPreview, type PdfPreviewProps, PhoneOrMobileValidator, RegBankCardNo, RegDetailAddress, RegEmail, RegFixedTelePhone, RegIdentityCardNo, RegMobile, RegNumNo, RegPassword, RegSmsCode, RegTaxNo, RegTelePhone, type RenderControl, _default$e as RenderMarkdown, type RenderMarkdownProps, _default$d as RenderWrapper, type RenderWrapperProps, type RequestConfig, type SecureManagerProps, type SetIntervalType, type SizeUnit, _default$b as SpeechButton, type SpeechPermission, type SpeechProps, ThanNumLengthValidator, ThanNumValidator, type TokenManagerProps, _default$a as UserAvatar, type UserAvatarProps, _default$i as VideoPlayer, type VideoPlayerProps, type WebSocketProps, type WebSocketType, absVal, addUrlLastSlash, aesDecrypt, aesEncrypt, arrToObj, buildUrlParams, cachedMessage, calculate, compareNum, convertCurrency, convertNewlineToBr, copyText, createRequest, createSecureManager, createTokenManager, decimalPlaces, deepCopy, deepEqual, deepMerge, dividedBy, downloadFile, emit, emitToChild, executeScript, findTreeNodesByIds, formatDate, formatNumberWithCommas, formatSize, genNonDuplicateID, generateRandomNumbers, getAllUrlParams, getDeviceId, getEndOfTimestamp, getFileName, getFileSuffixName, getRowSpanCount, getStartOfTimestamp, getTimestamp, getWebSocketUrl, importThirdPartyFile, is, isArray, isBlob, isBoolean, isDate, isDef, isElement, isEmpty, isEmptyObj, isExpire, isExternal, isFunction, isInteger, isJson, isLocalhost, isMap, isNegative, isNull, isNullOrUnDef, isNumber, isNumberNoNaN, isObject, isPromise, isReferenceType, isRegExp, isScriptSafe, isSet, isString, isUnDef, isWindow, markdownToText, minus, objToOptions, plus, precision, processItemList, propsMerge, setInterval, setUrlMainSource, shouldRender, times, toFixed, transform, transforms, _default$8 as useAutoRefresh, _default$7 as useCountDown, _default$6 as useCreateValtioContext, _default$5 as useDebounce, _default$4 as useDeepEffect, _default$9 as useIframeRelayBridge, _default$3 as useRefState, _default$c as useSpeech, _default$2 as useSyncInput, _default$1 as useThrottle, _default as useWebSocket };
|
package/dist/index.d.ts
CHANGED
|
@@ -950,9 +950,7 @@ declare const getWebSocketUrl: (path: string, customHost?: string) => string;
|
|
|
950
950
|
* )
|
|
951
951
|
* // => { x: 1, y: 3 }
|
|
952
952
|
*/
|
|
953
|
-
declare
|
|
954
|
-
[K in keyof U]: keyof T | ((source: T) => U[K]) | U[K];
|
|
955
|
-
}): U;
|
|
953
|
+
declare const transform: <T extends object, U extends object>(source: T, fieldMap: { [K in keyof U]: keyof T | ((source: T) => U[K]) | U[K]; }) => U;
|
|
956
954
|
/**
|
|
957
955
|
* 批量对象转换函数
|
|
958
956
|
* @param sources - 源对象数组
|
|
@@ -963,9 +961,7 @@ declare function transform<T extends object, U extends object>(source: T, fieldM
|
|
|
963
961
|
* transforms([{ a: 1 }], { x: 'a' })
|
|
964
962
|
* // => [{ x: 1 }]
|
|
965
963
|
*/
|
|
966
|
-
declare
|
|
967
|
-
[K in keyof U]: keyof T | ((source: T) => U[K]) | U[K];
|
|
968
|
-
}): U[];
|
|
964
|
+
declare const transforms: <T extends object, U extends object>(sources: T[], fieldMap: { [K in keyof U]: keyof T | ((source: T) => U[K]) | U[K]; }) => U[];
|
|
969
965
|
/**
|
|
970
966
|
* 将数字金额转换为中文大写金额
|
|
971
967
|
*
|
|
@@ -1122,14 +1118,14 @@ declare const executeScript: (script: string, params: {
|
|
|
1122
1118
|
* @returns 加密后的字符串
|
|
1123
1119
|
* @throws 当密钥为空或加密过程失败时抛出错误
|
|
1124
1120
|
*/
|
|
1125
|
-
declare
|
|
1121
|
+
declare const aesEncrypt: <T = any>(data: T, key: string) => string;
|
|
1126
1122
|
/**
|
|
1127
1123
|
* AES 解密
|
|
1128
1124
|
* @param data - 加密后的字符串
|
|
1129
1125
|
* @param key - 解密密钥
|
|
1130
1126
|
* @returns 解密后的数据,解密失败时返回null
|
|
1131
1127
|
*/
|
|
1132
|
-
declare
|
|
1128
|
+
declare const aesDecrypt: <T = any>(data: string, key: string) => T | null;
|
|
1133
1129
|
type SizeUnit = 'B' | 'KB' | 'MB' | 'GB' | 'TB' | 'PB';
|
|
1134
1130
|
interface FormatSizeOptions {
|
|
1135
1131
|
/** 起始单位,默认 KB */
|
|
@@ -1166,7 +1162,7 @@ interface FormatSizeOptions {
|
|
|
1166
1162
|
* @remarks
|
|
1167
1163
|
* - 支持从 B, KB, MB, GB, TB, PB 等单位开始转换
|
|
1168
1164
|
*/
|
|
1169
|
-
declare
|
|
1165
|
+
declare const formatSize: (value: number | string, options?: FormatSizeOptions) => number | string;
|
|
1170
1166
|
/**
|
|
1171
1167
|
* Markdown转纯文本
|
|
1172
1168
|
* @param markdown - 原始 Markdown 内容
|
|
@@ -1176,6 +1172,55 @@ declare function formatSize(value: number | string, options?: FormatSizeOptions)
|
|
|
1176
1172
|
* markdownToText('## 标题\n\n- 列表项1\n- 列表项2 <div>123</div>') // '标题 列表项1 列表项2 123'
|
|
1177
1173
|
*/
|
|
1178
1174
|
declare const markdownToText: (markdown: string) => string;
|
|
1175
|
+
interface FindTreeNodesOptions {
|
|
1176
|
+
/** 树的id字段名,默认 "id" */
|
|
1177
|
+
id?: string;
|
|
1178
|
+
/** 子节点字段名,默认 "children" */
|
|
1179
|
+
children?: string;
|
|
1180
|
+
}
|
|
1181
|
+
/**
|
|
1182
|
+
* 从树结构中查找指定id列表的节点,并以自定义结构返回
|
|
1183
|
+
* - 支持跳过某些id(通过formatFn返回null/undefined)
|
|
1184
|
+
* - 支持自定义字段名
|
|
1185
|
+
*
|
|
1186
|
+
* @template T - 树节点类型,必须是键值对对象
|
|
1187
|
+
* @template R - 返回节点类型,默认与T相同
|
|
1188
|
+
* @param tree - 树结构数组
|
|
1189
|
+
* @param ids - 要查找的节点ID列表
|
|
1190
|
+
* @param formatFn - 可选的节点格式化函数,用于自定义返回节点的结构
|
|
1191
|
+
* @param options - 配置选项
|
|
1192
|
+
* @param options.id - ID字段名,默认为 "id"
|
|
1193
|
+
* @param options.children - 子节点字段名,默认为 "children"
|
|
1194
|
+
* @returns 符合ID列表的节点数组,按formatFn格式化后返回
|
|
1195
|
+
*
|
|
1196
|
+
* @example
|
|
1197
|
+
* // 基本用法
|
|
1198
|
+
* const tree = [
|
|
1199
|
+
* { id: 1, name: 'Node 1', children: [{ id: 2, name: 'Node 1-1' }] },
|
|
1200
|
+
* { id: 3, name: 'Node 2', children: [] }
|
|
1201
|
+
* ]
|
|
1202
|
+
* const result = findTreeNodesByIds(tree, [1, 2])
|
|
1203
|
+
* // => [{ id: 1, name: 'Node 1' }, { id: 2, name: 'Node 1-1' }]
|
|
1204
|
+
*
|
|
1205
|
+
* @example
|
|
1206
|
+
* // 使用格式化函数
|
|
1207
|
+
* const result = findTreeNodesByIds(tree, [1], (node) => ({ label: node.name, value: node.id }))
|
|
1208
|
+
* // => [{ label: 'Node 1', value: 1 }]
|
|
1209
|
+
*
|
|
1210
|
+
* @example
|
|
1211
|
+
* // 自定义字段名
|
|
1212
|
+
* const treeWithCustomFields = [
|
|
1213
|
+
* { key: 'a', title: 'Node A', subItems: [{ key: 'b', title: 'Node B' }] }
|
|
1214
|
+
* ]
|
|
1215
|
+
* const result = findTreeNodesByIds(
|
|
1216
|
+
* treeWithCustomFields,
|
|
1217
|
+
* ['a'],
|
|
1218
|
+
* undefined,
|
|
1219
|
+
* { id: 'key', children: 'subItems' }
|
|
1220
|
+
* )
|
|
1221
|
+
* // => [{ key: 'a', title: 'Node A', subItems: undefined }]
|
|
1222
|
+
*/
|
|
1223
|
+
declare const findTreeNodesByIds: <T extends Record<string, any>, R = T>(tree: T[], ids?: T[keyof T][], formatFn?: (node: T) => R | null | undefined, options?: FindTreeNodesOptions) => R[];
|
|
1179
1224
|
|
|
1180
1225
|
type DateType = string | number | Date | dayjs.Dayjs | null;
|
|
1181
1226
|
/** 默认日期时间格式:年-月-日 时:分:秒 */
|
|
@@ -2268,4 +2313,4 @@ declare function createTokenManager({ key, storage }: TokenManagerProps): {
|
|
|
2268
2313
|
clear: () => void;
|
|
2269
2314
|
};
|
|
2270
2315
|
|
|
2271
|
-
export { _default$p as AudioPlayer, type AudioPlayerProps, BusinessCode, type CacheMessage, type ComponentMapType, DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT, DEFAULT_YEAR_MONTH_DAY_FORMAT, DEFAULT_YEAR_MONTH_FORMAT, _default$o as DocxPreview, type DocxPreviewProps, _default$n as FileIcon, type FileIconProps, _default$m as FilePreview, _default$l as FilePreviewDrawer, type FilePreviewDrawerProps, type FilePreviewProps, type FormatSizeOptions, HttpStatus, _default$h as Iframe, type IframeProps, _default$g as LazyComponent, type LazyComponentProps, _default$f as MarkdownEditor, type MarkdownEditorProps, _default$k as MarkdownPreview, type MarkdownPreviewProps, MultiEmailValidator, _default$j as PdfPreview, type PdfPreviewProps, PhoneOrMobileValidator, RegBankCardNo, RegDetailAddress, RegEmail, RegFixedTelePhone, RegIdentityCardNo, RegMobile, RegNumNo, RegPassword, RegSmsCode, RegTaxNo, RegTelePhone, type RenderControl, _default$e as RenderMarkdown, type RenderMarkdownProps, _default$d as RenderWrapper, type RenderWrapperProps, type RequestConfig, type SecureManagerProps, type SetIntervalType, type SizeUnit, _default$b as SpeechButton, type SpeechPermission, type SpeechProps, ThanNumLengthValidator, ThanNumValidator, type TokenManagerProps, _default$a as UserAvatar, type UserAvatarProps, _default$i as VideoPlayer, type VideoPlayerProps, type WebSocketProps, type WebSocketType, absVal, addUrlLastSlash, aesDecrypt, aesEncrypt, arrToObj, buildUrlParams, cachedMessage, calculate, compareNum, convertCurrency, convertNewlineToBr, copyText, createRequest, createSecureManager, createTokenManager, decimalPlaces, deepCopy, deepEqual, deepMerge, dividedBy, downloadFile, emit, emitToChild, executeScript, formatDate, formatNumberWithCommas, formatSize, genNonDuplicateID, generateRandomNumbers, getAllUrlParams, getDeviceId, getEndOfTimestamp, getFileName, getFileSuffixName, getRowSpanCount, getStartOfTimestamp, getTimestamp, getWebSocketUrl, importThirdPartyFile, is, isArray, isBlob, isBoolean, isDate, isDef, isElement, isEmpty, isEmptyObj, isExpire, isExternal, isFunction, isInteger, isJson, isLocalhost, isMap, isNegative, isNull, isNullOrUnDef, isNumber, isNumberNoNaN, isObject, isPromise, isReferenceType, isRegExp, isScriptSafe, isSet, isString, isUnDef, isWindow, markdownToText, minus, objToOptions, plus, precision, processItemList, propsMerge, setInterval, setUrlMainSource, shouldRender, times, toFixed, transform, transforms, _default$8 as useAutoRefresh, _default$7 as useCountDown, _default$6 as useCreateValtioContext, _default$5 as useDebounce, _default$4 as useDeepEffect, _default$9 as useIframeRelayBridge, _default$3 as useRefState, _default$c as useSpeech, _default$2 as useSyncInput, _default$1 as useThrottle, _default as useWebSocket };
|
|
2316
|
+
export { _default$p as AudioPlayer, type AudioPlayerProps, BusinessCode, type CacheMessage, type ComponentMapType, DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT, DEFAULT_YEAR_MONTH_DAY_FORMAT, DEFAULT_YEAR_MONTH_FORMAT, _default$o as DocxPreview, type DocxPreviewProps, _default$n as FileIcon, type FileIconProps, _default$m as FilePreview, _default$l as FilePreviewDrawer, type FilePreviewDrawerProps, type FilePreviewProps, type FindTreeNodesOptions, type FormatSizeOptions, HttpStatus, _default$h as Iframe, type IframeProps, _default$g as LazyComponent, type LazyComponentProps, _default$f as MarkdownEditor, type MarkdownEditorProps, _default$k as MarkdownPreview, type MarkdownPreviewProps, MultiEmailValidator, _default$j as PdfPreview, type PdfPreviewProps, PhoneOrMobileValidator, RegBankCardNo, RegDetailAddress, RegEmail, RegFixedTelePhone, RegIdentityCardNo, RegMobile, RegNumNo, RegPassword, RegSmsCode, RegTaxNo, RegTelePhone, type RenderControl, _default$e as RenderMarkdown, type RenderMarkdownProps, _default$d as RenderWrapper, type RenderWrapperProps, type RequestConfig, type SecureManagerProps, type SetIntervalType, type SizeUnit, _default$b as SpeechButton, type SpeechPermission, type SpeechProps, ThanNumLengthValidator, ThanNumValidator, type TokenManagerProps, _default$a as UserAvatar, type UserAvatarProps, _default$i as VideoPlayer, type VideoPlayerProps, type WebSocketProps, type WebSocketType, absVal, addUrlLastSlash, aesDecrypt, aesEncrypt, arrToObj, buildUrlParams, cachedMessage, calculate, compareNum, convertCurrency, convertNewlineToBr, copyText, createRequest, createSecureManager, createTokenManager, decimalPlaces, deepCopy, deepEqual, deepMerge, dividedBy, downloadFile, emit, emitToChild, executeScript, findTreeNodesByIds, formatDate, formatNumberWithCommas, formatSize, genNonDuplicateID, generateRandomNumbers, getAllUrlParams, getDeviceId, getEndOfTimestamp, getFileName, getFileSuffixName, getRowSpanCount, getStartOfTimestamp, getTimestamp, getWebSocketUrl, importThirdPartyFile, is, isArray, isBlob, isBoolean, isDate, isDef, isElement, isEmpty, isEmptyObj, isExpire, isExternal, isFunction, isInteger, isJson, isLocalhost, isMap, isNegative, isNull, isNullOrUnDef, isNumber, isNumberNoNaN, isObject, isPromise, isReferenceType, isRegExp, isScriptSafe, isSet, isString, isUnDef, isWindow, markdownToText, minus, objToOptions, plus, precision, processItemList, propsMerge, setInterval, setUrlMainSource, shouldRender, times, toFixed, transform, transforms, _default$8 as useAutoRefresh, _default$7 as useCountDown, _default$6 as useCreateValtioContext, _default$5 as useDebounce, _default$4 as useDeepEffect, _default$9 as useIframeRelayBridge, _default$3 as useRefState, _default$c as useSpeech, _default$2 as useSyncInput, _default$1 as useThrottle, _default as useWebSocket };
|
package/dist/index.esm.js
CHANGED
|
@@ -8,12 +8,18 @@ import { forwardRef, useState, useMemo, useEffect, useRef, lazy, Suspense, creat
|
|
|
8
8
|
import AES from 'crypto-js/aes';
|
|
9
9
|
import encUtf8 from 'crypto-js/enc-utf8';
|
|
10
10
|
import MarkdownIt from 'markdown-it';
|
|
11
|
+
import markdownItDefList from 'markdown-it-deflist';
|
|
12
|
+
import { full } from 'markdown-it-emoji';
|
|
13
|
+
import markdownItFootnote from 'markdown-it-footnote';
|
|
14
|
+
import markdownItTaskLists from 'markdown-it-task-lists';
|
|
11
15
|
import Decimal from 'decimal.js';
|
|
12
16
|
import dayjs from 'dayjs';
|
|
13
17
|
import relativeTime from 'dayjs/plugin/relativeTime';
|
|
14
18
|
import axios from 'axios';
|
|
19
|
+
import markdownItKatex from '@traptitech/markdown-it-katex';
|
|
15
20
|
import parse from 'html-react-parser';
|
|
16
21
|
import { jsonrepair } from 'jsonrepair';
|
|
22
|
+
import 'katex/dist/katex.min.css';
|
|
17
23
|
import { Worker, Viewer, PasswordStatus } from '@react-pdf-viewer/core';
|
|
18
24
|
import { pageNavigationPlugin } from '@react-pdf-viewer/page-navigation';
|
|
19
25
|
import { thumbnailPlugin } from '@react-pdf-viewer/thumbnail';
|
|
@@ -561,7 +567,7 @@ var getWebSocketUrl = (path, customHost) => {
|
|
|
561
567
|
const host = customHost || window.location.host;
|
|
562
568
|
return `${protocol}//${host}${path}`;
|
|
563
569
|
};
|
|
564
|
-
|
|
570
|
+
var transform = (source, fieldMap) => {
|
|
565
571
|
const result = {};
|
|
566
572
|
for (const [targetKey, mapping] of Object.entries(fieldMap)) {
|
|
567
573
|
const key = targetKey;
|
|
@@ -574,10 +580,10 @@ function transform(source, fieldMap) {
|
|
|
574
580
|
}
|
|
575
581
|
}
|
|
576
582
|
return result;
|
|
577
|
-
}
|
|
578
|
-
|
|
583
|
+
};
|
|
584
|
+
var transforms = (sources, fieldMap) => {
|
|
579
585
|
return sources?.map((source) => transform(source, fieldMap)) || [];
|
|
580
|
-
}
|
|
586
|
+
};
|
|
581
587
|
var convertCurrency = (money = "") => {
|
|
582
588
|
let newMoney = money;
|
|
583
589
|
const cnNums = ["\u96F6", "\u58F9", "\u8D30", "\u53C1", "\u8086", "\u4F0D", "\u9646", "\u67D2", "\u634C", "\u7396"];
|
|
@@ -723,7 +729,7 @@ var executeScript = (script, params) => {
|
|
|
723
729
|
console.error("unsafe script");
|
|
724
730
|
}
|
|
725
731
|
};
|
|
726
|
-
|
|
732
|
+
var aesEncrypt = (data, key) => {
|
|
727
733
|
if (!key) throw new Error("AES Encrypt: key is required");
|
|
728
734
|
if (isNullOrUnDef(data)) return "";
|
|
729
735
|
try {
|
|
@@ -733,8 +739,8 @@ function aesEncrypt(data, key) {
|
|
|
733
739
|
console.error("AES Encrypt error:", err);
|
|
734
740
|
throw new Error("AES Encrypt failed");
|
|
735
741
|
}
|
|
736
|
-
}
|
|
737
|
-
|
|
742
|
+
};
|
|
743
|
+
var aesDecrypt = (data, key) => {
|
|
738
744
|
if (!key) throw new Error("AES Decrypt: key is required");
|
|
739
745
|
if (!data) return null;
|
|
740
746
|
try {
|
|
@@ -746,8 +752,8 @@ function aesDecrypt(data, key) {
|
|
|
746
752
|
console.error("AES Decrypt error:", err);
|
|
747
753
|
return null;
|
|
748
754
|
}
|
|
749
|
-
}
|
|
750
|
-
|
|
755
|
+
};
|
|
756
|
+
var formatSize = (value, options = {}) => {
|
|
751
757
|
if (isNullOrUnDef(value) || !isNumberNoNaN(Number(value))) return value;
|
|
752
758
|
const UNIT_LIST = ["B", "KB", "MB", "GB", "TB", "PB"];
|
|
753
759
|
const { from = "KB", precision: precision2 = 2, trimZero = false, maxUnit } = options;
|
|
@@ -767,20 +773,45 @@ function formatSize(value, options = {}) {
|
|
|
767
773
|
index++;
|
|
768
774
|
}
|
|
769
775
|
return `${toFixed(size, precision2, !trimZero)}${UNIT_LIST[index]}`;
|
|
770
|
-
}
|
|
776
|
+
};
|
|
771
777
|
var markdownToText = (() => {
|
|
772
778
|
const md2 = new MarkdownIt({
|
|
773
779
|
html: true,
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
});
|
|
780
|
+
breaks: true
|
|
781
|
+
}).use(markdownItTaskLists).use(full).use(markdownItFootnote).use(markdownItDefList);
|
|
777
782
|
return (markdown) => {
|
|
778
783
|
if (!isString(markdown)) return "";
|
|
779
784
|
const html = md2.render(markdown);
|
|
780
|
-
const text = html.replace(/<[^>]+>/g, "
|
|
785
|
+
const text = html.replace(/<[^>]+>/g, " ").replace(/"/g, '"').replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/'/g, "'").replace(/\s+/g, " ").trim();
|
|
781
786
|
return text;
|
|
782
787
|
};
|
|
783
788
|
})();
|
|
789
|
+
var findTreeNodesByIds = (tree, ids, formatFn, options = {}) => {
|
|
790
|
+
const { id = "id", children = "children" } = options;
|
|
791
|
+
if (!ids?.length) {
|
|
792
|
+
return [];
|
|
793
|
+
}
|
|
794
|
+
const result = [];
|
|
795
|
+
const idSet = new Set(ids);
|
|
796
|
+
const dfs = (nodes) => {
|
|
797
|
+
for (const node of nodes) {
|
|
798
|
+
if (idSet.size === 0) break;
|
|
799
|
+
const nodeId = node[id];
|
|
800
|
+
if (idSet.has(nodeId)) {
|
|
801
|
+
idSet.delete(nodeId);
|
|
802
|
+
const formatted = formatFn ? formatFn(node) : { ...node, [children]: void 0 };
|
|
803
|
+
if (!isNullOrUnDef(formatted)) {
|
|
804
|
+
result.push(formatted);
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
if (node[children]?.length && idSet.size > 0) {
|
|
808
|
+
dfs(node[children]);
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
};
|
|
812
|
+
dfs(tree);
|
|
813
|
+
return result;
|
|
814
|
+
};
|
|
784
815
|
dayjs.extend(relativeTime);
|
|
785
816
|
var DEFAULT_DATE_TIME_FORMAT = "YYYY-MM-DD HH:mm:ss";
|
|
786
817
|
var DEFAULT_DATE_FORMAT = "YYYY-MM-DD";
|
|
@@ -1262,7 +1293,7 @@ var LazyComponent_default = ({ type, customComponents, ...rest }) => {
|
|
|
1262
1293
|
] });
|
|
1263
1294
|
return /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "\u52A0\u8F7D\u4E2D..." }), children: /* @__PURE__ */ jsx(LazyComponent, { ...rest }) });
|
|
1264
1295
|
};
|
|
1265
|
-
var md = MarkdownIt({ html: true, breaks: true });
|
|
1296
|
+
var md = MarkdownIt({ html: true, breaks: true }).use(markdownItTaskLists).use(full).use(markdownItFootnote).use(markdownItDefList).use(markdownItKatex);
|
|
1266
1297
|
md.renderer.rules.link_open = function(tokens, idx, options, env, self) {
|
|
1267
1298
|
const token = tokens[idx];
|
|
1268
1299
|
token.attrPush(["target", "_blank"]);
|
|
@@ -1576,7 +1607,7 @@ var useDeepEffect_default = (effect, deps) => {
|
|
|
1576
1607
|
prevDepsRef.current = deps;
|
|
1577
1608
|
return effect();
|
|
1578
1609
|
}
|
|
1579
|
-
}, [depsChanged]);
|
|
1610
|
+
}, [depsChanged, effect, ...deps]);
|
|
1580
1611
|
};
|
|
1581
1612
|
var useRefState_default = (init) => {
|
|
1582
1613
|
const [state, setState] = useState(init);
|
|
@@ -1990,7 +2021,7 @@ var PdfPreview_default = ({ password, fileUrl, pageNo = 1, scale = 1, isHasThumb
|
|
|
1990
2021
|
}, 500);
|
|
1991
2022
|
onSetPageNo?.(currentPage + 1);
|
|
1992
2023
|
}, [currentPage]);
|
|
1993
|
-
return /* @__PURE__ */ jsx("div", { ref: embedRef, className: styles_module_default.nsPreviewPdf, children: /* @__PURE__ */ jsx(Worker, { workerUrl:
|
|
2024
|
+
return /* @__PURE__ */ jsx("div", { ref: embedRef, className: styles_module_default.nsPreviewPdf, children: /* @__PURE__ */ jsx(Worker, { workerUrl: `https://logosdata.cn/public/pdf/pdf.worker.min.js`, children: /* @__PURE__ */ jsxs(Splitter, { onResize: setSizes, children: [
|
|
1994
2025
|
isHasThumbnails && /* @__PURE__ */ jsx(Splitter.Panel, { resizable: false, size: sizes[0], min: 250, max: 500, collapsible: true, children: /* @__PURE__ */ jsx(Thumbnails, {}) }),
|
|
1995
2026
|
/* @__PURE__ */ jsx(Splitter.Panel, { children: /* @__PURE__ */ jsxs("div", { className: "height-full", children: [
|
|
1996
2027
|
/* @__PURE__ */ jsx(
|
|
@@ -2011,13 +2042,13 @@ var PdfPreview_default = ({ password, fileUrl, pageNo = 1, scale = 1, isHasThumb
|
|
|
2011
2042
|
// 启用 CMap 支持,解决中文字体显示问题
|
|
2012
2043
|
// cMapUrl: 指定 CMap 文件的 URL,用于处理非拉丁字符(如中文)
|
|
2013
2044
|
// cMapPacked: 使用压缩的 CMap 文件以提高性能
|
|
2014
|
-
cMapUrl: "
|
|
2045
|
+
cMapUrl: "https://logosdata.cn/public/pdf/pdfjs-dist@3.2.146/cmaps/",
|
|
2015
2046
|
// 使用可用的源
|
|
2016
2047
|
cMapPacked: true,
|
|
2017
2048
|
// 禁用字体子集化,确保完整字体加载
|
|
2018
2049
|
disableFontFace: false,
|
|
2019
2050
|
// 启用标准字体支持
|
|
2020
|
-
standardFontDataUrl: "
|
|
2051
|
+
standardFontDataUrl: "https://logosdata.cn/public/pdf/pdfjs-dist@3.2.146/standard_fonts/",
|
|
2021
2052
|
// 设置字体回退策略
|
|
2022
2053
|
fallbackFontName: "Helvetica"
|
|
2023
2054
|
});
|
|
@@ -5984,6 +6015,6 @@ var UserAvatar_default = ({ size, avatarSrc, userName }) => {
|
|
|
5984
6015
|
return avatarSrc ? /* @__PURE__ */ jsx(Avatar, { size, src: avatarSrc }) : /* @__PURE__ */ jsx(Avatar, { size, className: "cursor-pointer", style: { backgroundColor: "var(--ant-color-primary)" }, children: userName?.slice(0, 1)?.toLocaleUpperCase() });
|
|
5985
6016
|
};
|
|
5986
6017
|
|
|
5987
|
-
export { AudioPlayer_default as AudioPlayer, BusinessCode, DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT, DEFAULT_YEAR_MONTH_DAY_FORMAT, DEFAULT_YEAR_MONTH_FORMAT, DocxPreview_default as DocxPreview, FileIcon_default as FileIcon, FilePreview_default as FilePreview, FilePreviewDrawer_default as FilePreviewDrawer, HttpStatus, Iframe_default as Iframe, LazyComponent_default as LazyComponent, MarkdownEditor_default as MarkdownEditor, MarkdownPreview_default as MarkdownPreview, MultiEmailValidator, PdfPreview_default as PdfPreview, PhoneOrMobileValidator, RegBankCardNo, RegDetailAddress, RegEmail, RegFixedTelePhone, RegIdentityCardNo, RegMobile, RegNumNo, RegPassword, RegSmsCode, RegTaxNo, RegTelePhone, RenderMarkdown_default as RenderMarkdown, RenderWrapper_default as RenderWrapper, SpeechButton_default as SpeechButton, ThanNumLengthValidator, ThanNumValidator, UserAvatar_default as UserAvatar, VideoPlayer_default as VideoPlayer, absVal, addUrlLastSlash, aesDecrypt, aesEncrypt, arrToObj, buildUrlParams, cachedMessage, calculate, compareNum, convertCurrency, convertNewlineToBr, copyText, createRequest, createSecureManager, createTokenManager, decimalPlaces, deepCopy, deepEqual, deepMerge, dividedBy, downloadFile, emit, emitToChild, executeScript, formatDate, formatNumberWithCommas, formatSize, genNonDuplicateID, generateRandomNumbers, getAllUrlParams, getDeviceId, getEndOfTimestamp, getFileName, getFileSuffixName, getRowSpanCount, getStartOfTimestamp, getTimestamp, getWebSocketUrl, importThirdPartyFile, is, isArray, isBlob, isBoolean, isDate, isDef, isElement, isEmpty, isEmptyObj, isExpire, isExternal, isFunction, isInteger, isJson, isLocalhost, isMap, isNegative, isNull, isNullOrUnDef, isNumber, isNumberNoNaN, isObject, isPromise, isReferenceType, isRegExp, isScriptSafe, isSet, isString, isUnDef, isWindow, markdownToText, minus, objToOptions, plus, precision, processItemList, propsMerge, setInterval2 as setInterval, setUrlMainSource, shouldRender, times, toFixed, transform, transforms, useAutoRefresh_default as useAutoRefresh, useCountDown_default as useCountDown, useCreateValtioContext_default as useCreateValtioContext, useDebounce_default as useDebounce, useDeepEffect_default as useDeepEffect, useIframeRelayBridge_default as useIframeRelayBridge, useRefState_default as useRefState, useSpeech_default as useSpeech, useSyncInput_default as useSyncInput, useThrottle_default as useThrottle, useWebSocket_default as useWebSocket };
|
|
6018
|
+
export { AudioPlayer_default as AudioPlayer, BusinessCode, DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT, DEFAULT_YEAR_MONTH_DAY_FORMAT, DEFAULT_YEAR_MONTH_FORMAT, DocxPreview_default as DocxPreview, FileIcon_default as FileIcon, FilePreview_default as FilePreview, FilePreviewDrawer_default as FilePreviewDrawer, HttpStatus, Iframe_default as Iframe, LazyComponent_default as LazyComponent, MarkdownEditor_default as MarkdownEditor, MarkdownPreview_default as MarkdownPreview, MultiEmailValidator, PdfPreview_default as PdfPreview, PhoneOrMobileValidator, RegBankCardNo, RegDetailAddress, RegEmail, RegFixedTelePhone, RegIdentityCardNo, RegMobile, RegNumNo, RegPassword, RegSmsCode, RegTaxNo, RegTelePhone, RenderMarkdown_default as RenderMarkdown, RenderWrapper_default as RenderWrapper, SpeechButton_default as SpeechButton, ThanNumLengthValidator, ThanNumValidator, UserAvatar_default as UserAvatar, VideoPlayer_default as VideoPlayer, absVal, addUrlLastSlash, aesDecrypt, aesEncrypt, arrToObj, buildUrlParams, cachedMessage, calculate, compareNum, convertCurrency, convertNewlineToBr, copyText, createRequest, createSecureManager, createTokenManager, decimalPlaces, deepCopy, deepEqual, deepMerge, dividedBy, downloadFile, emit, emitToChild, executeScript, findTreeNodesByIds, formatDate, formatNumberWithCommas, formatSize, genNonDuplicateID, generateRandomNumbers, getAllUrlParams, getDeviceId, getEndOfTimestamp, getFileName, getFileSuffixName, getRowSpanCount, getStartOfTimestamp, getTimestamp, getWebSocketUrl, importThirdPartyFile, is, isArray, isBlob, isBoolean, isDate, isDef, isElement, isEmpty, isEmptyObj, isExpire, isExternal, isFunction, isInteger, isJson, isLocalhost, isMap, isNegative, isNull, isNullOrUnDef, isNumber, isNumberNoNaN, isObject, isPromise, isReferenceType, isRegExp, isScriptSafe, isSet, isString, isUnDef, isWindow, markdownToText, minus, objToOptions, plus, precision, processItemList, propsMerge, setInterval2 as setInterval, setUrlMainSource, shouldRender, times, toFixed, transform, transforms, useAutoRefresh_default as useAutoRefresh, useCountDown_default as useCountDown, useCreateValtioContext_default as useCreateValtioContext, useDebounce_default as useDebounce, useDeepEffect_default as useDeepEffect, useIframeRelayBridge_default as useIframeRelayBridge, useRefState_default as useRefState, useSpeech_default as useSpeech, useSyncInput_default as useSyncInput, useThrottle_default as useThrottle, useWebSocket_default as useWebSocket };
|
|
5988
6019
|
//# sourceMappingURL=index.esm.js.map
|
|
5989
6020
|
//# sourceMappingURL=index.esm.js.map
|