@labelbee/lb-components 1.23.0-alpha.120 → 1.23.0-alpha.121
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var ahooks=require("ahooks"),es=require("antd/es"),React=require("react"),reactRedux=require("react-redux"),usePointCloudViews=require("../pointCloudView/hooks/usePointCloudViews.js"),PointCloudContext=require("../pointCloudView/PointCloudContext.js"),map=require("../../store/annotation/map.js"),ctx=require("../../store/ctx.js"),lbAnnotation=require("@labelbee/lb-annotation"),util=require("./util.js"),useUpdateRectList=require("./useUpdateRectList.js"),useToolStyle=require("../../hooks/useToolStyle.js"),index=require("../../store/toolConfig/index.js");function _interopDefaultLegacy(
|
|
1
|
+
"use strict";var ahooks=require("ahooks"),es=require("antd/es"),React=require("react"),reactRedux=require("react-redux"),usePointCloudViews=require("../pointCloudView/hooks/usePointCloudViews.js"),PointCloudContext=require("../pointCloudView/PointCloudContext.js"),map=require("../../store/annotation/map.js"),ctx=require("../../store/ctx.js"),lbAnnotation=require("@labelbee/lb-annotation"),util=require("./util.js"),useUpdateRectList=require("./useUpdateRectList.js"),_=require("lodash"),useToolStyle=require("../../hooks/useToolStyle.js"),index=require("../../store/toolConfig/index.js");function _interopDefaultLegacy(l){return l&&typeof l=="object"&&"default"in l?l:{default:l}}var React__default=_interopDefaultLegacy(React),___default=_interopDefaultLegacy(_),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(l,u,c)=>u in l?__defProp(l,u,{enumerable:!0,configurable:!0,writable:!0,value:c}):l[u]=c,__spreadValues=(l,u)=>{for(var c in u||(u={}))__hasOwnProp.call(u,c)&&__defNormalProp(l,c,u[c]);if(__getOwnPropSymbols)for(var c of __getOwnPropSymbols(u))__propIsEnum.call(u,c)&&__defNormalProp(l,c,u[c]);return l},__spreadProps=(l,u)=>__defProps(l,__getOwnPropDescs(u)),__async=(l,u,c)=>new Promise((a,p)=>{var I=d=>{try{D(c.next(d))}catch(R){p(R)}},x=d=>{try{D(c.throw(d))}catch(R){p(R)}},D=d=>d.done?a(d.value):Promise.resolve(d.value).then(I,x);D((c=c.apply(l,u)).next())});const PointCloud2DRectOperationView=l=>{var u,c;const{mappingData:a,size:p,config:I,checkMode:x,afterImgOnLoad:D,shouldExcludePointCloudBoxListUpdate:d}=l,{selectBoxVisibleSwitch:R}=index(),P=(u=a==null?void 0:a.url)!=null?u:"",b=(c=a==null?void 0:a.fallbackUrl)!=null?c:"",{pointCloudBoxList:S,setPointCloudResult:L,defaultAttribute:E,rectList:O,addRectIn2DView:Q,updateRectIn2DView:W,removeRectIn2DView:X,updateRectListByReducer:Y,selectedIDs:v,setSelectedIDs:V}=React.useContext(PointCloudContext.PointCloudContext),{value:q}=useToolStyle.useToolStyleContext(),Z=ahooks.useLatest(v),{update2DViewRect:ee,remove2DViewRect:te}=usePointCloudViews.usePointCloudViews(),j=React__default.default.useRef(null),o=React.useRef(null),M=ahooks.useMemoizedFn(ee),w=ahooks.useMemoizedFn(te),y=React.useRef(null),[re,A]=React.useState(!0),[F,T]=React.useState(""),[ne,k]=React.useState(!1),g=React.useMemo(()=>O==null?void 0:O.filter(e=>e.imageName===(a==null?void 0:a.path)),[a==null?void 0:a.path,O]),z=React.useRef(g),C=ahooks.useLatest(a==null?void 0:a.path),B=React.useCallback(e=>__async(void 0,null,function*(){try{const n=Z.current.slice(0),t=yield Promise.resolve(e());if(!t||t.length===0)return t;if(n.length){const r=new Set(n),i=t.filter(s=>r.has(s.id)).map(s=>s.id);V(i)}return t}catch(n){}}),[V]),H=e=>{const{boxID:n}=e;if(!d&&n){B(()=>{const t=M==null?void 0:M(e);return t?(y.current=t,L(t),t):null});return}W(e,!0)},J=e=>{C.current&&Q(__spreadProps(__spreadValues({},e),{imageName:C.current}))},$=e=>{if(e.length===0)return;if(!d){const t=e.find(r=>r.boxID);if(t){B(()=>{const r=w==null?void 0:w(t);return r?(y.current=r,L(r),h(),r):null});return}}const n=e.find(t=>t.extId);n&&B(()=>{const{imageName:t,extId:r}=n,i=w==null?void 0:w({boxID:r,imageName:t});return i?(y.current=i,L(i),i):null}),X(e)},oe=ahooks.useMemoizedFn(()=>{let e=[];return S.forEach(n=>{const{rects:t=[],id:r,attribute:i,trackID:s}=n,f=t.find(N=>N.imageName===C.current),m=r+"_"+C.current;f&&(e=[...e,__spreadProps(__spreadValues({},f),{boxID:r,id:m,attribute:i,order:s})])}),e}),h=useUpdateRectList.useUpdateRectList(()=>{var e,n,t,r,i;const s=d?[]:oe(),f=(e=o.current)==null?void 0:e.selectedRectID,m=v.slice(0),N=R?util.selectSpecifiedRectsFromTopViewSelectedIds(m,s,g):[...s,...g];let K=[];!R&&(v==null?void 0:v.length)&&(K=s.filter(U=>f?v.includes(U.boxID)&&!f.includes(U.boxID):v.includes(U.boxID))),(n=o.current)==null||n.setHighLightRectList(K),(t=o.current)==null||t.setResult(N),F?((r=o.current)==null||r.setSelectedRectID(F),T("")):ne&&f&&((i=o.current)==null||i.setSelectedRectID(f),k(!1))}),G=({targetId:e,id:n})=>{V(e),T(n)};return React.useEffect(()=>{if(j.current){const e=new lbAnnotation.PointCloud2DRectOperation({container:j.current,size:p,config:__spreadProps(__spreadValues({},I),{isShowOrder:!0,attributeConfigurable:!0}),checkMode:x});return o.current=e,o.current.init(),o.current.on("updateDragResult",H),o.current.on("afterAddingDrawingRect",J),o.current.on("deleteSelectedRects",$),o.current.on("onRightClick",G),()=>{var n,t,r,i,s;(n=o.current)==null||n.unbind("updateDragResult",H),(t=o.current)==null||t.unbind("afterAddingDrawingRect",J),(r=o.current)==null||r.unbind("deleteSelectedRects",$),(i=o.current)==null||i.unbind("onRightClick",G),(s=o.current)==null||s.destroy()}}},[]),React.useEffect(()=>{const e=t=>__async(void 0,null,function*(){try{return yield lbAnnotation.ImgUtils.load(t)}catch(r){return console.error("Error loading image:",r),null}}),n=()=>__async(void 0,null,function*(){var t;A(!0);let r=yield e(P);!r&&b&&(r=yield e(b)),r&&((t=o.current)==null||t.setImgNode(r),D(r)),A(!1)});o.current&&(P||b)&&n()},[P,b]),React.useEffect(()=>{var e;(e=o.current)==null||e.setSize(p)},[p]),React.useEffect(()=>{S!==y.current&&h()},[S]),React.useEffect(()=>{var e,n;const t=g.find(r=>r.id===o.current.selectedRectID);(n=(e=o.current)==null?void 0:e.setDefaultAttribute)==null||n.call(e,E),t&&Y(r=>{var i;const s=[];let f=null;return r.forEach(m=>{m.id!==o.current.selectedRectID?s.push(m):f=m}),t.extId===void 0&&(f=(i=o.current)==null?void 0:i.selectedRect),[...s,__spreadProps(__spreadValues({},f||{}),{attribute:E})]}),k(!0),h()},[E]),React.useEffect(()=>{const e=z.current;___default.default.isEqual(e,g)||(k(!0),h(),z.current=g)},[g]),React.useEffect(()=>{h()},[d]),React.useEffect(()=>{var e,n,t,r;const i=(n=(e=o.current)==null?void 0:e.config)!=null?n:{},s=__spreadProps(__spreadValues({},i),{attributeList:(t=I.attributeList)!=null?t:[]});(r=o.current)==null||r.setConfig(JSON.stringify(s))},[I.attributeList]),React.useEffect(()=>{var e;(e=o.current)==null||e.setEnableAddRect(v.length===0),h()},[v]),React.useEffect(()=>{const{hiddenText:e}=q||{};if(e===void 0)return;const n=o.current;if(!n)return;const t=__spreadValues(__spreadValues({},n.style),q);n.setStyle(t)},[q]),React.useEffect(()=>{h()},[R]),React__default.default.createElement(es.Spin,{spinning:re},React__default.default.createElement("div",{ref:j,style:__spreadValues({position:"relative"},p)}))};var PointCloud2DRectOperationView$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloud2DRectOperationView);module.exports=PointCloud2DRectOperationView$1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useLatest as
|
|
1
|
+
import{useLatest as ne,useMemoizedFn as F}from"ahooks";import{Spin as ve}from"antd/es";import z,{useContext as ge,useRef as q,useState as H,useMemo as Re,useCallback as he,useEffect as p}from"react";import{connect as _e}from"react-redux";import{usePointCloudViews as Ie}from"../pointCloudView/hooks/usePointCloudViews.js";import{PointCloudContext as De}from"../pointCloudView/PointCloudContext.js";import{a2MapStateToProps as be}from"../../store/annotation/map.js";import{LabelBeeContext as we}from"../../store/ctx.js";import{PointCloud2DRectOperation as Ce,ImgUtils as ye}from"@labelbee/lb-annotation";import{selectSpecifiedRectsFromTopViewSelectedIds as xe}from"./util.js";import{useUpdateRectList as Pe}from"./useUpdateRectList.js";import Se from"lodash";import{useToolStyleContext as Le}from"../../hooks/useToolStyle.js";import Oe from"../../store/toolConfig/index.js";var Ve=Object.defineProperty,je=Object.defineProperties,Ee=Object.getOwnPropertyDescriptors,re=Object.getOwnPropertySymbols,ke=Object.prototype.hasOwnProperty,Be=Object.prototype.propertyIsEnumerable,oe=(u,i,c)=>i in u?Ve(u,i,{enumerable:!0,configurable:!0,writable:!0,value:c}):u[i]=c,v=(u,i)=>{for(var c in i||(i={}))ke.call(i,c)&&oe(u,c,i[c]);if(re)for(var c of re(i))Be.call(i,c)&&oe(u,c,i[c]);return u},w=(u,i)=>je(u,Ee(i)),J=(u,i,c)=>new Promise((d,g)=>{var D=a=>{try{b(c.next(a))}catch(R){g(R)}},S=a=>{try{b(c.throw(a))}catch(R){g(R)}},b=a=>a.done?d(a.value):Promise.resolve(a.value).then(D,S);b((c=c.apply(u,i)).next())});const Ne=u=>{var i,c;const{mappingData:d,size:g,config:D,checkMode:S,afterImgOnLoad:b,shouldExcludePointCloudBoxListUpdate:a}=u,{selectBoxVisibleSwitch:R}=Oe(),L=(i=d==null?void 0:d.url)!=null?i:"",C=(c=d==null?void 0:d.fallbackUrl)!=null?c:"",{pointCloudBoxList:O,setPointCloudResult:V,defaultAttribute:j,rectList:E,addRectIn2DView:le,updateRectIn2DView:ie,removeRectIn2DView:ce,updateRectListByReducer:se,selectedIDs:m,setSelectedIDs:k}=ge(De),{value:B}=Le(),ue=ne(m),{update2DViewRect:de,remove2DViewRect:ae}=Ie(),N=z.useRef(null),o=q(null),$=F(de),y=F(ae),x=q(null),[fe,G]=H(!0),[K,Q]=H(""),[pe,U]=H(!1),h=Re(()=>E==null?void 0:E.filter(e=>e.imageName===(d==null?void 0:d.path)),[d==null?void 0:d.path,E]),W=q(h),P=ne(d==null?void 0:d.path),A=he(e=>J(void 0,null,function*(){try{const r=ue.current.slice(0),t=yield Promise.resolve(e());if(!t||t.length===0)return t;if(r.length){const n=new Set(r),l=t.filter(s=>n.has(s.id)).map(s=>s.id);k(l)}return t}catch(r){}}),[k]),X=e=>{const{boxID:r}=e;if(!a&&r){A(()=>{const t=$==null?void 0:$(e);return t?(x.current=t,V(t),t):null});return}ie(e,!0)},Y=e=>{P.current&&le(w(v({},e),{imageName:P.current}))},Z=e=>{if(e.length===0)return;if(!a){const t=e.find(n=>n.boxID);if(t){A(()=>{const n=y==null?void 0:y(t);return n?(x.current=n,V(n),_(),n):null});return}}const r=e.find(t=>t.extId);r&&A(()=>{const{imageName:t,extId:n}=r,l=y==null?void 0:y({boxID:n,imageName:t});return l?(x.current=l,V(l),l):null}),ce(e)},me=F(()=>{let e=[];return O.forEach(r=>{const{rects:t=[],id:n,attribute:l,trackID:s}=r,f=t.find(M=>M.imageName===P.current),I=n+"_"+P.current;f&&(e=[...e,w(v({},f),{boxID:n,id:I,attribute:l,order:s})])}),e}),_=Pe(()=>{var e,r,t,n,l;const s=a?[]:me(),f=(e=o.current)==null?void 0:e.selectedRectID,I=m.slice(0),M=R?xe(I,s,h):[...s,...h];let te=[];!R&&(m==null?void 0:m.length)&&(te=s.filter(T=>f?m.includes(T.boxID)&&!f.includes(T.boxID):m.includes(T.boxID))),(r=o.current)==null||r.setHighLightRectList(te),(t=o.current)==null||t.setResult(M),K?((n=o.current)==null||n.setSelectedRectID(K),Q("")):pe&&f&&((l=o.current)==null||l.setSelectedRectID(f),U(!1))}),ee=({targetId:e,id:r})=>{k(e),Q(r)};return p(()=>{if(N.current){const e=new Ce({container:N.current,size:g,config:w(v({},D),{isShowOrder:!0,attributeConfigurable:!0}),checkMode:S});return o.current=e,o.current.init(),o.current.on("updateDragResult",X),o.current.on("afterAddingDrawingRect",Y),o.current.on("deleteSelectedRects",Z),o.current.on("onRightClick",ee),()=>{var r,t,n,l,s;(r=o.current)==null||r.unbind("updateDragResult",X),(t=o.current)==null||t.unbind("afterAddingDrawingRect",Y),(n=o.current)==null||n.unbind("deleteSelectedRects",Z),(l=o.current)==null||l.unbind("onRightClick",ee),(s=o.current)==null||s.destroy()}}},[]),p(()=>{const e=t=>J(void 0,null,function*(){try{return yield ye.load(t)}catch(n){return console.error("Error loading image:",n),null}}),r=()=>J(void 0,null,function*(){var t;G(!0);let n=yield e(L);!n&&C&&(n=yield e(C)),n&&((t=o.current)==null||t.setImgNode(n),b(n)),G(!1)});o.current&&(L||C)&&r()},[L,C]),p(()=>{var e;(e=o.current)==null||e.setSize(g)},[g]),p(()=>{O!==x.current&&_()},[O]),p(()=>{var e,r;const t=h.find(n=>n.id===o.current.selectedRectID);(r=(e=o.current)==null?void 0:e.setDefaultAttribute)==null||r.call(e,j),t&&se(n=>{var l;const s=[];let f=null;return n.forEach(I=>{I.id!==o.current.selectedRectID?s.push(I):f=I}),t.extId===void 0&&(f=(l=o.current)==null?void 0:l.selectedRect),[...s,w(v({},f||{}),{attribute:j})]}),U(!0),_()},[j]),p(()=>{const e=W.current;Se.isEqual(e,h)||(U(!0),_(),W.current=h)},[h]),p(()=>{_()},[a]),p(()=>{var e,r,t,n;const l=(r=(e=o.current)==null?void 0:e.config)!=null?r:{},s=w(v({},l),{attributeList:(t=D.attributeList)!=null?t:[]});(n=o.current)==null||n.setConfig(JSON.stringify(s))},[D.attributeList]),p(()=>{var e;(e=o.current)==null||e.setEnableAddRect(m.length===0),_()},[m]),p(()=>{const{hiddenText:e}=B||{};if(e===void 0)return;const r=o.current;if(!r)return;const t=v(v({},r.style),B);r.setStyle(t)},[B]),p(()=>{_()},[R]),z.createElement(ve,{spinning:fe},z.createElement("div",{ref:N,style:v({position:"relative"},g)}))};var Ue=_e(be,null,null,{context:we})(Ne);export{Ue 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.121",
|
|
4
4
|
"description": "Provide a complete library of annotation components",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"es": "./es/index.js",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@ant-design/icons": "^4.6.2",
|
|
46
|
-
"@labelbee/lb-annotation": "1.27.0-alpha.
|
|
46
|
+
"@labelbee/lb-annotation": "1.27.0-alpha.62",
|
|
47
47
|
"@labelbee/lb-utils": "1.19.0-alpha.23",
|
|
48
48
|
"@labelbee/wavesurfer": "1.1.0-alpha.1",
|
|
49
49
|
"@types/react-dom": "^18.2.7",
|