@labelbee/lb-components 1.23.0-alpha.37 → 1.23.0-alpha.38
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.
|
@@ -39,7 +39,7 @@ export default class AnnotationDataUtils {
|
|
|
39
39
|
* @param {IImgList} params.nextMappingImgList - The list of next mapping images.
|
|
40
40
|
* @returns {string} The next path, returns an empty string if not found.
|
|
41
41
|
*/
|
|
42
|
-
static getNextPath(params: IGetNextPath): string;
|
|
42
|
+
static getNextPath(params: IGetNextPath): string | undefined;
|
|
43
43
|
/**
|
|
44
44
|
* Handles the processing of individual items during the traversal of results or resultRect.
|
|
45
45
|
* This function updates specific properties of the parent object based on the key of the current item.
|
|
@@ -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"),antd=require("antd"),lbUtils=require("@labelbee/lb-utils");function _interopDefaultLegacy(
|
|
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(v){return v&&typeof v=="object"&&"default"in v?v:{default:v}}var ___default=_interopDefaultLegacy(_);class AnnotationDataUtils{static traverseDF(t,s,e,i){s(t,e,i),typeof t=="object"&&t!==null&&(Array.isArray(t)?t.forEach((n,r)=>{this.traverseDF(n,s,r,t)}):Object.keys(t).forEach(n=>{this.traverseDF(t[n],s,n,t)}))}static getNextPath(t){var s,e,i;const{prePath:n,preMappingImgList:r,nextMappingImgList:a}=t,o=(e=(s=r==null?void 0:r.find(u=>u.path===n))==null?void 0:s.calib)==null?void 0:e.calName;return(i=a.find(u=>{var f;return((f=u.calib)==null?void 0:f.calName)===o}))==null?void 0:i.path}static copyResultItemHandler(t){const{item:s,key:e,parent:i,mappingImgList:n,preMappingImgList:r}=t,a=e===void 0?void 0:i[e];return e==="id"&&(i.id=lbAnnotation.uuid(8,62)),e==="imageName"&&(i.imageName=this.getNextPath({prePath:s,preMappingImgList:r,nextMappingImgList:n})),{value:e===void 0?void 0:i[e],oldValue:a}}static copyResultChange(t){const{copyResult:s,step:e,currentResult:i,mappingImgList:n,preMappingImgList:r}=t;try{const a=index.jsonParser(s),o=index.jsonParser(i),d=`step_${e}`;if(a[d]){const u=a[d],f=["result","resultRect"],p=new Map,I=(l,c)=>{if(l===void 0||c===void 0){console.warn("invalid id");return}p.set(c,l)};if(f.forEach(l=>{u[l]&&this.traverseDF(u[l],(c,m,h)=>{const{value:R,oldValue:D}=this.copyResultItemHandler({item:c,key:m,parent:h,mappingImgList:n,preMappingImgList:r});l==="result"&&m==="id"&&R!==void 0&&D!==void 0&&p.set(D,R)})}),p.size){const l=u.resultRect;Array.isArray(l)&&l.forEach(c=>{const m=c.extId,h=p.get(m);m!==void 0&&h!==void 0&&(c.extId=h)})}const y=["resultRect","rects"],g=[];return this.traverseDF(u,(l,c,m)=>{___default.default.isString(c)&&y.includes(c)&&Array.isArray(l)&&(m[c]=l.filter(h=>h.imageName?!0:(g.push(h),!1)))}),g.length&&(console.warn(g),antd.message.info(lbUtils.i18n.t("PartialResultsReplicationFailure"))),o[d]=u,JSON.stringify(o)}return s}catch(a){antd.message.info(lbUtils.i18n.t("FailedToCopyResults"))}}static isResultSourceMatchedDependence(t,s){const e=t==null?void 0:t.map(n=>n.sourceID).sort(),i=s==null?void 0:s.map(n=>n.id).sort();return ___default.default.isEqual(e,i)}static deltaUpdateBasicResultList(t,s){const e=t==null?void 0:t.map(i=>i.sourceID).sort();return s.filter(i=>!e.includes(i.id))}static getInitialResultList(t,s,e,i,n){const r=t!=null?t:[];switch(e.tool){case ToolType.EToolName.Tag:case ToolType.EToolName.Text:{if(e.dataSourceStep>0){const a=this.deltaUpdateBasicResultList(r,i);if(a.length>0)return r.concat(s.getInitResultList(e.dataSourceStep,a))}return n!==!0?r:s.getInitResultList(e.dataSourceStep,i)}default:return r}}static dataCorrection(t,s,e,i){var n,r;try{const o=`step_${StepUtils.getStepInfo(e,i).step}`,d=index.jsonParser(t),u=index.jsonParser(s),f=(n=d[o])==null?void 0:n.result,p=(r=u[o])==null?void 0:r.result;if(!p||___default.default.isEqual(f.sort(this.idCmp),p.sort(this.idCmp)))return t;const I=this.findDeletedIds(f,p);if(I.length===0)return t;const y=e,g=this.getStepKeys(d).sort();return this.deleteRes(d,y,I,g),JSON.stringify(d)}catch(a){return console.error(a),t}}static idCmp(t,s){const e=t.id,i=s.id;return e<i?-1:e>i?1:0}static findDeletedIds(t,s){return this.findDeletedItems(s,t).map(e=>e.id)}static findDeletedItems(t,s){const e=[];return t.forEach(i=>{s.some(r=>r.id===i.id)||e.push(i)}),e}static getStepKeys(t){return Object.keys(t).map(s=>parseInt(s.replace("step_",""),10)).filter(s=>!isNaN(s))}static deleteRes(t,s,e,i){i.forEach(n=>{if(n>s){const r=t[`step_${n}`];if([ToolType.EToolName.FolderTag,ToolType.EToolName.Segmentation].includes(r.tool))return;if(r.dataSourceStep===s){const a=[];r.result=r.result.filter(o=>e.includes(o.sourceID)?(a.push(o.id),!1):!0),this.deleteRes(t,n,a,i)}else r.result=r.result.filter(a=>!e.includes(a.sourceID))}})}}module.exports=AnnotationDataUtils;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{uuid as
|
|
1
|
+
import{uuid as E}from"@labelbee/lb-annotation";import{jsonParser as v}from"./index.js";import{EToolName as I}from"../data/enums/ToolType.js";import S from"lodash";import L from"./StepUtils.js";import{message as N}from"antd";import{i18n as F}from"@labelbee/lb-utils";class _{static traverseDF(t,s,e,i){s(t,e,i),typeof t=="object"&&t!==null&&(Array.isArray(t)?t.forEach((n,r)=>{this.traverseDF(n,s,r,t)}):Object.keys(t).forEach(n=>{this.traverseDF(t[n],s,n,t)}))}static getNextPath(t){var s,e,i;const{prePath:n,preMappingImgList:r,nextMappingImgList:a}=t,o=(e=(s=r==null?void 0:r.find(c=>c.path===n))==null?void 0:s.calib)==null?void 0:e.calName;return(i=a.find(c=>{var f;return((f=c.calib)==null?void 0:f.calName)===o}))==null?void 0:i.path}static copyResultItemHandler(t){const{item:s,key:e,parent:i,mappingImgList:n,preMappingImgList:r}=t,a=e===void 0?void 0:i[e];return e==="id"&&(i.id=E(8,62)),e==="imageName"&&(i.imageName=this.getNextPath({prePath:s,preMappingImgList:r,nextMappingImgList:n})),{value:e===void 0?void 0:i[e],oldValue:a}}static copyResultChange(t){const{copyResult:s,step:e,currentResult:i,mappingImgList:n,preMappingImgList:r}=t;try{const a=v(s),o=v(i),d=`step_${e}`;if(a[d]){const c=a[d],f=["result","resultRect"],p=new Map,R=(l,u)=>{if(l===void 0||u===void 0){console.warn("invalid id");return}p.set(u,l)};if(f.forEach(l=>{c[l]&&this.traverseDF(c[l],(u,m,h)=>{const{value:y,oldValue:x}=this.copyResultItemHandler({item:u,key:m,parent:h,mappingImgList:n,preMappingImgList:r});l==="result"&&m==="id"&&y!==void 0&&x!==void 0&&p.set(x,y)})}),p.size){const l=c.resultRect;Array.isArray(l)&&l.forEach(u=>{const m=u.extId,h=p.get(m);m!==void 0&&h!==void 0&&(u.extId=h)})}const D=["resultRect","rects"],g=[];return this.traverseDF(c,(l,u,m)=>{S.isString(u)&&D.includes(u)&&Array.isArray(l)&&(m[u]=l.filter(h=>h.imageName?!0:(g.push(h),!1)))}),g.length&&(console.warn(g),N.info(F.t("PartialResultsReplicationFailure"))),o[d]=c,JSON.stringify(o)}return s}catch(a){N.info(F.t("FailedToCopyResults"))}}static isResultSourceMatchedDependence(t,s){const e=t==null?void 0:t.map(n=>n.sourceID).sort(),i=s==null?void 0:s.map(n=>n.id).sort();return S.isEqual(e,i)}static deltaUpdateBasicResultList(t,s){const e=t==null?void 0:t.map(i=>i.sourceID).sort();return s.filter(i=>!e.includes(i.id))}static getInitialResultList(t,s,e,i,n){const r=t!=null?t:[];switch(e.tool){case I.Tag:case I.Text:{if(e.dataSourceStep>0){const a=this.deltaUpdateBasicResultList(r,i);if(a.length>0)return r.concat(s.getInitResultList(e.dataSourceStep,a))}return n!==!0?r:s.getInitResultList(e.dataSourceStep,i)}default:return r}}static dataCorrection(t,s,e,i){var n,r;try{const o=`step_${L.getStepInfo(e,i).step}`,d=v(t),c=v(s),f=(n=d[o])==null?void 0:n.result,p=(r=c[o])==null?void 0:r.result;if(!p||S.isEqual(f.sort(this.idCmp),p.sort(this.idCmp)))return t;const R=this.findDeletedIds(f,p);if(R.length===0)return t;const D=e,g=this.getStepKeys(d).sort();return this.deleteRes(d,D,R,g),JSON.stringify(d)}catch(a){return console.error(a),t}}static idCmp(t,s){const e=t.id,i=s.id;return e<i?-1:e>i?1:0}static findDeletedIds(t,s){return this.findDeletedItems(s,t).map(e=>e.id)}static findDeletedItems(t,s){const e=[];return t.forEach(i=>{s.some(r=>r.id===i.id)||e.push(i)}),e}static getStepKeys(t){return Object.keys(t).map(s=>parseInt(s.replace("step_",""),10)).filter(s=>!isNaN(s))}static deleteRes(t,s,e,i){i.forEach(n=>{if(n>s){const r=t[`step_${n}`];if([I.FolderTag,I.Segmentation].includes(r.tool))return;if(r.dataSourceStep===s){const a=[];r.result=r.result.filter(o=>e.includes(o.sourceID)?(a.push(o.id),!1):!0),this.deleteRes(t,n,a,i)}else r.result=r.result.filter(a=>!e.includes(a.sourceID))}})}}export{_ as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@labelbee/lb-components",
|
|
3
|
-
"version": "1.23.0-alpha.
|
|
3
|
+
"version": "1.23.0-alpha.38",
|
|
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.
|
|
47
|
-
"@labelbee/lb-utils": "1.19.0-alpha.
|
|
46
|
+
"@labelbee/lb-annotation": "1.27.0-alpha.18",
|
|
47
|
+
"@labelbee/lb-utils": "1.19.0-alpha.12",
|
|
48
48
|
"@labelbee/wavesurfer": "1.0.0",
|
|
49
49
|
"@types/react-dom": "^18.2.7",
|
|
50
50
|
"@types/react-transition-group": "^4.4.9",
|