shop-components 0.1.21 → 0.1.22
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/shop-components.mjs
CHANGED
|
@@ -57496,20 +57496,7 @@ class L0 extends Iv {
|
|
|
57496
57496
|
}
|
|
57497
57497
|
} else
|
|
57498
57498
|
this._emitter.emit(xi.ON_DROP_ERROR, new Error("No device info"));
|
|
57499
|
-
})
|
|
57500
|
-
const t = [
|
|
57501
|
-
"单激光定位导航",
|
|
57502
|
-
"激光反光板导航",
|
|
57503
|
-
"普通栈板识别",
|
|
57504
|
-
"2D 障碍物停障",
|
|
57505
|
-
"2D 障碍物绕障1",
|
|
57506
|
-
"2D 障碍物绕障2",
|
|
57507
|
-
"2D 障碍物绕障3",
|
|
57508
|
-
"2D 障碍物绕障4",
|
|
57509
|
-
"2D 障碍物绕障5"
|
|
57510
|
-
];
|
|
57511
|
-
this.allFunctions = [...t], t.pop(), t.pop(), t.pop(), t.pop(), t.pop(), this.addFunctions(t);
|
|
57512
|
-
}, 1e3);
|
|
57499
|
+
});
|
|
57513
57500
|
}
|
|
57514
57501
|
get hasDevice() {
|
|
57515
57502
|
return this._slotContainer.children.length > 0;
|
|
@@ -9559,7 +9559,7 @@ void main(void)\r
|
|
|
9559
9559
|
</div>
|
|
9560
9560
|
</div>
|
|
9561
9561
|
</div>
|
|
9562
|
-
`}};Ot.styles=Bf([dk]),ci([qa()],Ot.prototype,"_size",2),ci([qa()],Ot.prototype,"_showDialog",2),ci([$i({type:Boolean})],Ot.prototype,"selected",2),ci([$i({type:Boolean})],Ot.prototype,"hasError",2),ci([$i({type:Boolean})],Ot.prototype,"canInstall",2),ci([$i({type:Boolean})],Ot.prototype,"hide",2),ci([$i({type:Boolean})],Ot.prototype,"disable",2),ci([$i({type:Boolean})],Ot.prototype,"filled",2),ci([$i({type:Object})],Ot.prototype,"allFunctions",2),ci([$i({type:Object})],Ot.prototype,"functions",2),ci([$i({type:String})],Ot.prototype,"deviceName",2),ci([$i()],Ot.prototype,"slot",2),Ot=ci([jf("slot-item")],Ot);const hi={ON_DROP:"slot-on-drop",ON_BEFORE_SELECTED:"slot-on-before-selected",ON_SELECTED:"slot-on-selected",ON_DEVICE_SELECTED:"slot-on-device-selected",ON_DROP_ERROR:"slot-on-drop-error",ON_ERROR_STATE_CHANGE:"slot-on-error-state-change",ON_FUNCTION_REMOVED:"slot-on-function-removed",ON_FUNCTION_ADDED:"slot-on-function-added"};class Kf extends Rg{constructor(A){const e=document.createElement("div");super(e),this.props=A,this._emitter=new xs,this._slotContainer=new Rt,this._bracketSlots=[],this._hasError=!1,this.useBracket=!1,this.addEventListener=this._emitter.addListener.bind(this._emitter),this.removeEventListener=this._emitter.removeListener.bind(this._emitter),this._canInstall=!1,this._loading=!1,this._selected=!1,this._deviceSelected=!1,this._allFunctions=new Set,this._functions=new Set,this._timer=0,this.getWP=this._slotContainer.getWorldPosition.bind(this._slotContainer),this.name=A.name,this._slotUI=new Ot({name:A.name}),this._slotUI.slot=this,e.append(this._slotUI),this._slotUI.addEventListener("function-removed",({detail:t})=>{this.removeFunction(t)}),this._slotUI.addEventListener("function-added",({detail:t})=>{this.addFunction(t)}),this.add(this._slotContainer),this.props.slot.add(this),e.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.selected=!this.selected}),e.addEventListener("dragover",t=>{if(t.preventDefault(),!this._canInstall){t.dataTransfer&&(t.dataTransfer.dropEffect="none");return}}),e.addEventListener("drop",async t=>{var r;if(t.preventDefault(),t.stopPropagation(),!this._canInstall)return;const i=(r=t.dataTransfer)==null?void 0:r.getData("application/json");if(i){const s=JSON.parse(i);try{await this.install(s),this._emitter.emit(hi.ON_DROP,this)}catch(o){this._emitter.emit(hi.ON_DROP_ERROR,o)}}else this._emitter.emit(hi.ON_DROP_ERROR,new Error("No device info"))})
|
|
9562
|
+
`}};Ot.styles=Bf([dk]),ci([qa()],Ot.prototype,"_size",2),ci([qa()],Ot.prototype,"_showDialog",2),ci([$i({type:Boolean})],Ot.prototype,"selected",2),ci([$i({type:Boolean})],Ot.prototype,"hasError",2),ci([$i({type:Boolean})],Ot.prototype,"canInstall",2),ci([$i({type:Boolean})],Ot.prototype,"hide",2),ci([$i({type:Boolean})],Ot.prototype,"disable",2),ci([$i({type:Boolean})],Ot.prototype,"filled",2),ci([$i({type:Object})],Ot.prototype,"allFunctions",2),ci([$i({type:Object})],Ot.prototype,"functions",2),ci([$i({type:String})],Ot.prototype,"deviceName",2),ci([$i()],Ot.prototype,"slot",2),Ot=ci([jf("slot-item")],Ot);const hi={ON_DROP:"slot-on-drop",ON_BEFORE_SELECTED:"slot-on-before-selected",ON_SELECTED:"slot-on-selected",ON_DEVICE_SELECTED:"slot-on-device-selected",ON_DROP_ERROR:"slot-on-drop-error",ON_ERROR_STATE_CHANGE:"slot-on-error-state-change",ON_FUNCTION_REMOVED:"slot-on-function-removed",ON_FUNCTION_ADDED:"slot-on-function-added"};class Kf extends Rg{constructor(A){const e=document.createElement("div");super(e),this.props=A,this._emitter=new xs,this._slotContainer=new Rt,this._bracketSlots=[],this._hasError=!1,this.useBracket=!1,this.addEventListener=this._emitter.addListener.bind(this._emitter),this.removeEventListener=this._emitter.removeListener.bind(this._emitter),this._canInstall=!1,this._loading=!1,this._selected=!1,this._deviceSelected=!1,this._allFunctions=new Set,this._functions=new Set,this._timer=0,this.getWP=this._slotContainer.getWorldPosition.bind(this._slotContainer),this.name=A.name,this._slotUI=new Ot({name:A.name}),this._slotUI.slot=this,e.append(this._slotUI),this._slotUI.addEventListener("function-removed",({detail:t})=>{this.removeFunction(t)}),this._slotUI.addEventListener("function-added",({detail:t})=>{this.addFunction(t)}),this.add(this._slotContainer),this.props.slot.add(this),e.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.selected=!this.selected}),e.addEventListener("dragover",t=>{if(t.preventDefault(),!this._canInstall){t.dataTransfer&&(t.dataTransfer.dropEffect="none");return}}),e.addEventListener("drop",async t=>{var r;if(t.preventDefault(),t.stopPropagation(),!this._canInstall)return;const i=(r=t.dataTransfer)==null?void 0:r.getData("application/json");if(i){const s=JSON.parse(i);try{await this.install(s),this._emitter.emit(hi.ON_DROP,this)}catch(o){this._emitter.emit(hi.ON_DROP_ERROR,o)}}else this._emitter.emit(hi.ON_DROP_ERROR,new Error("No device info"))})}get hasDevice(){return this._slotContainer.children.length>0}shapeKeyChanged(A,e){if(this.props.follows.has(A)){const t=this.props.follows.get(A);if(t){let i="x";A==="height"?i="y":A==="width"&&(i="z"),this.position[i]=(e-t.origin)*t.scale}}}async loadGlb(A){const t=await new dc({useCache:!0}).loadAsync(A);if(t.glb)return t.glb.clone(!0)}async installBracket(A){const t=await new dc({useCache:!0}).loadAsync(A);if(!t.glb)return;const i=t.glb.clone(!0);i.traverse(r=>{r.userData.isBracket=!0}),this.useBracket=!0,this._slotContainer.add(i)}async install(A){if(!this._loading){this._loading=!0;try{const e=await this.loadGlb(A.url);if(!e)throw new Error(`Fail to load device from: ${A.url}`);if(e.traverse(t=>{t.userData.isDevice=!0}),A.bracketUrl){const t=await this.loadGlb(A.bracketUrl);if(t)this.clearSlot(),t.traverse(i=>{i.name.startsWith("Slot")&&this._bracketSlots.push(i),i.userData.isBracket=!0}),this._slotContainer.add(t);else throw new Error(`Fail to load bracket from: ${A.bracketUrl}`);this._bracketSlots.forEach(i=>{i.add(e)})}else this.clearSlot(),this._slotContainer.add(e);this.deviceInfo=A,this._slotUI.deviceName=A.name,this._slotUI.filled=!0}catch(e){throw e}finally{this._loading=!1}}}get device(){return this._slotContainer.children.length?this._slotContainer.children[0]:null}get allFunctions(){return[...this._allFunctions]}set allFunctions(A){this._functions.forEach(e=>{A.includes(e)||this._functions.delete(e)}),this._allFunctions=new Set(A),console.log([...A]),this._slotUI.allFunctions=A}get functions(){return[...this._functions]}addFunction(A){this._allFunctions.has(A)&&(this._functions.add(A),this._slotUI.functions=[...this.functions],this._emitter.emit(hi.ON_FUNCTION_ADDED,A))}removeFunction(A){this._functions.has(A)&&(this._functions.delete(A),this._slotUI.functions=[...this.functions],this._emitter.emit(hi.ON_FUNCTION_REMOVED,A))}addFunctions(A){A.forEach(e=>this.addFunction(e)),this._slotUI.functions=this.functions}changeName(A){var e;this.name=A,this.props.slot.userData.name=A,this.props.name=A,(e=this.element)==null||e.setAttribute("data-name",this.props.name)}clearSlot(){this._bracketSlots=[],this._slotContainer.children.forEach(A=>{A.removeFromParent(),ir(A)}),this._slotUI.filled=!1,this.deviceInfo=void 0,this._slotUI.deviceName=""}enable(){this._slotUI.disable=!1}disable(){this._slotUI.disable=!0}hide(){this._slotUI.hide=!0}show(){this._slotUI.hide=!1}get selected(){return this._selected}set selected(A){A&&this._emitter.emit(hi.ON_BEFORE_SELECTED,A),this._selected=A,this._slotUI.selected=A,this._emitter.emit(hi.ON_SELECTED,A)}get deviceSelected(){return this._deviceSelected}set deviceSelected(A){this._deviceSelected=A,this._emitter.emit(hi.ON_DEVICE_SELECTED,A)}get error(){return this._hasError}set error(A){this._loading&&setTimeout(()=>{this.error=A},100),this._hasError=A,this._slotUI.hasError=A,this._emitter.emit(hi.ON_ERROR_STATE_CHANGE,A)}getCanInstall(){return this._canInstall}canInstall(A){this._canInstall=A,this._slotUI.canInstall=A}dispose(){cancelAnimationFrame(this._timer),this.clearSlot(),this._emitter.removeAllListeners(),ir(this._slotContainer),this.element.remove()}render(A){const e=this.element.style.transform,t=/translate\(-?\d*\.?\d*%?,?\s-?\d*\.?\d*%?\)\s*translate\((-?\d*\.?\d*)px,\s*(-?\d*\.?\d*)px\)/.exec(e);if(!t)return;const i=new dA(parseFloat(t[1]),parseFloat(t[2])),r=A.mousePos.distanceTo(i);let s=12,o=24,a=30;if(this._canInstall&&(s=34,o=60,a=60),r<a){let l=(a-r)*1+s;r<20&&(l=o),l>o&&(l=o),this._slotUI.setSize(l)}else this._slotUI.setSize(s)}clone(A){return new Rt}}var vk=Object.defineProperty,yk=Object.getOwnPropertyDescriptor,Av=(n,A,e,t)=>{for(var i=t>1?void 0:t?yk(A,e):A,r=n.length-1,s;r>=0;r--)(s=n[r])&&(i=(t?s(A,e,i):s(i))||i);return t&&i&&vk(A,e,i),i};class wk{constructor(A,e,t,i){this.name=A,this.slot=e,this.start=t,this.end=i,this.split="--",this.uuid="",this.valid=!1,this.editable=!1,this.highlight=!1,this.uuid=A+this.split+e}update(A,e){this.start=A.clone(),this.end=e.clone()}}ue.DeviceLines=class extends Gr{constructor(A,e=0){super(),this.offset=A,this.heightOffset=e,this.lines=new Map,this.setOffset(this.offset.x,this.offset.y)}setOffset(A,e){this.offset.set(A,e),this.style.setProperty("--left",this.offset.x+"px"),this.style.setProperty("--top",this.offset.y+"px")}setHeightOffset(A){this.heightOffset=A,this.style.setProperty("--heightOffset",this.heightOffset+"px")}hide(){var A;(A=this.container)==null||A.classList.add("hidden")}show(){var A;(A=this.container)==null||A.classList.remove("hidden")}addLine(A){this.lines.has(A.uuid)||this.lines.set(A.uuid,A)}clear(){this.lines.clear()}removeLine(A){this.lines.delete(A.uuid)}getLineByName(A){const e=[];return this.lines.forEach((t,i)=>{t.name===A&&e.push(t)}),e}getLineBySlot(A){const e=[];return this.lines.forEach((t,i)=>{t.slot===A&&e.push(t)}),e}getPath(A){const e=A.end.clone();e.set(e.x-this.offset.x,e.y-this.offset.y);const t=A.start.clone().add(e).multiplyScalar(.5),i=A.start.clone().add(e).multiplyScalar(.7);return`M${A.start.x} ${A.start.y}
|
|
9563
9563
|
C${t.x} ${A.start.y}
|
|
9564
9564
|
${i.x} ${A.end.y}
|
|
9565
9565
|
${e.x} ${e.y}
|