@zero-library/common 2.3.2 → 2.3.4

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.mts CHANGED
@@ -289,7 +289,6 @@ type CollectionType = {
289
289
  text: string;
290
290
  from: number;
291
291
  to: number;
292
- pageNo?: string;
293
292
  } & {
294
293
  [key in (typeof COLLECTION_ATTRS)[number]]: string;
295
294
  };
@@ -387,8 +386,9 @@ interface SizeType {
387
386
  }
388
387
  interface MarkDrawingProps {
389
388
  children: ReactNode;
390
- detections: Detection[];
389
+ detections?: Detection[];
391
390
  originalSize: SizeType;
391
+ scopeRender?: (score: number) => ReactNode;
392
392
  }
393
393
  /**
394
394
  * MarkDrawing组件
@@ -397,8 +397,9 @@ interface MarkDrawingProps {
397
397
  * @param children - 待绘制标注的内容
398
398
  * @param detections - 检测结果数组
399
399
  * @param originalSize - 原始尺寸信息
400
+ * @param scopeRender - 可选的作用域渲染函数
400
401
  */
401
- declare const _default$f: ({ children, detections, originalSize }: MarkDrawingProps) => react_jsx_runtime.JSX.Element;
402
+ declare const _default$f: ({ children, detections, originalSize, scopeRender }: MarkDrawingProps) => react_jsx_runtime.JSX.Element;
402
403
 
403
404
  /**
404
405
  * Markdown渲染组件属性接口
@@ -908,6 +909,7 @@ declare const setInterval: (fn: () => void | Promise<void>, t: number) => {
908
909
  /**
909
910
  * 生成唯一的 UUID v4 格式 ID
910
911
  * 使用 crypto.randomUUID() 生成符合 RFC 4122 标准的 UUID
912
+ * 如果浏览器不支持 crypto.randomUUID(),则使用 Math.random() 生成随机数
911
913
  *
912
914
  * @returns 符合 UUID v4 格式的唯一标识符字符串
913
915
  *
package/dist/index.d.ts CHANGED
@@ -289,7 +289,6 @@ type CollectionType = {
289
289
  text: string;
290
290
  from: number;
291
291
  to: number;
292
- pageNo?: string;
293
292
  } & {
294
293
  [key in (typeof COLLECTION_ATTRS)[number]]: string;
295
294
  };
@@ -387,8 +386,9 @@ interface SizeType {
387
386
  }
388
387
  interface MarkDrawingProps {
389
388
  children: ReactNode;
390
- detections: Detection[];
389
+ detections?: Detection[];
391
390
  originalSize: SizeType;
391
+ scopeRender?: (score: number) => ReactNode;
392
392
  }
393
393
  /**
394
394
  * MarkDrawing组件
@@ -397,8 +397,9 @@ interface MarkDrawingProps {
397
397
  * @param children - 待绘制标注的内容
398
398
  * @param detections - 检测结果数组
399
399
  * @param originalSize - 原始尺寸信息
400
+ * @param scopeRender - 可选的作用域渲染函数
400
401
  */
401
- declare const _default$f: ({ children, detections, originalSize }: MarkDrawingProps) => react_jsx_runtime.JSX.Element;
402
+ declare const _default$f: ({ children, detections, originalSize, scopeRender }: MarkDrawingProps) => react_jsx_runtime.JSX.Element;
402
403
 
403
404
  /**
404
405
  * Markdown渲染组件属性接口
@@ -908,6 +909,7 @@ declare const setInterval: (fn: () => void | Promise<void>, t: number) => {
908
909
  /**
909
910
  * 生成唯一的 UUID v4 格式 ID
910
911
  * 使用 crypto.randomUUID() 生成符合 RFC 4122 标准的 UUID
912
+ * 如果浏览器不支持 crypto.randomUUID(),则使用 Math.random() 生成随机数
911
913
  *
912
914
  * @returns 符合 UUID v4 格式的唯一标识符字符串
913
915
  *
package/dist/index.esm.js CHANGED
@@ -445,7 +445,14 @@ var setInterval2 = (fn, t) => {
445
445
  };
446
446
  };
447
447
  var genNonDuplicateID = () => {
448
- return crypto.randomUUID();
448
+ if (crypto?.randomUUID) {
449
+ return crypto.randomUUID();
450
+ }
451
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
452
+ const r = Math.random() * 16 | 0;
453
+ const v = c === "x" ? r : r & 3 | 8;
454
+ return v.toString(16);
455
+ });
449
456
  };
450
457
  var copyText = async (text, prompt = "\u590D\u5236\u6210\u529F") => {
451
458
  try {
@@ -8546,7 +8553,6 @@ var MarkdownEditor_default = ({
8546
8553
  content: value,
8547
8554
  contentType: "markdown",
8548
8555
  onUpdate: () => {
8549
- console.log("update \u6587\u672C\u6539\u53D8");
8550
8556
  const markdownOutput = getMarkdown();
8551
8557
  if (markdownOutput === lastContentRef.current) return;
8552
8558
  lastContentRef.current = markdownOutput;
@@ -8690,7 +8696,7 @@ var styles_module_default7 = {
8690
8696
  rect: "styles_module_rect",
8691
8697
  score: "styles_module_score"
8692
8698
  };
8693
- var MarkDrawing_default = ({ children, detections, originalSize }) => {
8699
+ var MarkDrawing_default = ({ children, detections, originalSize, scopeRender }) => {
8694
8700
  const containerRef = useRef(null);
8695
8701
  const [containerSize, setContainerSize] = useState({
8696
8702
  width: originalSize.width,
@@ -8711,7 +8717,7 @@ var MarkDrawing_default = ({ children, detections, originalSize }) => {
8711
8717
  const scaleY = containerSize.height / originalSize.height;
8712
8718
  return /* @__PURE__ */ jsxs("div", { ref: containerRef, className: styles_module_default7.container, children: [
8713
8719
  children,
8714
- detections.map((det, idx) => {
8720
+ detections?.map((det, idx) => {
8715
8721
  const [x1, y1, x2, y2] = det.bbox;
8716
8722
  const left = x1 * scaleX;
8717
8723
  const top = y1 * scaleY;
@@ -8738,7 +8744,7 @@ var MarkDrawing_default = ({ children, detections, originalSize }) => {
8738
8744
  left,
8739
8745
  top: Math.max(top - 20, 0)
8740
8746
  },
8741
- children: det.score.toFixed(3)
8747
+ children: scopeRender ? scopeRender(det.score) : det.score
8742
8748
  }
8743
8749
  )
8744
8750
  ] }, idx);