@labelbee/lb-components 1.23.0-alpha.21 → 1.23.0-alpha.23

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.
Files changed (33) hide show
  1. package/dist/components/audioAnnotate/audioContext/index.js +1 -1
  2. package/dist/components/audioAnnotate/audioSide/clipSidebar/index.js +1 -1
  3. package/dist/components/audioAnnotate/index.js +1 -1
  4. package/dist/components/audioAnnotate/textInput/index.js +1 -1
  5. package/dist/components/audioPlayer/clipRegion/index.js +1 -1
  6. package/dist/components/audioPlayer/index.js +1 -1
  7. package/dist/components/pointCloud2DRectOperationView/index.js +1 -1
  8. package/dist/components/pointCloudView/PointCloud3DView.js +1 -1
  9. package/dist/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
  10. package/dist/store/annotation/reducer.js +1 -1
  11. package/dist/types/components/audioAnnotate/audioContext/index.d.ts +9 -1
  12. package/dist/types/components/audioAnnotate/textInput/index.d.ts +1 -0
  13. package/dist/types/components/audioPlayer/index.d.ts +3 -2
  14. package/dist/types/components/pointCloudView/hooks/usePointCloudViews.d.ts +5 -0
  15. package/dist/types/components/videoAnnotate/index.d.ts +1 -1
  16. package/dist/types/utils/AnnotationDataUtils.d.ts +54 -1
  17. package/dist/types/views/MainView/sidebar/TextToolSidebar/index.d.ts +1 -1
  18. package/dist/types/views/MainView/toolFooter/index.d.ts +1 -1
  19. package/dist/types/views/MainView/toolHeader/StepSwitch/index.d.ts +1 -1
  20. package/dist/types/views/MainView/toolHeader/index.d.ts +1 -1
  21. package/dist/utils/AnnotationDataUtils.js +1 -1
  22. package/es/components/audioAnnotate/audioContext/index.js +1 -1
  23. package/es/components/audioAnnotate/audioSide/clipSidebar/index.js +1 -1
  24. package/es/components/audioAnnotate/index.js +1 -1
  25. package/es/components/audioAnnotate/textInput/index.js +1 -1
  26. package/es/components/audioPlayer/clipRegion/index.js +1 -1
  27. package/es/components/audioPlayer/index.js +1 -1
  28. package/es/components/pointCloud2DRectOperationView/index.js +1 -1
  29. package/es/components/pointCloudView/PointCloud3DView.js +1 -1
  30. package/es/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
  31. package/es/store/annotation/reducer.js +1 -1
  32. package/es/utils/AnnotationDataUtils.js +1 -1
  33. package/package.json +3 -3
@@ -1 +1 @@
1
- import{getFormatSize as St}from"../../components/customResizeHook/index.js";import{ESubmitType as K}from"../../constant/index.js";import Dt from"../../constant/styleString.js";import{ANNOTATION_ACTIONS as i}from"../Actions.js";import{jsonParser as x}from"../../utils/index.js";import X from"../../utils/AnnotationDataUtils.js";import{ConfigUtils as vt}from"../../utils/ConfigUtils.js";import{composeResultWithBasicImgInfo as ut,composeResult as Y}from"../../utils/data.js";import O from"../../utils/StepUtils.js";import J from"../../utils/ToolUtils.js";import{MathUtils as at,CommonToolUtils as yt,AnnotationEngine as Pt,ImgUtils as Rt}from"@labelbee/lb-annotation";import{PointCloudUtils as ct,i18n as G}from"@labelbee/lb-utils";import{Modal as dt}from"antd";import{message as pt}from"antd/es";import _t from"lodash";import{SetAnnotationLoading as $}from"./actionCreators.js";import{EToolName as W}from"../../data/enums/ToolType.js";var Ct=Object.defineProperty,Ot=Object.defineProperties,ht=Object.getOwnPropertyDescriptors,gt=Object.getOwnPropertySymbols,bt=Object.prototype.hasOwnProperty,Nt=Object.prototype.propertyIsEnumerable,It=(t,e,r)=>e in t?Ct(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,o=(t,e)=>{for(var r in e||(e={}))bt.call(e,r)&&It(t,r,e[r]);if(gt)for(var r of gt(e))Nt.call(e,r)&&It(t,r,e[r]);return t},l=(t,e)=>Ot(t,ht(e)),mt=(t,e,r)=>new Promise((A,d)=>{var S=m=>{try{T(r.next(m))}catch(y){d(y)}},f=m=>{try{T(r.throw(m))}catch(y){d(y)}},T=m=>m.done?A(m.value):Promise.resolve(m.value).then(S,f);T((r=r.apply(t,e)).next())});const w=(t,e)=>t.find(r=>r.step===e),ft={annotationEngine:null,toolInstance:null,imgList:[],config:"{}",imgIndex:-1,basicIndex:0,imgPageSize:1,step:1,stepList:[],imgNode:new Image,basicResultList:[],resultList:[],stepProgress:0,loading:!1,loadPCDFileLoading:!0,triggerEventAfterIndexChanged:!1,pointCloudLoading:!1,checkMode:!1,predictionResult:[],predictionResultVisible:!1,highlightAttribute:""},Ut=t=>{const{imgList:e,imgPageSize:r}=t;return Math.ceil(e.length/r)},Tt=(t,e)=>t.reduce((r,A)=>{if(A){const d=A.result;if(x(d)[`step_${e}`])return r+1}return r},0)/t.length,Bt=(t,e)=>{const{step:r,stepList:A}=t,d=O.getCurrentStepInfo(r,A),S=vt.jsonParser(d.config);if(J.isVideoTool(d==null?void 0:d.tool)||J.isAudioTool(d==null?void 0:d.tool)||J.isPointCloudTool(d==null?void 0:d.tool)||[W.LLM,W.NLP].includes(d==null?void 0:d.tool))return;const f=document.getElementById("toolContainer");if(!f)throw"Not exist dom named id-toolContainer";const T=St({width:window.innerWidth,height:window.innerHeight}),m=new Pt({container:f,toolName:d.tool,size:T,imgNode:e,config:S,style:JSON.parse(Dt)});return{toolInstance:m==null?void 0:m.toolInstance,annotationEngine:m}},xt=(t,e)=>(r,A)=>mt(void 0,null,function*(){var d,S;const{stepList:f,step:T}=A().annotation,m=O.currentToolIsVideo(T,f),y=O.currentToolIsPointCloud(T,f),h=((d=O.getCurrentStepInfo(T,f))==null?void 0:d.tool)===W.LLM,b=((S=O.getCurrentStepInfo(T,f))==null?void 0:S.tool)===W.NLP,N=O.currentToolIsAudio(T,f);if($(r,!0),yield r(wt(t)),m){r(Ft(t));return}if(y||h||N||b){r(jt(t));return}r(Gt(t,e))}),wt=t=>(e,r)=>mt(void 0,null,function*(){const{getFileData:A,imgList:d}=r().annotation;if(A){const S=yield A(d[t],t);e({type:i.SET_FILE_DATA,payload:{fileData:S,index:t}})}}),Ft=t=>e=>{e({type:i.LOAD_FILE_DATA,payload:{nextIndex:t}})},jt=t=>e=>{$(e,!1),e({type:i.LOAD_FILE_DATA,payload:{nextIndex:t}})},Gt=(t,e)=>(r,A)=>{var d;const{toolInstance:S,imgList:f}=A().annotation,T=(d=f==null?void 0:f[t])==null?void 0:d.url;Rt.load(T).then(m=>{$(r,!1),r({type:i.LOAD_FILE_DATA,payload:{imgNode:m,nextIndex:t,nextBasicIndex:e}})}).catch(()=>{$(r,!1),S==null||S.setErrorImg(),r({type:i.LOAD_FILE_DATA,payload:{nextIndex:t,nextBasicIndex:e}})})},Vt=({toolInstance:t,imgList:e,imgIndex:r,stepList:A,step:d=1})=>{var S,f,T,m;const y=((S=e[r])==null?void 0:S.result)||"",[h,b,N]=(f=t==null?void 0:t.exportData())!=null?f:[],V=(m=(T=t==null?void 0:t.exportCustomData)==null?void 0:T.call(t))!=null?m:{},M=ut(y,b),k=Y(M,{step:d,stepList:A},{rect:h},V);return e.map((F,H)=>H===r?o(l(o({},F),{result:k}),N):o({},F))},Mt=(t=o({},ft),e)=>{var r,A,d,S,f,T,m,y,h,b,N,V,M,k,F,H,q,Z,Q,tt,et,nt,ot,st,lt;switch(e.type){case i.INIT_ALL_STATE:return o(o({},t),ft);case i.UPDATE_TOOL_INSTANCE:return l(o({},t),{toolInstance:e.payload.toolInstance});case i.UPDATE_IMG_LIST:return l(o({},t),{imgList:e.payload.imgList});case i.CALC_STEP_PROGRESS:{const{imgList:n,step:s}=t,u=Tt(n,s);return l(o({},t),{stepProgress:u})}case i.SUBMIT_FILE_DATA:{const{imgList:n,imgIndex:s,step:u,stepList:a,toolInstance:p,onSubmit:c,resultList:L}=t;if(!p||!n[s])return t;const g=((r=n[s])==null?void 0:r.result)||"",[,_,I]=(A=p==null?void 0:p.exportData())!=null?A:[],E=(S=(d=p==null?void 0:p.exportCustomData)==null?void 0:d.call(p))!=null?S:{},D=ut(g,_),P=Y(D,{step:u,stepList:a},{rect:L},E),v=t.imgList.map((C,R)=>{if(R===s){const j=X.dataCorrection(P,g,u,a);return o(l(o({},C),{result:j}),I)}return C});if(((f=e.payload)==null?void 0:f.submitType)===K.SyncImgList)return l(o({},t),{imgList:v});c&&c([v[s]],(T=e.payload)==null?void 0:T.submitType,s,v);const U=Tt(v,u);return l(o({},t),{stepProgress:U,imgList:v})}case i.SAVE_RESULT:{const{imgList:n,imgIndex:s,onSave:u}=t;return u==null||u(n[s],s,n),o({},t)}case i.SUBMIT_RESULT:{const{imgList:n,basicIndex:s,resultList:u,toolInstance:a,basicResultList:p}=t;if(!a)return t;const[c]=(m=a==null?void 0:a.exportData())!=null?m:[];let L=c;if((p==null?void 0:p.length)>0){const g=(y=p[s])==null?void 0:y.id,_=c.map(I=>l(o({},I),{sourceID:g}));L=_t.cloneDeep(u).filter(I=>I.sourceID!==g),L.push(..._)}return l(o({},t),{resultList:L,imgList:n})}case i.SET_BASIC_INDEX:{const{toolInstance:n,step:s,imgList:u,imgIndex:a,stepList:p,annotationEngine:c,resultList:L,basicResultList:g}=t;if(!n||!c)return t;const _=e.payload.basicIndex,I=(h=g[_])==null?void 0:h.id,E=x((b=u[a])==null?void 0:b.result),D=(L||[]).filter(j=>j.sourceID===I),P=w(p,s),{dataSourceStep:v,tool:U}=P,C=w(p,v);let R=[];return v&&U&&(R=(N=E[`step_${v}`])==null?void 0:N.result,(R==null?void 0:R.length)>0?(c==null||c.setBasicInfo(C.tool,R[_]),c==null||c.launchOperation()):(c==null||c.setBasicInfo(C.tool),c==null||c.forbidOperation(),pt.info(G.t("NoDependency")))),n==null||n.setResult(D),n==null||n.history.initRecord(D,!0),l(o({},t),{basicIndex:_})}case i.SET_TRIGGER_EVENT_AFTER_INDEX_CHANGED:{const{triggerEventAfterIndexChanged:n}=e.payload;return l(o({},t),{triggerEventAfterIndexChanged:!!n})}case i.LOAD_FILE_DATA:{const{imgList:n,step:s,toolInstance:u,annotationEngine:a,stepList:p}=t;if(!u)return l(o({},t),{imgIndex:e.payload.nextIndex});const c=O.getCurrentStepInfo(s,p),{nextIndex:L,imgNode:g,nextBasicIndex:_,imgError:I}=e.payload,E=_!=null?_:0,D=x((V=n[L])==null?void 0:V.result),P=D[`step_${c.step}`],v=!P,U={rotate:(M=D.rotate)!=null?M:0,valid:(k=D.valid)!=null?k:!0};g&&I!==!0?a==null||a.setImgNode(g,U):u==null||u.setValid(U.valid);const C=w(p,c.step),{dataSourceStep:R,tool:j}=C,it=w(p,R),rt=R&&j,B=(H=(F=D[`step_${R}`])==null?void 0:F.result)!=null?H:[],z=X.getInitialResultList(P==null?void 0:P.result,u,C,B,v);if(a==null||a.launchOperation(),rt&&((B==null?void 0:B.length)>0?a==null||a.setBasicInfo(it.tool,B[E]):(a==null||a.setBasicInfo(it.tool),a==null||a.forbidOperation(),pt.info(G.t("NoDependency")))),c.tool!=="check"){const Lt=(Z=(q=B[E])==null?void 0:q.id)!=null?Z:"",Et=rt?z.filter(At=>yt.isSameSourceID(At.sourceID,Lt)):z;(Q=u==null?void 0:u.history)==null||Q.initRecord(z,!0),u==null||u.setResult(Et)}return l(o({},t),{imgIndex:L,basicIndex:E,basicResultList:B,resultList:z})}case i.UPDATE_ANNOTATION_CONFIG:return l(o({},t),{config:(tt=e.payload.config)!=null?tt:"{}"});case i.SET_TASK_STEP_LIST:{const{stepList:n}=e.payload;return l(o({},t),{stepList:n})}case i.SET_TASK_CONFIG:{const{stepList:n,step:s}=e.payload;return l(o({},t),{stepList:n,step:s})}case i.INIT_TOOL:{const{imgNode:n}=t,s=Bt(t,n);if(s){const{toolInstance:u,annotationEngine:a}=s;return l(o({},t),{toolInstance:u,annotationEngine:a})}return o({},t)}case i.SET_TOOL:{const n=(et=e.payload)==null?void 0:et.instance;return n?l(o({},t),{toolInstance:n}):o({},t)}case i.UPDATE_ON_SUBMIT:return l(o({},t),{onSubmit:e.payload.onSubmit});case i.UPDATE_ON_SAVE:return l(o({},t),{onSave:e.payload.onSave});case i.UPDATE_ON_PAGE_CHANGE:return l(o({},t),{onPageChange:e.payload.onPageChange});case i.SET_PREDICT_RESULT:return l(o({},t),{predictionResult:e.payload.result});case i.SET_PREDICT_RESULT_VISIBLE:return l(o({},t),{predictionResultVisible:e.payload.visible});case i.UPDATE_ON_STEP_CHANGE:return l(o({},t),{onStepChange:e.payload.onStepChange});case i.UPDATE_GET_FILE_DATA:return l(o({},t),{getFileData:e.payload.getFileData});case i.UPDATE_PAGE_SIZE:return l(o({},t),{pageSize:e.payload.pageSize});case i.UPDATE_LOAD_FILE_LIST:return l(o({},t),{loadFileList:e.payload.loadFileList});case i.UPDATE_BEFORE_ROTATE:return l(o({},t),{beforeRotate:e.payload.beforeRotate});case i.UPDATE_PRE_DATA_PROCESS:return l(o({},t),{preDataProcess:e.payload.preDataProcess});case i.UPDATE_IMG_INDEX_BY_EXTERNAL:return l(o({},t),{getImgIndexByExternal:e.payload.getImgIndexByExternal});case i.SKIP_BEFORE_PAGE_TURNING:return l(o({},t),{skipBeforePageTurning:e.payload.skipBeforePageTurning});case i.SET_FILE_DATA:{const{fileData:n,index:s}=e.payload,{imgList:u}=t,a=[...u];return a[s]=o(o({},a[s]),n),l(o({},t),{imgList:a})}case i.UPDATE_ROTATE:{const{toolInstance:n,beforeRotate:s}=t;return s&&s()===!1||(nt=n==null?void 0:n.updateRotate)==null||nt.call(n),t}case i.UPDATE_ANNOTATION_VALID:{const{toolInstance:n}=t,s=(ot=n==null?void 0:n.valid)!=null?ot:!0;return dt.destroyAll(),dt.confirm({content:G.t(s?"updateValidFromValidToInValid":"updateValidFromInValidToValid"),onOk:()=>{n==null||n.setValid(!s)},okText:G.t("Confirm"),cancelText:G.t("Cancel")}),t}case i.COPY_BACKWARD_RESULT:{const{toolInstance:n,imgIndex:s,imgList:u,step:a}=t;if(!n)return t;if(s===0||s>=u.length)return console.error("\u65E0\u6CD5\u590D\u5236\u8FB9\u754C\u5916\u7684\u5185\u5BB9"),t;const p=u[s-1].result;if(!p)return t;const c=X.copyResultChange(p,a,(st=u[s].result)!=null?st:"");u[s]=l(o({},u[s]),{result:c});const g=x(c)[`step_${a}`],_=(g==null?void 0:g.result)||[];return n==null||n.setResult(_),n==null||n.history.pushHistory(_),(lt=n==null?void 0:n.asyncData)==null||lt.call(n,u[s]),l(o({},t),{imgList:[...u]})}case i.SET_STEP:{const{stepList:n,annotationEngine:s}=t,{toStep:u}=e.payload;if(s){const a=w(n,u);return s==null||s.setToolName(a.tool,a.config),l(o({},t),{step:u,toolInstance:s==null?void 0:s.toolInstance})}return l(o({},t),{step:u})}case i.SET_LOADPCDFILE_LOADING:{const{loadPCDFileLoading:n}=e.payload;return l(o({},t),{loadPCDFileLoading:!!n})}case i.SET_LOADING:{const{loading:n}=e.payload;return l(o({},t),{loading:!!n})}case i.SET_POINT_CLOUD_LOADING:{const{pointCloudLoading:n}=e.payload;return l(o({},t),{pointCloudLoading:!!n})}case i.SET_CHECK_MODE:{const{checkMode:n}=e.payload;return l(o({},t),{checkMode:!!n})}case i.SET_HIGHLIGHT_ATTRIBUTE:{const{attribute:n}=e.payload;return l(o({},t),{highlightAttribute:n})}case i.BATCH_UPDATE_TRACK_ID:{const{id:n,newID:s,rangeIndex:u,imgList:a}=e.payload,{imgIndex:p,onSubmit:c}=t,L=[],g=a.map((_,I)=>{if(at.isInRange(I,u)){const E=l(o({},_),{result:ct.batchUpdateTrackID({id:n,newID:s,result:_.result})});return L.push({imgIndex:I,newInfo:E}),E}return _});return c&&c([g[p]],K.BatchUpdateTrackID,p,g,{updateImgList:L}),l(o({},t),{imgList:g})}case i.BATCH_UPDATE_RESULT_BY_TRACK_ID:{const{id:n,newData:s,rangeIndex:u}=e.payload,{imgList:a,imgIndex:p,onSubmit:c}=t,L=[],g=a.map((_,I)=>{if(at.isInRange(I,u)){const E=l(o({},_),{result:ct.batchUpdateResultByTrackID({id:n,newData:s,result:_.result})});return L.push({imgIndex:I,newInfo:E}),E}return _});return c&&c([g[p]],K.BatchUpdateTrackID,p,g,{updateImgList:L}),l(o({},t),{imgList:g})}case i.BATCH_UPDATE_IMG_LIST_RESULT_BY_PREDICT_RESULT:{const{onSubmit:n,imgList:s,stepList:u,step:a,predictionResult:p}=t,c={};p.forEach(I=>{const{index:E}=I;c[E]=_t.pick(I,["center","width","height","depth","rotation","id","attribute","valid","trackID"])});const L=`step_${a}`,g=[],_=s.map((I,E)=>{if(c[E]){const D=I.result==="{}"?x(Y("",{step:a,stepList:u},{rect:[]},{})):x(I.result);D[L].result.push(c[E]);const P=l(o({},I),{result:JSON.stringify(D)});return g.push({imgIndex:E,newInfo:P}),P}return I});return n==null||n(_,K.BatchUpdateImgList,-1,_,{updateImgList:g}),l(o({},t),{imgList:_})}default:return t}};export{xt as LoadFileAndFileData,Mt as annotationReducer,Vt as composeResultByToolInstance,w as getStepConfig,Ut as getTotalPage};
1
+ import{getFormatSize as vt}from"../../components/customResizeHook/index.js";import{ESubmitType as K}from"../../constant/index.js";import yt from"../../constant/styleString.js";import{ANNOTATION_ACTIONS as i}from"../Actions.js";import{jsonParser as x}from"../../utils/index.js";import X from"../../utils/AnnotationDataUtils.js";import{ConfigUtils as Rt}from"../../utils/ConfigUtils.js";import{composeResultWithBasicImgInfo as ct,composeResult as Y}from"../../utils/data.js";import O from"../../utils/StepUtils.js";import J from"../../utils/ToolUtils.js";import{MathUtils as dt,CommonToolUtils as Pt,AnnotationEngine as Ct,ImgUtils as Ot}from"@labelbee/lb-annotation";import{PointCloudUtils as pt,i18n as G}from"@labelbee/lb-utils";import{Modal as gt}from"antd";import{message as _t}from"antd/es";import It from"lodash";import{SetAnnotationLoading as $}from"./actionCreators.js";import{EToolName as W}from"../../data/enums/ToolType.js";var ht=Object.defineProperty,bt=Object.defineProperties,Nt=Object.getOwnPropertyDescriptors,mt=Object.getOwnPropertySymbols,Ut=Object.prototype.hasOwnProperty,Bt=Object.prototype.propertyIsEnumerable,ft=(t,e,u)=>e in t?ht(t,e,{enumerable:!0,configurable:!0,writable:!0,value:u}):t[e]=u,o=(t,e)=>{for(var u in e||(e={}))Ut.call(e,u)&&ft(t,u,e[u]);if(mt)for(var u of mt(e))Bt.call(e,u)&&ft(t,u,e[u]);return t},l=(t,e)=>bt(t,Nt(e)),Tt=(t,e,u)=>new Promise((A,d)=>{var S=m=>{try{T(u.next(m))}catch(y){d(y)}},f=m=>{try{T(u.throw(m))}catch(y){d(y)}},T=m=>m.done?A(m.value):Promise.resolve(m.value).then(S,f);T((u=u.apply(t,e)).next())});const w=(t,e)=>t.find(u=>u.step===e),Lt={annotationEngine:null,toolInstance:null,imgList:[],config:"{}",imgIndex:-1,basicIndex:0,imgPageSize:1,step:1,stepList:[],imgNode:new Image,basicResultList:[],resultList:[],stepProgress:0,loading:!1,loadPCDFileLoading:!0,triggerEventAfterIndexChanged:!1,pointCloudLoading:!1,checkMode:!1,predictionResult:[],predictionResultVisible:!1,highlightAttribute:""},xt=t=>{const{imgList:e,imgPageSize:u}=t;return Math.ceil(e.length/u)},Et=(t,e)=>t.reduce((u,A)=>{if(A){const d=A.result;if(x(d)[`step_${e}`])return u+1}return u},0)/t.length,wt=(t,e)=>{const{step:u,stepList:A}=t,d=O.getCurrentStepInfo(u,A),S=Rt.jsonParser(d.config);if(J.isVideoTool(d==null?void 0:d.tool)||J.isAudioTool(d==null?void 0:d.tool)||J.isPointCloudTool(d==null?void 0:d.tool)||[W.LLM,W.NLP].includes(d==null?void 0:d.tool))return;const f=document.getElementById("toolContainer");if(!f)throw"Not exist dom named id-toolContainer";const T=vt({width:window.innerWidth,height:window.innerHeight}),m=new Ct({container:f,toolName:d.tool,size:T,imgNode:e,config:S,style:JSON.parse(yt)});return{toolInstance:m==null?void 0:m.toolInstance,annotationEngine:m}},Ft=(t,e)=>(u,A)=>Tt(void 0,null,function*(){var d,S;const{stepList:f,step:T}=A().annotation,m=O.currentToolIsVideo(T,f),y=O.currentToolIsPointCloud(T,f),h=((d=O.getCurrentStepInfo(T,f))==null?void 0:d.tool)===W.LLM,b=((S=O.getCurrentStepInfo(T,f))==null?void 0:S.tool)===W.NLP,N=O.currentToolIsAudio(T,f);if($(u,!0),yield u(jt(t)),m){u(Gt(t));return}if(y||h||N||b){u(Vt(t));return}u(Mt(t,e))}),jt=t=>(e,u)=>Tt(void 0,null,function*(){const{getFileData:A,imgList:d}=u().annotation;if(A){const S=yield A(d[t],t);e({type:i.SET_FILE_DATA,payload:{fileData:S,index:t}})}}),Gt=t=>e=>{e({type:i.LOAD_FILE_DATA,payload:{nextIndex:t}})},Vt=t=>e=>{$(e,!1),e({type:i.LOAD_FILE_DATA,payload:{nextIndex:t}})},Mt=(t,e)=>(u,A)=>{var d;const{toolInstance:S,imgList:f}=A().annotation,T=(d=f==null?void 0:f[t])==null?void 0:d.url;Ot.load(T).then(m=>{$(u,!1),u({type:i.LOAD_FILE_DATA,payload:{imgNode:m,nextIndex:t,nextBasicIndex:e}})}).catch(()=>{$(u,!1),S==null||S.setErrorImg(),u({type:i.LOAD_FILE_DATA,payload:{nextIndex:t,nextBasicIndex:e}})})},kt=({toolInstance:t,imgList:e,imgIndex:u,stepList:A,step:d=1})=>{var S,f,T,m;const y=((S=e[u])==null?void 0:S.result)||"",[h,b,N]=(f=t==null?void 0:t.exportData())!=null?f:[],V=(m=(T=t==null?void 0:t.exportCustomData)==null?void 0:T.call(t))!=null?m:{},M=ct(y,b),k=Y(M,{step:d,stepList:A},{rect:h},V);return e.map((F,H)=>H===u?o(l(o({},F),{result:k}),N):o({},F))},Ht=(t=o({},Lt),e)=>{var u,A,d,S,f,T,m,y,h,b,N,V,M,k,F,H,q,Z,Q,tt,et,nt,ot,st,lt,it,rt;switch(e.type){case i.INIT_ALL_STATE:return o(o({},t),Lt);case i.UPDATE_TOOL_INSTANCE:return l(o({},t),{toolInstance:e.payload.toolInstance});case i.UPDATE_IMG_LIST:return l(o({},t),{imgList:e.payload.imgList});case i.CALC_STEP_PROGRESS:{const{imgList:n,step:s}=t,r=Et(n,s);return l(o({},t),{stepProgress:r})}case i.SUBMIT_FILE_DATA:{const{imgList:n,imgIndex:s,step:r,stepList:a,toolInstance:p,onSubmit:c,resultList:L}=t;if(!p||!n[s])return t;const _=((u=n[s])==null?void 0:u.result)||"",[,g,I]=(A=p==null?void 0:p.exportData())!=null?A:[],E=(S=(d=p==null?void 0:p.exportCustomData)==null?void 0:d.call(p))!=null?S:{},D=ct(_,g),R=Y(D,{step:r,stepList:a},{rect:L},E),v=t.imgList.map((C,P)=>{if(P===s){const j=X.dataCorrection(R,_,r,a);return o(l(o({},C),{result:j}),I)}return C});if(((f=e.payload)==null?void 0:f.submitType)===K.SyncImgList)return l(o({},t),{imgList:v});c&&c([v[s]],(T=e.payload)==null?void 0:T.submitType,s,v);const U=Et(v,r);return l(o({},t),{stepProgress:U,imgList:v})}case i.SAVE_RESULT:{const{imgList:n,imgIndex:s,onSave:r}=t;return r==null||r(n[s],s,n),o({},t)}case i.SUBMIT_RESULT:{const{imgList:n,basicIndex:s,resultList:r,toolInstance:a,basicResultList:p}=t;if(!a)return t;const[c]=(m=a==null?void 0:a.exportData())!=null?m:[];let L=c;if((p==null?void 0:p.length)>0){const _=(y=p[s])==null?void 0:y.id,g=c.map(I=>l(o({},I),{sourceID:_}));L=It.cloneDeep(r).filter(I=>I.sourceID!==_),L.push(...g)}return l(o({},t),{resultList:L,imgList:n})}case i.SET_BASIC_INDEX:{const{toolInstance:n,step:s,imgList:r,imgIndex:a,stepList:p,annotationEngine:c,resultList:L,basicResultList:_}=t;if(!n||!c)return t;const g=e.payload.basicIndex,I=(h=_[g])==null?void 0:h.id,E=x((b=r[a])==null?void 0:b.result),D=(L||[]).filter(j=>j.sourceID===I),R=w(p,s),{dataSourceStep:v,tool:U}=R,C=w(p,v);let P=[];return v&&U&&(P=(N=E[`step_${v}`])==null?void 0:N.result,(P==null?void 0:P.length)>0?(c==null||c.setBasicInfo(C.tool,P[g]),c==null||c.launchOperation()):(c==null||c.setBasicInfo(C.tool),c==null||c.forbidOperation(),_t.info(G.t("NoDependency")))),n==null||n.setResult(D),n==null||n.history.initRecord(D,!0),l(o({},t),{basicIndex:g})}case i.SET_TRIGGER_EVENT_AFTER_INDEX_CHANGED:{const{triggerEventAfterIndexChanged:n}=e.payload;return l(o({},t),{triggerEventAfterIndexChanged:!!n})}case i.LOAD_FILE_DATA:{const{imgList:n,step:s,toolInstance:r,annotationEngine:a,stepList:p}=t;if(!r)return l(o({},t),{imgIndex:e.payload.nextIndex});const c=O.getCurrentStepInfo(s,p),{nextIndex:L,imgNode:_,nextBasicIndex:g,imgError:I}=e.payload,E=g!=null?g:0,D=x((V=n[L])==null?void 0:V.result),R=D[`step_${c.step}`],v=!R,U={rotate:(M=D.rotate)!=null?M:0,valid:(k=D.valid)!=null?k:!0};_&&I!==!0?a==null||a.setImgNode(_,U):r==null||r.setValid(U.valid);const C=w(p,c.step),{dataSourceStep:P,tool:j}=C,ut=w(p,P),at=P&&j,B=(H=(F=D[`step_${P}`])==null?void 0:F.result)!=null?H:[],z=X.getInitialResultList(R==null?void 0:R.result,r,C,B,v);if(a==null||a.launchOperation(),at&&((B==null?void 0:B.length)>0?a==null||a.setBasicInfo(ut.tool,B[E]):(a==null||a.setBasicInfo(ut.tool),a==null||a.forbidOperation(),_t.info(G.t("NoDependency")))),c.tool!=="check"){const At=(Z=(q=B[E])==null?void 0:q.id)!=null?Z:"",St=at?z.filter(Dt=>Pt.isSameSourceID(Dt.sourceID,At)):z;(Q=r==null?void 0:r.history)==null||Q.initRecord(z,!0),r==null||r.setResult(St)}return l(o({},t),{imgIndex:L,basicIndex:E,basicResultList:B,resultList:z})}case i.UPDATE_ANNOTATION_CONFIG:return l(o({},t),{config:(tt=e.payload.config)!=null?tt:"{}"});case i.SET_TASK_STEP_LIST:{const{stepList:n}=e.payload;return l(o({},t),{stepList:n})}case i.SET_TASK_CONFIG:{const{stepList:n,step:s}=e.payload;return l(o({},t),{stepList:n,step:s})}case i.INIT_TOOL:{const{imgNode:n}=t,s=wt(t,n);if(s){const{toolInstance:r,annotationEngine:a}=s;return l(o({},t),{toolInstance:r,annotationEngine:a})}return o({},t)}case i.SET_TOOL:{const n=(et=e.payload)==null?void 0:et.instance;return n?l(o({},t),{toolInstance:n}):o({},t)}case i.UPDATE_ON_SUBMIT:return l(o({},t),{onSubmit:e.payload.onSubmit});case i.UPDATE_ON_SAVE:return l(o({},t),{onSave:e.payload.onSave});case i.UPDATE_ON_PAGE_CHANGE:return l(o({},t),{onPageChange:e.payload.onPageChange});case i.SET_PREDICT_RESULT:return l(o({},t),{predictionResult:e.payload.result});case i.SET_PREDICT_RESULT_VISIBLE:return l(o({},t),{predictionResultVisible:e.payload.visible});case i.UPDATE_ON_STEP_CHANGE:return l(o({},t),{onStepChange:e.payload.onStepChange});case i.UPDATE_GET_FILE_DATA:return l(o({},t),{getFileData:e.payload.getFileData});case i.UPDATE_PAGE_SIZE:return l(o({},t),{pageSize:e.payload.pageSize});case i.UPDATE_LOAD_FILE_LIST:return l(o({},t),{loadFileList:e.payload.loadFileList});case i.UPDATE_BEFORE_ROTATE:return l(o({},t),{beforeRotate:e.payload.beforeRotate});case i.UPDATE_PRE_DATA_PROCESS:return l(o({},t),{preDataProcess:e.payload.preDataProcess});case i.UPDATE_IMG_INDEX_BY_EXTERNAL:return l(o({},t),{getImgIndexByExternal:e.payload.getImgIndexByExternal});case i.SKIP_BEFORE_PAGE_TURNING:return l(o({},t),{skipBeforePageTurning:e.payload.skipBeforePageTurning});case i.SET_FILE_DATA:{const{fileData:n,index:s}=e.payload,{imgList:r}=t,a=[...r];return a[s]=o(o({},a[s]),n),l(o({},t),{imgList:a})}case i.UPDATE_ROTATE:{const{toolInstance:n,beforeRotate:s}=t;return s&&s()===!1||(nt=n==null?void 0:n.updateRotate)==null||nt.call(n),t}case i.UPDATE_ANNOTATION_VALID:{const{toolInstance:n}=t,s=(ot=n==null?void 0:n.valid)!=null?ot:!0;return gt.destroyAll(),gt.confirm({content:G.t(s?"updateValidFromValidToInValid":"updateValidFromInValidToValid"),onOk:()=>{n==null||n.setValid(!s)},okText:G.t("Confirm"),cancelText:G.t("Cancel")}),t}case i.COPY_BACKWARD_RESULT:{const{toolInstance:n,imgIndex:s,imgList:r,step:a}=t;if(!n)return t;if(s===0||s>=r.length)return console.error("\u65E0\u6CD5\u590D\u5236\u8FB9\u754C\u5916\u7684\u5185\u5BB9"),t;const p=r[s-1].result;if(!p)return t;const c=X.copyResultChange({copyResult:p,step:a,currentResult:(st=r[s].result)!=null?st:"",preMappingImgList:(lt=r[s-1].mappingImgList)!=null?lt:[],mappingImgList:(it=r[s].mappingImgList)!=null?it:[]});r[s]=l(o({},r[s]),{result:c});const _=x(c)[`step_${a}`],g=(_==null?void 0:_.result)||[];return n==null||n.setResult(g),n==null||n.history.pushHistory(g),(rt=n==null?void 0:n.asyncData)==null||rt.call(n,r[s]),l(o({},t),{imgList:[...r]})}case i.SET_STEP:{const{stepList:n,annotationEngine:s}=t,{toStep:r}=e.payload;if(s){const a=w(n,r);return s==null||s.setToolName(a.tool,a.config),l(o({},t),{step:r,toolInstance:s==null?void 0:s.toolInstance})}return l(o({},t),{step:r})}case i.SET_LOADPCDFILE_LOADING:{const{loadPCDFileLoading:n}=e.payload;return l(o({},t),{loadPCDFileLoading:!!n})}case i.SET_LOADING:{const{loading:n}=e.payload;return l(o({},t),{loading:!!n})}case i.SET_POINT_CLOUD_LOADING:{const{pointCloudLoading:n}=e.payload;return l(o({},t),{pointCloudLoading:!!n})}case i.SET_CHECK_MODE:{const{checkMode:n}=e.payload;return l(o({},t),{checkMode:!!n})}case i.SET_HIGHLIGHT_ATTRIBUTE:{const{attribute:n}=e.payload;return l(o({},t),{highlightAttribute:n})}case i.BATCH_UPDATE_TRACK_ID:{const{id:n,newID:s,rangeIndex:r,imgList:a}=e.payload,{imgIndex:p,onSubmit:c}=t,L=[],_=a.map((g,I)=>{if(dt.isInRange(I,r)){const E=l(o({},g),{result:pt.batchUpdateTrackID({id:n,newID:s,result:g.result})});return L.push({imgIndex:I,newInfo:E}),E}return g});return c&&c([_[p]],K.BatchUpdateTrackID,p,_,{updateImgList:L}),l(o({},t),{imgList:_})}case i.BATCH_UPDATE_RESULT_BY_TRACK_ID:{const{id:n,newData:s,rangeIndex:r}=e.payload,{imgList:a,imgIndex:p,onSubmit:c}=t,L=[],_=a.map((g,I)=>{if(dt.isInRange(I,r)){const E=l(o({},g),{result:pt.batchUpdateResultByTrackID({id:n,newData:s,result:g.result})});return L.push({imgIndex:I,newInfo:E}),E}return g});return c&&c([_[p]],K.BatchUpdateTrackID,p,_,{updateImgList:L}),l(o({},t),{imgList:_})}case i.BATCH_UPDATE_IMG_LIST_RESULT_BY_PREDICT_RESULT:{const{onSubmit:n,imgList:s,stepList:r,step:a,predictionResult:p}=t,c={};p.forEach(I=>{const{index:E}=I;c[E]=It.pick(I,["center","width","height","depth","rotation","id","attribute","valid","trackID"])});const L=`step_${a}`,_=[],g=s.map((I,E)=>{if(c[E]){const D=I.result==="{}"?x(Y("",{step:a,stepList:r},{rect:[]},{})):x(I.result);D[L].result.push(c[E]);const R=l(o({},I),{result:JSON.stringify(D)});return _.push({imgIndex:E,newInfo:R}),R}return I});return n==null||n(g,K.BatchUpdateImgList,-1,g,{updateImgList:_}),l(o({},t),{imgList:g})}default:return t}};export{Ft as LoadFileAndFileData,Ht as annotationReducer,kt as composeResultByToolInstance,w as getStepConfig,xt as getTotalPage};
@@ -1 +1 @@
1
- import{uuid as v}from"@labelbee/lb-annotation";import{jsonParser as l}from"./index.js";import{EToolName as d}from"../data/enums/ToolType.js";import _ from"lodash";import y from"./StepUtils.js";var O=Object.defineProperty,P=Object.defineProperties,j=Object.getOwnPropertyDescriptors,h=Object.getOwnPropertySymbols,w=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable,S=(a,t,e)=>t in a?O(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,E=(a,t)=>{for(var e in t||(t={}))w.call(t,e)&&S(a,e,t[e]);if(h)for(var e of h(t))x.call(t,e)&&S(a,e,t[e]);return a},N=(a,t)=>P(a,j(t));class R{static copyResultChange(t,e,r){try{const s=l(t),i=l(r),o=`step_${e}`;if(s[o]){const n=s[o];if(n.result)return n.result=n.result.map(u=>N(E({},u),{id:v(8,62)})),i[o]=n,JSON.stringify(i)}return t}catch(s){return t}}static isResultSourceMatchedDependence(t,e){const r=t==null?void 0:t.map(i=>i.sourceID).sort(),s=e==null?void 0:e.map(i=>i.id).sort();return _.isEqual(r,s)}static deltaUpdateBasicResultList(t,e){const r=t==null?void 0:t.map(s=>s.sourceID).sort();return e.filter(s=>!r.includes(s.id))}static getInitialResultList(t,e,r,s,i){const o=t!=null?t:[];switch(r.tool){case d.Tag:case d.Text:{if(r.dataSourceStep>0){const n=this.deltaUpdateBasicResultList(o,s);if(n.length>0)return o.concat(e.getInitResultList(r.dataSourceStep,n))}return i!==!0?o:e.getInitResultList(r.dataSourceStep,s)}default:return o}}static dataCorrection(t,e,r,s){var i,o;try{const u=`step_${y.getStepInfo(r,s).step}`,c=l(t),I=l(e),f=(i=c[u])==null?void 0:i.result,p=(o=I[u])==null?void 0:o.result;if(!p||_.isEqual(f.sort(this.idCmp),p.sort(this.idCmp)))return t;const m=this.findDeletedIds(f,p);if(m.length===0)return t;const D=r,g=this.getStepKeys(c).sort();return this.deleteRes(c,D,m,g),JSON.stringify(c)}catch(n){return console.error(n),t}}static idCmp(t,e){const r=t.id,s=e.id;return r<s?-1:r>s?1:0}static findDeletedIds(t,e){return this.findDeletedItems(e,t).map(r=>r.id)}static findDeletedItems(t,e){const r=[];return t.forEach(s=>{e.some(o=>o.id===s.id)||r.push(s)}),r}static getStepKeys(t){return Object.keys(t).map(e=>parseInt(e.replace("step_",""),10)).filter(e=>!isNaN(e))}static deleteRes(t,e,r,s){s.forEach(i=>{if(i>e){const o=t[`step_${i}`];if([d.FolderTag,d.Segmentation].includes(o.tool))return;if(o.dataSourceStep===e){const n=[];o.result=o.result.filter(u=>r.includes(u.sourceID)?(n.push(u.id),!1):!0),this.deleteRes(t,i,n,s)}else o.result=o.result.filter(n=>!r.includes(n.sourceID))}})}}export{R 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";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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labelbee/lb-components",
3
- "version": "1.23.0-alpha.21",
3
+ "version": "1.23.0-alpha.23",
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.10",
47
- "@labelbee/lb-utils": "1.19.0-alpha.5",
46
+ "@labelbee/lb-annotation": "1.27.0-alpha.12",
47
+ "@labelbee/lb-utils": "1.19.0-alpha.7",
48
48
  "@labelbee/wavesurfer": "1.0.0",
49
49
  "@types/react-dom": "^18.2.7",
50
50
  "@types/react-transition-group": "^4.4.9",