@labelbee/lb-components 1.23.0-alpha.31 → 1.23.0-alpha.33

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.
@@ -59,7 +59,7 @@ export default class AnnotationDataUtils {
59
59
  * @param currentResult 当前的步骤
60
60
  * @returns
61
61
  */
62
- static copyResultChange(params: ICopyResultChangeParams): string;
62
+ static copyResultChange(params: ICopyResultChangeParams): string | undefined;
63
63
  /**
64
64
  * 判断结果sourceID与依赖数据的id是否能对应
65
65
  * @param result
@@ -1 +1 @@
1
- "use strict";var lbAnnotation=require("@labelbee/lb-annotation"),index=require("./index.js"),ToolType=require("../data/enums/ToolType.js"),_=require("lodash"),StepUtils=require("./StepUtils.js");function _interopDefaultLegacy(c){return c&&typeof c=="object"&&"default"in c?c:{default:c}}var ___default=_interopDefaultLegacy(_);class AnnotationDataUtils{static traverseDF(t,e,s,i){e(t,s,i),typeof t=="object"&&t!==null&&(Array.isArray(t)?t.forEach((n,r)=>{this.traverseDF(n,e,r,t)}):Object.keys(t).forEach(n=>{this.traverseDF(t[n],e,n,t)}))}static getNextPath(t){var e,s,i;const{prePath:n,preMappingImgList:r,nextMappingImgList:a}=t,u=(s=(e=r==null?void 0:r.find(l=>l.path===n))==null?void 0:e.calib)==null?void 0:s.calName,o=(i=a.find(l=>{var d;return((d=l.calib)==null?void 0:d.calName)===u}))==null?void 0:i.path;return o!=null?o:""}static copyResultItemHandler(t){const{item:e,key:s,parent:i,mappingImgList:n,preMappingImgList:r}=t;s==="id"&&(i.id=lbAnnotation.uuid(8,62)),s==="imageName"&&(i.imageName=this.getNextPath({prePath:e,preMappingImgList:r,nextMappingImgList:n}))}static copyResultChange(t){const{copyResult:e,step:s,currentResult:i,mappingImgList:n,preMappingImgList:r}=t;try{const a=index.jsonParser(e),u=index.jsonParser(i),o=`step_${s}`;if(a[o]){const l=a[o];return["result","resultRect"].forEach(p=>{l[p]&&this.traverseDF(l[p],(f,m,h)=>{this.copyResultItemHandler({item:f,key:m,parent:h,mappingImgList:n,preMappingImgList:r})})}),u[o]=l,JSON.stringify(u)}return e}catch(a){return e}}static isResultSourceMatchedDependence(t,e){const s=t==null?void 0:t.map(n=>n.sourceID).sort(),i=e==null?void 0:e.map(n=>n.id).sort();return ___default.default.isEqual(s,i)}static deltaUpdateBasicResultList(t,e){const s=t==null?void 0:t.map(i=>i.sourceID).sort();return e.filter(i=>!s.includes(i.id))}static getInitialResultList(t,e,s,i,n){const r=t!=null?t:[];switch(s.tool){case ToolType.EToolName.Tag:case ToolType.EToolName.Text:{if(s.dataSourceStep>0){const a=this.deltaUpdateBasicResultList(r,i);if(a.length>0)return r.concat(e.getInitResultList(s.dataSourceStep,a))}return n!==!0?r:e.getInitResultList(s.dataSourceStep,i)}default:return r}}static dataCorrection(t,e,s,i){var n,r;try{const u=`step_${StepUtils.getStepInfo(s,i).step}`,o=index.jsonParser(t),l=index.jsonParser(e),d=(n=o[u])==null?void 0:n.result,p=(r=l[u])==null?void 0:r.result;if(!p||___default.default.isEqual(d.sort(this.idCmp),p.sort(this.idCmp)))return t;const f=this.findDeletedIds(d,p);if(f.length===0)return t;const m=s,h=this.getStepKeys(o).sort();return this.deleteRes(o,m,f,h),JSON.stringify(o)}catch(a){return console.error(a),t}}static idCmp(t,e){const s=t.id,i=e.id;return s<i?-1:s>i?1:0}static findDeletedIds(t,e){return this.findDeletedItems(e,t).map(s=>s.id)}static findDeletedItems(t,e){const s=[];return t.forEach(i=>{e.some(r=>r.id===i.id)||s.push(i)}),s}static getStepKeys(t){return Object.keys(t).map(e=>parseInt(e.replace("step_",""),10)).filter(e=>!isNaN(e))}static deleteRes(t,e,s,i){i.forEach(n=>{if(n>e){const r=t[`step_${n}`];if([ToolType.EToolName.FolderTag,ToolType.EToolName.Segmentation].includes(r.tool))return;if(r.dataSourceStep===e){const a=[];r.result=r.result.filter(u=>s.includes(u.sourceID)?(a.push(u.id),!1):!0),this.deleteRes(t,n,a,i)}else r.result=r.result.filter(a=>!s.includes(a.sourceID))}})}}module.exports=AnnotationDataUtils;
1
+ "use strict";var lbAnnotation=require("@labelbee/lb-annotation"),index=require("./index.js"),ToolType=require("../data/enums/ToolType.js"),_=require("lodash"),StepUtils=require("./StepUtils.js"),antd=require("antd"),lbUtils=require("@labelbee/lb-utils");function _interopDefaultLegacy(c){return c&&typeof c=="object"&&"default"in c?c:{default:c}}var ___default=_interopDefaultLegacy(_);class AnnotationDataUtils{static traverseDF(t,e,s,i){e(t,s,i),typeof t=="object"&&t!==null&&(Array.isArray(t)?t.forEach((a,r)=>{this.traverseDF(a,e,r,t)}):Object.keys(t).forEach(a=>{this.traverseDF(t[a],e,a,t)}))}static getNextPath(t){var e,s,i;const{prePath:a,preMappingImgList:r,nextMappingImgList:n}=t,l=(s=(e=r==null?void 0:r.find(u=>u.path===a))==null?void 0:e.calib)==null?void 0:s.calName,o=(i=n.find(u=>{var d;return((d=u.calib)==null?void 0:d.calName)===l}))==null?void 0:i.path;if(!o)throw Error("nextPath error");return o}static copyResultItemHandler(t){const{item:e,key:s,parent:i,mappingImgList:a,preMappingImgList:r}=t;s==="id"&&(i.id=lbAnnotation.uuid(8,62)),s==="imageName"&&(i.imageName=this.getNextPath({prePath:e,preMappingImgList:r,nextMappingImgList:a}))}static copyResultChange(t){const{copyResult:e,step:s,currentResult:i,mappingImgList:a,preMappingImgList:r}=t;try{const n=index.jsonParser(e),l=index.jsonParser(i),o=`step_${s}`;if(n[o]){const u=n[o];return["result","resultRect"].forEach(p=>{u[p]&&this.traverseDF(u[p],(f,m,h)=>{this.copyResultItemHandler({item:f,key:m,parent:h,mappingImgList:a,preMappingImgList:r})})}),l[o]=u,JSON.stringify(l)}return e}catch(n){antd.message.info(lbUtils.i18n.t("FailedToCopyResults"))}}static isResultSourceMatchedDependence(t,e){const s=t==null?void 0:t.map(a=>a.sourceID).sort(),i=e==null?void 0:e.map(a=>a.id).sort();return ___default.default.isEqual(s,i)}static deltaUpdateBasicResultList(t,e){const s=t==null?void 0:t.map(i=>i.sourceID).sort();return e.filter(i=>!s.includes(i.id))}static getInitialResultList(t,e,s,i,a){const r=t!=null?t:[];switch(s.tool){case ToolType.EToolName.Tag:case ToolType.EToolName.Text:{if(s.dataSourceStep>0){const n=this.deltaUpdateBasicResultList(r,i);if(n.length>0)return r.concat(e.getInitResultList(s.dataSourceStep,n))}return a!==!0?r:e.getInitResultList(s.dataSourceStep,i)}default:return r}}static dataCorrection(t,e,s,i){var a,r;try{const l=`step_${StepUtils.getStepInfo(s,i).step}`,o=index.jsonParser(t),u=index.jsonParser(e),d=(a=o[l])==null?void 0:a.result,p=(r=u[l])==null?void 0:r.result;if(!p||___default.default.isEqual(d.sort(this.idCmp),p.sort(this.idCmp)))return t;const f=this.findDeletedIds(d,p);if(f.length===0)return t;const m=s,h=this.getStepKeys(o).sort();return this.deleteRes(o,m,f,h),JSON.stringify(o)}catch(n){return console.error(n),t}}static idCmp(t,e){const s=t.id,i=e.id;return s<i?-1:s>i?1:0}static findDeletedIds(t,e){return this.findDeletedItems(e,t).map(s=>s.id)}static findDeletedItems(t,e){const s=[];return t.forEach(i=>{e.some(r=>r.id===i.id)||s.push(i)}),s}static getStepKeys(t){return Object.keys(t).map(e=>parseInt(e.replace("step_",""),10)).filter(e=>!isNaN(e))}static deleteRes(t,e,s,i){i.forEach(a=>{if(a>e){const r=t[`step_${a}`];if([ToolType.EToolName.FolderTag,ToolType.EToolName.Segmentation].includes(r.tool))return;if(r.dataSourceStep===e){const n=[];r.result=r.result.filter(l=>s.includes(l.sourceID)?(n.push(l.id),!1):!0),this.deleteRes(t,a,n,i)}else r.result=r.result.filter(n=>!s.includes(n.sourceID))}})}}module.exports=AnnotationDataUtils;
@@ -1 +1 @@
1
- import{uuid as D}from"@labelbee/lb-annotation";import{jsonParser as f}from"./index.js";import{EToolName as m}from"../data/enums/ToolType.js";import I from"lodash";import S from"./StepUtils.js";class y{static traverseDF(t,e,s,i){e(t,s,i),typeof t=="object"&&t!==null&&(Array.isArray(t)?t.forEach((n,r)=>{this.traverseDF(n,e,r,t)}):Object.keys(t).forEach(n=>{this.traverseDF(t[n],e,n,t)}))}static getNextPath(t){var e,s,i;const{prePath:n,preMappingImgList:r,nextMappingImgList:a}=t,c=(s=(e=r==null?void 0:r.find(l=>l.path===n))==null?void 0:e.calib)==null?void 0:s.calName,o=(i=a.find(l=>{var u;return((u=l.calib)==null?void 0:u.calName)===c}))==null?void 0:i.path;return o!=null?o:""}static copyResultItemHandler(t){const{item:e,key:s,parent:i,mappingImgList:n,preMappingImgList:r}=t;s==="id"&&(i.id=D(8,62)),s==="imageName"&&(i.imageName=this.getNextPath({prePath:e,preMappingImgList:r,nextMappingImgList:n}))}static copyResultChange(t){const{copyResult:e,step:s,currentResult:i,mappingImgList:n,preMappingImgList:r}=t;try{const a=f(e),c=f(i),o=`step_${s}`;if(a[o]){const l=a[o];return["result","resultRect"].forEach(d=>{l[d]&&this.traverseDF(l[d],(p,h,g)=>{this.copyResultItemHandler({item:p,key:h,parent:g,mappingImgList:n,preMappingImgList:r})})}),c[o]=l,JSON.stringify(c)}return e}catch(a){return e}}static isResultSourceMatchedDependence(t,e){const s=t==null?void 0:t.map(n=>n.sourceID).sort(),i=e==null?void 0:e.map(n=>n.id).sort();return I.isEqual(s,i)}static deltaUpdateBasicResultList(t,e){const s=t==null?void 0:t.map(i=>i.sourceID).sort();return e.filter(i=>!s.includes(i.id))}static getInitialResultList(t,e,s,i,n){const r=t!=null?t:[];switch(s.tool){case m.Tag:case m.Text:{if(s.dataSourceStep>0){const a=this.deltaUpdateBasicResultList(r,i);if(a.length>0)return r.concat(e.getInitResultList(s.dataSourceStep,a))}return n!==!0?r:e.getInitResultList(s.dataSourceStep,i)}default:return r}}static dataCorrection(t,e,s,i){var n,r;try{const c=`step_${S.getStepInfo(s,i).step}`,o=f(t),l=f(e),u=(n=o[c])==null?void 0:n.result,d=(r=l[c])==null?void 0:r.result;if(!d||I.isEqual(u.sort(this.idCmp),d.sort(this.idCmp)))return t;const p=this.findDeletedIds(u,d);if(p.length===0)return t;const h=s,g=this.getStepKeys(o).sort();return this.deleteRes(o,h,p,g),JSON.stringify(o)}catch(a){return console.error(a),t}}static idCmp(t,e){const s=t.id,i=e.id;return s<i?-1:s>i?1:0}static findDeletedIds(t,e){return this.findDeletedItems(e,t).map(s=>s.id)}static findDeletedItems(t,e){const s=[];return t.forEach(i=>{e.some(r=>r.id===i.id)||s.push(i)}),s}static getStepKeys(t){return Object.keys(t).map(e=>parseInt(e.replace("step_",""),10)).filter(e=>!isNaN(e))}static deleteRes(t,e,s,i){i.forEach(n=>{if(n>e){const r=t[`step_${n}`];if([m.FolderTag,m.Segmentation].includes(r.tool))return;if(r.dataSourceStep===e){const a=[];r.result=r.result.filter(c=>s.includes(c.sourceID)?(a.push(c.id),!1):!0),this.deleteRes(t,n,a,i)}else r.result=r.result.filter(a=>!s.includes(a.sourceID))}})}}export{y as default};
1
+ import{uuid as D}from"@labelbee/lb-annotation";import{jsonParser as f}from"./index.js";import{EToolName as m}from"../data/enums/ToolType.js";import I from"lodash";import S from"./StepUtils.js";import{message as y}from"antd";import{i18n as v}from"@labelbee/lb-utils";class R{static traverseDF(t,e,s,i){e(t,s,i),typeof t=="object"&&t!==null&&(Array.isArray(t)?t.forEach((n,r)=>{this.traverseDF(n,e,r,t)}):Object.keys(t).forEach(n=>{this.traverseDF(t[n],e,n,t)}))}static getNextPath(t){var e,s,i;const{prePath:n,preMappingImgList:r,nextMappingImgList:a}=t,l=(s=(e=r==null?void 0:r.find(c=>c.path===n))==null?void 0:e.calib)==null?void 0:s.calName,o=(i=a.find(c=>{var u;return((u=c.calib)==null?void 0:u.calName)===l}))==null?void 0:i.path;if(!o)throw Error("nextPath error");return o}static copyResultItemHandler(t){const{item:e,key:s,parent:i,mappingImgList:n,preMappingImgList:r}=t;s==="id"&&(i.id=D(8,62)),s==="imageName"&&(i.imageName=this.getNextPath({prePath:e,preMappingImgList:r,nextMappingImgList:n}))}static copyResultChange(t){const{copyResult:e,step:s,currentResult:i,mappingImgList:n,preMappingImgList:r}=t;try{const a=f(e),l=f(i),o=`step_${s}`;if(a[o]){const c=a[o];return["result","resultRect"].forEach(d=>{c[d]&&this.traverseDF(c[d],(p,h,g)=>{this.copyResultItemHandler({item:p,key:h,parent:g,mappingImgList:n,preMappingImgList:r})})}),l[o]=c,JSON.stringify(l)}return e}catch(a){y.info(v.t("FailedToCopyResults"))}}static isResultSourceMatchedDependence(t,e){const s=t==null?void 0:t.map(n=>n.sourceID).sort(),i=e==null?void 0:e.map(n=>n.id).sort();return I.isEqual(s,i)}static deltaUpdateBasicResultList(t,e){const s=t==null?void 0:t.map(i=>i.sourceID).sort();return e.filter(i=>!s.includes(i.id))}static getInitialResultList(t,e,s,i,n){const r=t!=null?t:[];switch(s.tool){case m.Tag:case m.Text:{if(s.dataSourceStep>0){const a=this.deltaUpdateBasicResultList(r,i);if(a.length>0)return r.concat(e.getInitResultList(s.dataSourceStep,a))}return n!==!0?r:e.getInitResultList(s.dataSourceStep,i)}default:return r}}static dataCorrection(t,e,s,i){var n,r;try{const l=`step_${S.getStepInfo(s,i).step}`,o=f(t),c=f(e),u=(n=o[l])==null?void 0:n.result,d=(r=c[l])==null?void 0:r.result;if(!d||I.isEqual(u.sort(this.idCmp),d.sort(this.idCmp)))return t;const p=this.findDeletedIds(u,d);if(p.length===0)return t;const h=s,g=this.getStepKeys(o).sort();return this.deleteRes(o,h,p,g),JSON.stringify(o)}catch(a){return console.error(a),t}}static idCmp(t,e){const s=t.id,i=e.id;return s<i?-1:s>i?1:0}static findDeletedIds(t,e){return this.findDeletedItems(e,t).map(s=>s.id)}static findDeletedItems(t,e){const s=[];return t.forEach(i=>{e.some(r=>r.id===i.id)||s.push(i)}),s}static getStepKeys(t){return Object.keys(t).map(e=>parseInt(e.replace("step_",""),10)).filter(e=>!isNaN(e))}static deleteRes(t,e,s,i){i.forEach(n=>{if(n>e){const r=t[`step_${n}`];if([m.FolderTag,m.Segmentation].includes(r.tool))return;if(r.dataSourceStep===e){const a=[];r.result=r.result.filter(l=>s.includes(l.sourceID)?(a.push(l.id),!1):!0),this.deleteRes(t,n,a,i)}else r.result=r.result.filter(a=>!s.includes(a.sourceID))}})}}export{R as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labelbee/lb-components",
3
- "version": "1.23.0-alpha.31",
3
+ "version": "1.23.0-alpha.33",
4
4
  "description": "Provide a complete library of annotation components",
5
5
  "main": "./dist/index.js",
6
6
  "es": "./es/index.js",
@@ -43,8 +43,8 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@ant-design/icons": "^4.6.2",
46
- "@labelbee/lb-annotation": "1.27.0-alpha.13",
47
- "@labelbee/lb-utils": "1.19.0-alpha.8",
46
+ "@labelbee/lb-annotation": "1.27.0-alpha.15",
47
+ "@labelbee/lb-utils": "1.19.0-alpha.9",
48
48
  "@labelbee/wavesurfer": "1.0.0",
49
49
  "@types/react-dom": "^18.2.7",
50
50
  "@types/react-transition-group": "^4.4.9",