lty-protocol 1.0.38 → 1.0.39

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
- .tab-content[data-v-163637c2]{padding:20px}.config-item[data-v-163637c2]{margin-bottom:16px;display:flex;align-items:center}.config-item label[data-v-163637c2]{width:120px;margin-right:16px}.config-item input[data-v-163637c2]{flex:1;padding:8px;border:1px solid #ddd;border-radius:4px}
1
+ .tab-content[data-v-58bcba54]{padding:20px}.config-item[data-v-58bcba54]{margin-bottom:16px;display:flex;align-items:center}.config-item label[data-v-58bcba54]{width:120px;margin-right:16px}.config-item input[data-v-58bcba54]{flex:1;padding:8px;border:1px solid #ddd;border-radius:4px}
@@ -1,5 +1,5 @@
1
- import { defineComponent as b, inject as k, computed as S, openBlock as p, createBlock as E, resolveDynamicComponent as g, unref as v, normalizeProps as A, guardReactiveProps as D, createElementBlock as m, Fragment as _, renderList as V, toDisplayString as B, createCommentVNode as H, createVNode as L, normalizeStyle as j, withCtx as P, renderSlot as R, ref as K, createElementVNode as F } from "vue";
2
- const T = /* @__PURE__ */ Symbol("UI_KEY"), $ = /* @__PURE__ */ b({
1
+ import { defineComponent as C, inject as k, computed as S, openBlock as p, createBlock as g, resolveDynamicComponent as b, unref as v, normalizeProps as A, guardReactiveProps as D, createElementBlock as m, Fragment as _, renderList as V, toDisplayString as B, createCommentVNode as x, createVNode as L, normalizeStyle as j, withCtx as P, renderSlot as R, ref as K, createElementVNode as F } from "vue";
2
+ const T = /* @__PURE__ */ Symbol("UI_KEY"), $ = /* @__PURE__ */ C({
3
3
  __name: "Input",
4
4
  props: {
5
5
  modelValue: {}
@@ -13,12 +13,12 @@ const T = /* @__PURE__ */ Symbol("UI_KEY"), $ = /* @__PURE__ */ b({
13
13
  [u]: n.modelValue,
14
14
  [l]: (f) => s("update:modelValue", f)
15
15
  })), i = c.component;
16
- return (f, M) => (p(), E(g(v(i)), A(D(t.value)), null, 16));
16
+ return (f, M) => (p(), g(b(v(i)), A(D(t.value)), null, 16));
17
17
  }
18
18
  }), z = { style: { display: "flex", "align-items": "center" } }, G = {
19
19
  key: 0,
20
20
  style: { margin: "0 4px", "background-color": "inherit" }
21
- }, x = /* @__PURE__ */ b({
21
+ }, H = /* @__PURE__ */ C({
22
22
  __name: "IpInput",
23
23
  props: {
24
24
  modelValue: {}
@@ -50,7 +50,7 @@ const T = /* @__PURE__ */ Symbol("UI_KEY"), $ = /* @__PURE__ */ b({
50
50
  };
51
51
  return (u, r) => (p(), m("div", z, [
52
52
  (p(!0), m(_, null, V(o.value, (l, t) => (p(), m(_, { key: t }, [
53
- t > 0 ? (p(), m("span", G, B(t === 4 ? ":" : "."), 1)) : H("", !0),
53
+ t > 0 ? (p(), m("span", G, B(t === 4 ? ":" : "."), 1)) : x("", !0),
54
54
  L($, {
55
55
  "model-value": l,
56
56
  "onUpdate:modelValue": (i) => c(t, i),
@@ -63,7 +63,7 @@ const T = /* @__PURE__ */ Symbol("UI_KEY"), $ = /* @__PURE__ */ b({
63
63
  ], 64))), 128))
64
64
  ]));
65
65
  }
66
- }), Y = /* @__PURE__ */ b({
66
+ }), Y = /* @__PURE__ */ C({
67
67
  __name: "InputNumber",
68
68
  props: {
69
69
  modelValue: {}
@@ -77,9 +77,9 @@ const T = /* @__PURE__ */ Symbol("UI_KEY"), $ = /* @__PURE__ */ b({
77
77
  [u]: n.modelValue,
78
78
  [l]: (f) => s("update:modelValue", f)
79
79
  })), i = c.component;
80
- return (f, M) => (p(), E(g(v(i)), A(D(t.value)), null, 16));
80
+ return (f, M) => (p(), g(b(v(i)), A(D(t.value)), null, 16));
81
81
  }
82
- }), J = /* @__PURE__ */ b({
82
+ }), J = /* @__PURE__ */ C({
83
83
  __name: "Tab",
84
84
  props: {
85
85
  modelValue: {},
@@ -94,26 +94,26 @@ const T = /* @__PURE__ */ Symbol("UI_KEY"), $ = /* @__PURE__ */ b({
94
94
  throw new Error("TabItem not registered");
95
95
  const c = o.Tab, u = o.TabItem, r = c.modelProp ?? "modelValue", l = c.modelEvent ?? "update:modelValue", t = "on" + l.charAt(0).toUpperCase() + l.slice(1), i = S(() => ({
96
96
  [r]: n.modelValue,
97
- [t]: (C) => s("update:modelValue", C)
97
+ [t]: (E) => s("update:modelValue", E)
98
98
  })), f = c.component, M = u.component;
99
- return (C, re) => (p(), E(g(v(f)), A(D(i.value)), {
99
+ return (E, re) => (p(), g(b(v(f)), A(D(i.value)), {
100
100
  default: P(() => [
101
- (p(!0), m(_, null, V(a.tabs, (h) => (p(), E(g(v(M)), {
101
+ (p(!0), m(_, null, V(a.tabs, (h) => (p(), g(b(v(M)), {
102
102
  key: h.key,
103
- label: h.name.i18nKey,
103
+ label: E.$t(h.name.i18nKey),
104
104
  name: h.key
105
105
  }, {
106
106
  default: P(() => [
107
- R(C.$slots, h.key)
107
+ R(E.$slots, h.key)
108
108
  ]),
109
109
  _: 2
110
110
  }, 1032, ["label", "name"]))), 128)),
111
- R(C.$slots, "default")
111
+ R(E.$slots, "default")
112
112
  ]),
113
113
  _: 3
114
114
  }, 16));
115
115
  }
116
- }), q = /* @__PURE__ */ b({
116
+ }), q = /* @__PURE__ */ C({
117
117
  __name: "Ethernet",
118
118
  props: {
119
119
  data: {}
@@ -127,7 +127,7 @@ const T = /* @__PURE__ */ Symbol("UI_KEY"), $ = /* @__PURE__ */ b({
127
127
  s.value[i.key] = i.defaultValue;
128
128
  });
129
129
  })();
130
- const c = (r) => e.data.config[r] || [], u = (r) => r === "ipInput" ? x : "input";
130
+ const c = (r) => e.data.config[r] || [], u = (r) => r === "ipInput" ? H : "input";
131
131
  return (r, l) => (p(), m("div", null, [
132
132
  L(J, {
133
133
  modelValue: n.value,
@@ -143,8 +143,8 @@ const T = /* @__PURE__ */ Symbol("UI_KEY"), $ = /* @__PURE__ */ b({
143
143
  key: i.key,
144
144
  class: "config-item"
145
145
  }, [
146
- F("label", null, B(i.name.i18nKey), 1),
147
- (p(), E(g(u(i.componentType)), {
146
+ F("label", null, B(r.$t(i.name.i18nKey)), 1),
147
+ (p(), g(b(u(i.componentType)), {
148
148
  modelValue: s.value[i.key],
149
149
  "onUpdate:modelValue": (f) => s.value[i.key] = f
150
150
  }, null, 8, ["modelValue", "onUpdate:modelValue"]))
@@ -160,7 +160,7 @@ const T = /* @__PURE__ */ Symbol("UI_KEY"), $ = /* @__PURE__ */ b({
160
160
  for (const [s, o] of e)
161
161
  n[s] = o;
162
162
  return n;
163
- }, W = /* @__PURE__ */ Q(q, [["__scopeId", "data-v-163637c2"]]);
163
+ }, W = /* @__PURE__ */ Q(q, [["__scopeId", "data-v-58bcba54"]]);
164
164
  class d {
165
165
  id;
166
166
  deviceId;
@@ -325,7 +325,7 @@ class le {
325
325
  this.map.clear();
326
326
  }
327
327
  }
328
- const oe = [$, Y, x, W], ue = {
328
+ const oe = [$, Y, H, W], ue = {
329
329
  install(a, e) {
330
330
  e && a.provide(T, e), oe.forEach((n) => {
331
331
  a.component(n.name, n);
@@ -337,7 +337,7 @@ export {
337
337
  U as EthernetProtocolItem,
338
338
  $ as Input,
339
339
  Y as InputNumber,
340
- x as IpInput,
340
+ H as IpInput,
341
341
  O as ModbusTCPClientProtocolItem,
342
342
  N as ModbusTCPServerProtocolItem,
343
343
  w as ModbusTCPSlaveDeviceProtocolItem,
@@ -1 +1 @@
1
- (function(i,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(i=typeof globalThis<"u"?globalThis:i||self,e(i["lty-protocol"]={},i.Vue))})(this,(function(i,e){"use strict";const E=Symbol("UI_KEY"),S=e.defineComponent({__name:"Input",props:{modelValue:{}},emits:["update:modelValue"],setup(a,{emit:t}){const o=a,s=t,r=e.inject(E);if(!r||!r.Input)throw new Error("Input not registered");const d=r.Input,p=d.modelProp??"modelValue",l=d.modelEvent??"update:modelValue",c="on"+l.charAt(0).toUpperCase()+l.slice(1),n=e.computed(()=>({[p]:o.modelValue,[c]:y=>s("update:modelValue",y)})),m=d.component;return(y,I)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(m)),e.normalizeProps(e.guardReactiveProps(n.value)),null,16))}}),B={style:{display:"flex","align-items":"center"}},D={key:0,style:{margin:"0 4px","background-color":"inherit"}},V=e.defineComponent({__name:"IpInput",props:{modelValue:{}},emits:["update:modelValue"],setup(a,{emit:t}){const o=a,s=t,r=e.computed({get:()=>{const l=(o.modelValue||"0.0.0.0").split(":"),c=l[0].split(".");return l.length>1?[...c,l[1]]:c},set:p=>{if(p.length>4){const l=p.slice(0,4),c=p[4];s("update:modelValue",`${l.join(".")}:${c}`)}else s("update:modelValue",p.join("."))}}),d=(p,l)=>{const c=[...r.value];if(p<4){let n=parseInt(l,10);isNaN(n)&&(n=0),n<0&&(n=0),n>255&&(n=255),c[p]=n.toString()}else{let n=parseInt(l,10);isNaN(n)&&(n=0),n<0&&(n=0),n>65535&&(n=65535),c[p]=n.toString()}r.value=c};return(p,l)=>(e.openBlock(),e.createElementBlock("div",B,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(c,n)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:n},[n>0?(e.openBlock(),e.createElementBlock("span",D,e.toDisplayString(n===4?":":"."),1)):e.createCommentVNode("",!0),e.createVNode(S,{"model-value":c,"onUpdate:modelValue":m=>d(n,m),style:e.normalizeStyle({borderLeft:n>0?"none":"",borderRight:n<r.value.length-1?"none":"",borderRadius:n===0?"4px 0 0 4px":n===r.value.length-1?"0 4px 4px 0":"0"})},null,8,["model-value","onUpdate:modelValue","style"])],64))),128))]))}}),P=e.defineComponent({__name:"InputNumber",props:{modelValue:{}},emits:["update:modelValue"],setup(a,{emit:t}){const o=a,s=t,r=e.inject(E);if(console.log("inject result:",r),!r||!r.InputNumber)throw new Error("InputNumber not registered");const d=r.InputNumber,p=d.modelProp??"modelValue",l=d.modelEvent??"update:modelValue",c="on"+l.charAt(0).toUpperCase()+l.slice(1),n=e.computed(()=>({[p]:o.modelValue,[c]:y=>s("update:modelValue",y)})),m=d.component;return(y,I)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(m)),e.normalizeProps(e.guardReactiveProps(n.value)),null,16))}}),A=e.defineComponent({__name:"Tab",props:{modelValue:{},tabs:{}},emits:["update:modelValue"],setup(a,{emit:t}){const o=a,s=t,r=e.inject(E);if(!r||!r.Tab)throw new Error("Tab not registered");if(!r||!r.TabItem)throw new Error("TabItem not registered");const d=r.Tab,p=r.TabItem,l=d.modelProp??"modelValue",c=d.modelEvent??"update:modelValue",n="on"+c.charAt(0).toUpperCase()+c.slice(1),m=e.computed(()=>({[l]:o.modelValue,[n]:k=>s("update:modelValue",k)})),y=d.component,I=p.component;return(k,z)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(y)),e.normalizeProps(e.guardReactiveProps(m.value)),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.tabs,T=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(I)),{key:T.key,label:T.name.i18nKey,name:T.key},{default:e.withCtx(()=>[e.renderSlot(k.$slots,T.key)]),_:2},1032,["label","name"]))),128)),e.renderSlot(k.$slots,"default")]),_:3},16))}}),M=((a,t)=>{const o=a.__vccOpts||a;for(const[s,r]of t)o[s]=r;return o})(e.defineComponent({__name:"Ethernet",props:{data:{}},setup(a){const t=a,o=e.ref(t.data.tab[0]?.key||""),s=e.ref({});(()=>{const l=t.data.config;for(const c in l)l[c].forEach(m=>{s.value[m.key]=m.defaultValue})})();const d=l=>t.data.config[l]||[],p=l=>l==="ipInput"?V:"input";return(l,c)=>(e.openBlock(),e.createElementBlock("div",null,[e.createVNode(A,{modelValue:o.value,"onUpdate:modelValue":c[0]||(c[0]=n=>o.value=n),tabs:a.data.tab},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.data.tab,n=>(e.openBlock(),e.createElementBlock("div",{key:n.key,class:"tab-content"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d(n.key),m=>(e.openBlock(),e.createElementBlock("div",{key:m.key,class:"config-item"},[e.createElementVNode("label",null,e.toDisplayString(m.name.i18nKey),1),(e.openBlock(),e.createBlock(e.resolveDynamicComponent(p(m.componentType)),{modelValue:s.value[m.key],"onUpdate:modelValue":y=>s.value[m.key]=y},null,8,["modelValue","onUpdate:modelValue"]))]))),128))]))),128))]),_:1},8,["modelValue","tabs"])]))}}),[["__scopeId","data-v-163637c2"]]);class u{id;deviceId;type;static registry={};constructor(t){this.id=t.id,this.deviceId=t.deviceId}static register(t,o){u.registry[t]=o}static fromPlain(t){const o=u.registry[t.type];if(!o)throw new Error(`Unsupported protocol type: ${t.type}`);return o.fromPlain(t)}}class U{static getDefaultConfig(t){console.log(1231231,t);const o=t.baseInfo,s=t.configuration,r=t.tab;return{baseInfo:o,config:s,tab:r}}}const N={type:"Ethernet",baseInfo:[{key:"name",name:{i18nKey:"name"},defaultValue:"Ethernet"},{key:"supplier",name:{i18nKey:"supplier"},defaultValue:{i18nKey:"company"}},{key:"version",name:{i18nKey:"verison"},defaultValue:"1.0.0.0"},{key:"description",name:{i18nKey:"description"},defaultValue:{i18nKey:"descriptionMap.ethernet"}},{key:"category",name:{i18nKey:"category"},defaultValue:{i18nKey:"ethernet"}}],tab:[{name:{i18nKey:"general"},key:"general"},{name:{i18nKey:"ioMapping"},key:"ioMapping"}],configuration:{general:[{key:"netInterface",name:{i18nKey:"netInterface"},dataType:"string",componentType:"strInput",defaultValue:""},{key:"ipAddress",name:{i18nKey:"ipAddress"},dataType:"string",componentType:"ipInput",defaultValue:"192.168.1.1"},{key:"subnetMask",name:{i18nKey:"subnetMask"},dataType:"string",componentType:"ipInput",defaultValue:"255.255.255.0"},{key:"defaultGateway",name:{i18nKey:"defaultGateway"},dataType:"string",componentType:"ipInput",defaultValue:"0.0.0.0"},{key:"adaptedOSConfiguration",name:{i18nKey:"adaptedOSConfiguration"},dataType:"boolean",componentType:"switch",defaultValue:!1}],ioMapping:[{key:"busCycleTask",name:{i18nKey:"busCycleTask"},dataType:"string",componentType:"select",defaultValue:"-1"}]}};class C extends u{type=f.ETHERNET;moduleType=g[f.ETHERNET];baseInfo;config;tab;constructor(t){super(t);const{baseInfo:o,config:s,tab:r}=U.getDefaultConfig(N);this.baseInfo=o,this.config=s,this.tab=r}static fromPlain(t){return new C(t)}}class _ extends u{type=f.MODBUS_TCP_SERVER;moduleType=g[f.MODBUS_TCP_SERVER];constructor(t){super(t)}static fromPlain(t){return new _(t)}}class b extends u{type=f.MODBUS_TCP_CLIENT;moduleType=g[f.MODBUS_TCP_CLIENT];constructor(t){super(t)}static fromPlain(t){return new b(t)}}class h extends u{type=f.MODBUS_TCP_SLAVE_DEVICE;moduleType=g[f.MODBUS_TCP_SLAVE_DEVICE];constructor(t){super(t)}static fromPlain(t){return new h(t)}}var f=(a=>(a.ETHERNET="Ethernet",a.MODBUS_TCP_SERVER="ModbusTCPServer",a.MODBUS_TCP_CLIENT="ModbusTCPClient",a.MODBUS_TCP_SLAVE_DEVICE="ModbusTCPSlaveDevice",a.MODBUS_SERIAL_PORT="ModbusSerialPort",a.MODBUS_MASTER="ModbusMaster",a.MODBUS_SLAVE="ModbusSlave",a.MODBUS_SERIAL="ModbusSerial",a.OPCUA_SERVER="OPCUAServer",a.ETHER_CAT_MASTER="EtherCatMaster",a.ETHER_CAT_SLAVE="EtherCatSlave",a.ETHER_CAT_MODULE="EtherCatModule",a))(f||{});const g={Pprogrammable:4096,Protgrammable_Safety:4098,CAN_Master:16,CAN_Slave:17,CAN_Device:18,EtherCat_Master:64,EtherCat_Slave:65,ProfinetIO_Master:80,ProfinetIO_Device:81,EthernetIP_Scanner:100,EthernetIP_Adapter:101,Ethernet:110,ModbusTCPServer:88,ModbusTCPClient:89,ModbusTCPSlaveDevice:115,ModbusSerialPort:92,ModbusMaster:90,ModbusSlave:91,ModbusSerial:94,OPCUAServer:128,EtherCatMaster:64,EtherCatSlave:16384,EtherCatModule:16384};class w{map=new Map;constructor(){u.register("Ethernet",C),u.register("ModbusTCPServer",_),u.register("ModbusTCPClient",b),u.register("ModbusTCPSlaveDevice",h)}init(t){this.clear(),t.forEach(o=>{const s=u.fromPlain(o);this.map.set(o.id,s)})}build(t){return""}get(t){const o=Array.isArray(t)?t.map(s=>this.map.get(s)).filter(s=>s!==void 0):this.map.get(t);if(Array.isArray(o)&&!o.length||!o)throw new Error(`Protocol ${t} is not found.`);return o}add(t){this.map.set(t.id,t)}delete(t){Array.isArray(t)?t.forEach(o=>this.map.delete(o)):this.map.delete(t)}clear(){this.map.clear()}}const O=[S,P,V,M],R={install(a,t){t&&a.provide(E,t),O.forEach(o=>{a.component(o.name,o)})}};i.Ethernet=M,i.EthernetProtocolItem=C,i.Input=S,i.InputNumber=P,i.IpInput=V,i.ModbusTCPClientProtocolItem=b,i.ModbusTCPServerProtocolItem=_,i.ModbusTCPSlaveDeviceProtocolItem=h,i.ProtocolCollection=w,i.ProtocolItem=u,i.ProtocolType=f,i.UI_KEY=E,i.default=R,i.protocolMap=g,Object.defineProperties(i,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
1
+ (function(i,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(i=typeof globalThis<"u"?globalThis:i||self,e(i["lty-protocol"]={},i.Vue))})(this,(function(i,e){"use strict";const E=Symbol("UI_KEY"),S=e.defineComponent({__name:"Input",props:{modelValue:{}},emits:["update:modelValue"],setup(a,{emit:t}){const o=a,s=t,r=e.inject(E);if(!r||!r.Input)throw new Error("Input not registered");const d=r.Input,p=d.modelProp??"modelValue",l=d.modelEvent??"update:modelValue",c="on"+l.charAt(0).toUpperCase()+l.slice(1),n=e.computed(()=>({[p]:o.modelValue,[c]:y=>s("update:modelValue",y)})),m=d.component;return(y,I)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(m)),e.normalizeProps(e.guardReactiveProps(n.value)),null,16))}}),B={style:{display:"flex","align-items":"center"}},D={key:0,style:{margin:"0 4px","background-color":"inherit"}},V=e.defineComponent({__name:"IpInput",props:{modelValue:{}},emits:["update:modelValue"],setup(a,{emit:t}){const o=a,s=t,r=e.computed({get:()=>{const l=(o.modelValue||"0.0.0.0").split(":"),c=l[0].split(".");return l.length>1?[...c,l[1]]:c},set:p=>{if(p.length>4){const l=p.slice(0,4),c=p[4];s("update:modelValue",`${l.join(".")}:${c}`)}else s("update:modelValue",p.join("."))}}),d=(p,l)=>{const c=[...r.value];if(p<4){let n=parseInt(l,10);isNaN(n)&&(n=0),n<0&&(n=0),n>255&&(n=255),c[p]=n.toString()}else{let n=parseInt(l,10);isNaN(n)&&(n=0),n<0&&(n=0),n>65535&&(n=65535),c[p]=n.toString()}r.value=c};return(p,l)=>(e.openBlock(),e.createElementBlock("div",B,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(c,n)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:n},[n>0?(e.openBlock(),e.createElementBlock("span",D,e.toDisplayString(n===4?":":"."),1)):e.createCommentVNode("",!0),e.createVNode(S,{"model-value":c,"onUpdate:modelValue":m=>d(n,m),style:e.normalizeStyle({borderLeft:n>0?"none":"",borderRight:n<r.value.length-1?"none":"",borderRadius:n===0?"4px 0 0 4px":n===r.value.length-1?"0 4px 4px 0":"0"})},null,8,["model-value","onUpdate:modelValue","style"])],64))),128))]))}}),P=e.defineComponent({__name:"InputNumber",props:{modelValue:{}},emits:["update:modelValue"],setup(a,{emit:t}){const o=a,s=t,r=e.inject(E);if(console.log("inject result:",r),!r||!r.InputNumber)throw new Error("InputNumber not registered");const d=r.InputNumber,p=d.modelProp??"modelValue",l=d.modelEvent??"update:modelValue",c="on"+l.charAt(0).toUpperCase()+l.slice(1),n=e.computed(()=>({[p]:o.modelValue,[c]:y=>s("update:modelValue",y)})),m=d.component;return(y,I)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(m)),e.normalizeProps(e.guardReactiveProps(n.value)),null,16))}}),A=e.defineComponent({__name:"Tab",props:{modelValue:{},tabs:{}},emits:["update:modelValue"],setup(a,{emit:t}){const o=a,s=t,r=e.inject(E);if(!r||!r.Tab)throw new Error("Tab not registered");if(!r||!r.TabItem)throw new Error("TabItem not registered");const d=r.Tab,p=r.TabItem,l=d.modelProp??"modelValue",c=d.modelEvent??"update:modelValue",n="on"+c.charAt(0).toUpperCase()+c.slice(1),m=e.computed(()=>({[l]:o.modelValue,[n]:C=>s("update:modelValue",C)})),y=d.component,I=p.component;return(C,z)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(y)),e.normalizeProps(e.guardReactiveProps(m.value)),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.tabs,T=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(I)),{key:T.key,label:C.$t(T.name.i18nKey),name:T.key},{default:e.withCtx(()=>[e.renderSlot(C.$slots,T.key)]),_:2},1032,["label","name"]))),128)),e.renderSlot(C.$slots,"default")]),_:3},16))}}),M=((a,t)=>{const o=a.__vccOpts||a;for(const[s,r]of t)o[s]=r;return o})(e.defineComponent({__name:"Ethernet",props:{data:{}},setup(a){const t=a,o=e.ref(t.data.tab[0]?.key||""),s=e.ref({});(()=>{const l=t.data.config;for(const c in l)l[c].forEach(m=>{s.value[m.key]=m.defaultValue})})();const d=l=>t.data.config[l]||[],p=l=>l==="ipInput"?V:"input";return(l,c)=>(e.openBlock(),e.createElementBlock("div",null,[e.createVNode(A,{modelValue:o.value,"onUpdate:modelValue":c[0]||(c[0]=n=>o.value=n),tabs:a.data.tab},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.data.tab,n=>(e.openBlock(),e.createElementBlock("div",{key:n.key,class:"tab-content"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d(n.key),m=>(e.openBlock(),e.createElementBlock("div",{key:m.key,class:"config-item"},[e.createElementVNode("label",null,e.toDisplayString(l.$t(m.name.i18nKey)),1),(e.openBlock(),e.createBlock(e.resolveDynamicComponent(p(m.componentType)),{modelValue:s.value[m.key],"onUpdate:modelValue":y=>s.value[m.key]=y},null,8,["modelValue","onUpdate:modelValue"]))]))),128))]))),128))]),_:1},8,["modelValue","tabs"])]))}}),[["__scopeId","data-v-58bcba54"]]);class u{id;deviceId;type;static registry={};constructor(t){this.id=t.id,this.deviceId=t.deviceId}static register(t,o){u.registry[t]=o}static fromPlain(t){const o=u.registry[t.type];if(!o)throw new Error(`Unsupported protocol type: ${t.type}`);return o.fromPlain(t)}}class U{static getDefaultConfig(t){console.log(1231231,t);const o=t.baseInfo,s=t.configuration,r=t.tab;return{baseInfo:o,config:s,tab:r}}}const N={type:"Ethernet",baseInfo:[{key:"name",name:{i18nKey:"name"},defaultValue:"Ethernet"},{key:"supplier",name:{i18nKey:"supplier"},defaultValue:{i18nKey:"company"}},{key:"version",name:{i18nKey:"verison"},defaultValue:"1.0.0.0"},{key:"description",name:{i18nKey:"description"},defaultValue:{i18nKey:"descriptionMap.ethernet"}},{key:"category",name:{i18nKey:"category"},defaultValue:{i18nKey:"ethernet"}}],tab:[{name:{i18nKey:"general"},key:"general"},{name:{i18nKey:"ioMapping"},key:"ioMapping"}],configuration:{general:[{key:"netInterface",name:{i18nKey:"netInterface"},dataType:"string",componentType:"strInput",defaultValue:""},{key:"ipAddress",name:{i18nKey:"ipAddress"},dataType:"string",componentType:"ipInput",defaultValue:"192.168.1.1"},{key:"subnetMask",name:{i18nKey:"subnetMask"},dataType:"string",componentType:"ipInput",defaultValue:"255.255.255.0"},{key:"defaultGateway",name:{i18nKey:"defaultGateway"},dataType:"string",componentType:"ipInput",defaultValue:"0.0.0.0"},{key:"adaptedOSConfiguration",name:{i18nKey:"adaptedOSConfiguration"},dataType:"boolean",componentType:"switch",defaultValue:!1}],ioMapping:[{key:"busCycleTask",name:{i18nKey:"busCycleTask"},dataType:"string",componentType:"select",defaultValue:"-1"}]}};class b extends u{type=f.ETHERNET;moduleType=g[f.ETHERNET];baseInfo;config;tab;constructor(t){super(t);const{baseInfo:o,config:s,tab:r}=U.getDefaultConfig(N);this.baseInfo=o,this.config=s,this.tab=r}static fromPlain(t){return new b(t)}}class _ extends u{type=f.MODBUS_TCP_SERVER;moduleType=g[f.MODBUS_TCP_SERVER];constructor(t){super(t)}static fromPlain(t){return new _(t)}}class h extends u{type=f.MODBUS_TCP_CLIENT;moduleType=g[f.MODBUS_TCP_CLIENT];constructor(t){super(t)}static fromPlain(t){return new h(t)}}class k extends u{type=f.MODBUS_TCP_SLAVE_DEVICE;moduleType=g[f.MODBUS_TCP_SLAVE_DEVICE];constructor(t){super(t)}static fromPlain(t){return new k(t)}}var f=(a=>(a.ETHERNET="Ethernet",a.MODBUS_TCP_SERVER="ModbusTCPServer",a.MODBUS_TCP_CLIENT="ModbusTCPClient",a.MODBUS_TCP_SLAVE_DEVICE="ModbusTCPSlaveDevice",a.MODBUS_SERIAL_PORT="ModbusSerialPort",a.MODBUS_MASTER="ModbusMaster",a.MODBUS_SLAVE="ModbusSlave",a.MODBUS_SERIAL="ModbusSerial",a.OPCUA_SERVER="OPCUAServer",a.ETHER_CAT_MASTER="EtherCatMaster",a.ETHER_CAT_SLAVE="EtherCatSlave",a.ETHER_CAT_MODULE="EtherCatModule",a))(f||{});const g={Pprogrammable:4096,Protgrammable_Safety:4098,CAN_Master:16,CAN_Slave:17,CAN_Device:18,EtherCat_Master:64,EtherCat_Slave:65,ProfinetIO_Master:80,ProfinetIO_Device:81,EthernetIP_Scanner:100,EthernetIP_Adapter:101,Ethernet:110,ModbusTCPServer:88,ModbusTCPClient:89,ModbusTCPSlaveDevice:115,ModbusSerialPort:92,ModbusMaster:90,ModbusSlave:91,ModbusSerial:94,OPCUAServer:128,EtherCatMaster:64,EtherCatSlave:16384,EtherCatModule:16384};class w{map=new Map;constructor(){u.register("Ethernet",b),u.register("ModbusTCPServer",_),u.register("ModbusTCPClient",h),u.register("ModbusTCPSlaveDevice",k)}init(t){this.clear(),t.forEach(o=>{const s=u.fromPlain(o);this.map.set(o.id,s)})}build(t){return""}get(t){const o=Array.isArray(t)?t.map(s=>this.map.get(s)).filter(s=>s!==void 0):this.map.get(t);if(Array.isArray(o)&&!o.length||!o)throw new Error(`Protocol ${t} is not found.`);return o}add(t){this.map.set(t.id,t)}delete(t){Array.isArray(t)?t.forEach(o=>this.map.delete(o)):this.map.delete(t)}clear(){this.map.clear()}}const O=[S,P,V,M],R={install(a,t){t&&a.provide(E,t),O.forEach(o=>{a.component(o.name,o)})}};i.Ethernet=M,i.EthernetProtocolItem=b,i.Input=S,i.InputNumber=P,i.IpInput=V,i.ModbusTCPClientProtocolItem=h,i.ModbusTCPServerProtocolItem=_,i.ModbusTCPSlaveDeviceProtocolItem=k,i.ProtocolCollection=w,i.ProtocolItem=u,i.ProtocolType=f,i.UI_KEY=E,i.default=R,i.protocolMap=g,Object.defineProperties(i,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lty-protocol",
3
- "version": "1.0.38",
3
+ "version": "1.0.39",
4
4
  "main": "dist/lty-protocol.umd.js",
5
5
  "module": "dist/lty-protocol.mjs",
6
6
  "style": "dist/lty-protocol.css",