@zero-library/common 2.2.9 → 2.2.11
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 +42 -15
- 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 +42 -16
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -600,7 +600,7 @@ var getWebSocketUrl = (path, customHost) => {
|
|
|
600
600
|
const host = customHost || window.location.host;
|
|
601
601
|
return `${protocol}//${host}${path}`;
|
|
602
602
|
};
|
|
603
|
-
|
|
603
|
+
var transform = (source, fieldMap) => {
|
|
604
604
|
const result = {};
|
|
605
605
|
for (const [targetKey, mapping] of Object.entries(fieldMap)) {
|
|
606
606
|
const key = targetKey;
|
|
@@ -613,10 +613,10 @@ function transform(source, fieldMap) {
|
|
|
613
613
|
}
|
|
614
614
|
}
|
|
615
615
|
return result;
|
|
616
|
-
}
|
|
617
|
-
|
|
616
|
+
};
|
|
617
|
+
var transforms = (sources, fieldMap) => {
|
|
618
618
|
return sources?.map((source) => transform(source, fieldMap)) || [];
|
|
619
|
-
}
|
|
619
|
+
};
|
|
620
620
|
var convertCurrency = (money = "") => {
|
|
621
621
|
let newMoney = money;
|
|
622
622
|
const cnNums = ["\u96F6", "\u58F9", "\u8D30", "\u53C1", "\u8086", "\u4F0D", "\u9646", "\u67D2", "\u634C", "\u7396"];
|
|
@@ -762,7 +762,7 @@ var executeScript = (script, params) => {
|
|
|
762
762
|
console.error("unsafe script");
|
|
763
763
|
}
|
|
764
764
|
};
|
|
765
|
-
|
|
765
|
+
var aesEncrypt = (data, key) => {
|
|
766
766
|
if (!key) throw new Error("AES Encrypt: key is required");
|
|
767
767
|
if (isNullOrUnDef(data)) return "";
|
|
768
768
|
try {
|
|
@@ -772,8 +772,8 @@ function aesEncrypt(data, key) {
|
|
|
772
772
|
console.error("AES Encrypt error:", err);
|
|
773
773
|
throw new Error("AES Encrypt failed");
|
|
774
774
|
}
|
|
775
|
-
}
|
|
776
|
-
|
|
775
|
+
};
|
|
776
|
+
var aesDecrypt = (data, key) => {
|
|
777
777
|
if (!key) throw new Error("AES Decrypt: key is required");
|
|
778
778
|
if (!data) return null;
|
|
779
779
|
try {
|
|
@@ -785,8 +785,8 @@ function aesDecrypt(data, key) {
|
|
|
785
785
|
console.error("AES Decrypt error:", err);
|
|
786
786
|
return null;
|
|
787
787
|
}
|
|
788
|
-
}
|
|
789
|
-
|
|
788
|
+
};
|
|
789
|
+
var formatSize = (value, options = {}) => {
|
|
790
790
|
if (isNullOrUnDef(value) || !isNumberNoNaN(Number(value))) return value;
|
|
791
791
|
const UNIT_LIST = ["B", "KB", "MB", "GB", "TB", "PB"];
|
|
792
792
|
const { from = "KB", precision: precision2 = 2, trimZero = false, maxUnit } = options;
|
|
@@ -806,7 +806,7 @@ function formatSize(value, options = {}) {
|
|
|
806
806
|
index++;
|
|
807
807
|
}
|
|
808
808
|
return `${toFixed(size, precision2, !trimZero)}${UNIT_LIST[index]}`;
|
|
809
|
-
}
|
|
809
|
+
};
|
|
810
810
|
var markdownToText = (() => {
|
|
811
811
|
const md2 = new MarkdownIt__default.default({
|
|
812
812
|
html: true,
|
|
@@ -820,6 +820,32 @@ var markdownToText = (() => {
|
|
|
820
820
|
return text;
|
|
821
821
|
};
|
|
822
822
|
})();
|
|
823
|
+
var findTreeNodesByIds = (tree, ids, formatFn, options = {}) => {
|
|
824
|
+
const { id = "id", children = "children" } = options;
|
|
825
|
+
if (!ids?.length) {
|
|
826
|
+
return [];
|
|
827
|
+
}
|
|
828
|
+
const result = [];
|
|
829
|
+
const idSet = new Set(ids);
|
|
830
|
+
const dfs = (nodes) => {
|
|
831
|
+
for (const node of nodes) {
|
|
832
|
+
if (idSet.size === 0) break;
|
|
833
|
+
const nodeId = node[id];
|
|
834
|
+
if (idSet.has(nodeId)) {
|
|
835
|
+
idSet.delete(nodeId);
|
|
836
|
+
const formatted = formatFn ? formatFn(node) : { ...node, [children]: void 0 };
|
|
837
|
+
if (!isNullOrUnDef(formatted)) {
|
|
838
|
+
result.push(formatted);
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
if (node[children]?.length && idSet.size > 0) {
|
|
842
|
+
dfs(node[children]);
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
};
|
|
846
|
+
dfs(tree);
|
|
847
|
+
return result;
|
|
848
|
+
};
|
|
823
849
|
dayjs__default.default.extend(relativeTime__default.default);
|
|
824
850
|
var DEFAULT_DATE_TIME_FORMAT = "YYYY-MM-DD HH:mm:ss";
|
|
825
851
|
var DEFAULT_DATE_FORMAT = "YYYY-MM-DD";
|
|
@@ -1209,7 +1235,7 @@ var DocxPreview_default = ({ fileUrl, scale = 1 }) => {
|
|
|
1209
1235
|
const resetZoom = () => {
|
|
1210
1236
|
setZoomRatio(1);
|
|
1211
1237
|
};
|
|
1212
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classNames__default.default(styles_module_default.nsPreviewDocx, "height-full"), children: [
|
|
1238
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classNames__default.default(styles_module_default.nsPreviewDocx, "height-full", "width-full"), children: [
|
|
1213
1239
|
/* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { gap: 6, align: "center", className: styles_module_default.docxToolbar, children: [
|
|
1214
1240
|
/* @__PURE__ */ jsxRuntime.jsx(antd.Button, { onClick: zoomOut, icon: /* @__PURE__ */ jsxRuntime.jsx(Icon.MinusCircleOutlined, {}), title: "\u7F29\u5C0F" }),
|
|
1215
1241
|
/* @__PURE__ */ jsxRuntime.jsx(antd.Button, { onClick: zoomIn, icon: /* @__PURE__ */ jsxRuntime.jsx(Icon.PlusCircleOutlined, {}), title: "\u653E\u5927" }),
|
|
@@ -1448,7 +1474,7 @@ var MarkdownPreview_default = ({ fileUrl, searchValue }) => {
|
|
|
1448
1474
|
React16.useEffect(() => {
|
|
1449
1475
|
init();
|
|
1450
1476
|
}, [fileUrl]);
|
|
1451
|
-
return error ? /* @__PURE__ */ jsxRuntime.jsx(antd.Result, { status: "error", title: error }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "height-full", children: /* @__PURE__ */ jsxRuntime.jsx(RenderMarkdown_default, { content, searchValue }) });
|
|
1477
|
+
return error ? /* @__PURE__ */ jsxRuntime.jsx(antd.Result, { status: "error", title: error }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "height-full width-full", children: /* @__PURE__ */ jsxRuntime.jsx(RenderMarkdown_default, { content, searchValue }) });
|
|
1452
1478
|
};
|
|
1453
1479
|
|
|
1454
1480
|
// src/hooks/iframe/iframeRelay.ts
|
|
@@ -2029,7 +2055,7 @@ var PdfPreview_default = ({ password, fileUrl, pageNo = 1, scale = 1, isHasThumb
|
|
|
2029
2055
|
}, 500);
|
|
2030
2056
|
onSetPageNo?.(currentPage + 1);
|
|
2031
2057
|
}, [currentPage]);
|
|
2032
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: embedRef, className: styles_module_default.nsPreviewPdf, children: /* @__PURE__ */ jsxRuntime.jsx(core$1.Worker, { workerUrl:
|
|
2058
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: embedRef, className: styles_module_default.nsPreviewPdf, children: /* @__PURE__ */ jsxRuntime.jsx(core$1.Worker, { workerUrl: `https://logosdata.cn/public/pdf/pdf.worker.min.js`, children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Splitter, { onResize: setSizes, children: [
|
|
2033
2059
|
isHasThumbnails && /* @__PURE__ */ jsxRuntime.jsx(antd.Splitter.Panel, { resizable: false, size: sizes[0], min: 250, max: 500, collapsible: true, children: /* @__PURE__ */ jsxRuntime.jsx(Thumbnails, {}) }),
|
|
2034
2060
|
/* @__PURE__ */ jsxRuntime.jsx(antd.Splitter.Panel, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "height-full", children: [
|
|
2035
2061
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2050,13 +2076,13 @@ var PdfPreview_default = ({ password, fileUrl, pageNo = 1, scale = 1, isHasThumb
|
|
|
2050
2076
|
// 启用 CMap 支持,解决中文字体显示问题
|
|
2051
2077
|
// cMapUrl: 指定 CMap 文件的 URL,用于处理非拉丁字符(如中文)
|
|
2052
2078
|
// cMapPacked: 使用压缩的 CMap 文件以提高性能
|
|
2053
|
-
cMapUrl: "
|
|
2079
|
+
cMapUrl: "https://logosdata.cn/public/pdf/pdfjs-dist@3.2.146/cmaps/",
|
|
2054
2080
|
// 使用可用的源
|
|
2055
2081
|
cMapPacked: true,
|
|
2056
2082
|
// 禁用字体子集化,确保完整字体加载
|
|
2057
2083
|
disableFontFace: false,
|
|
2058
2084
|
// 启用标准字体支持
|
|
2059
|
-
standardFontDataUrl: "
|
|
2085
|
+
standardFontDataUrl: "https://logosdata.cn/public/pdf/pdfjs-dist@3.2.146/standard_fonts/",
|
|
2060
2086
|
// 设置字体回退策略
|
|
2061
2087
|
fallbackFontName: "Helvetica"
|
|
2062
2088
|
});
|
|
@@ -6083,6 +6109,7 @@ exports.downloadFile = downloadFile;
|
|
|
6083
6109
|
exports.emit = emit;
|
|
6084
6110
|
exports.emitToChild = emitToChild;
|
|
6085
6111
|
exports.executeScript = executeScript;
|
|
6112
|
+
exports.findTreeNodesByIds = findTreeNodesByIds;
|
|
6086
6113
|
exports.formatDate = formatDate;
|
|
6087
6114
|
exports.formatNumberWithCommas = formatNumberWithCommas;
|
|
6088
6115
|
exports.formatSize = formatSize;
|