lty-protocol 1.0.35 → 1.0.36

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,4 +1,4 @@
1
- import { defineComponent as y, openBlock as m, createElementBlock as d, renderSlot as I, inject as V, computed as C, createBlock as T, resolveDynamicComponent as P, unref as k, normalizeProps as A, guardReactiveProps as D, Fragment as v, renderList as R, toDisplayString as B, createCommentVNode as K, createVNode as w, normalizeStyle as L } from "vue";
1
+ import { defineComponent as y, openBlock as m, createElementBlock as d, renderSlot as I, inject as V, computed as g, createBlock as T, resolveDynamicComponent as P, unref as k, normalizeProps as A, guardReactiveProps as D, Fragment as v, renderList as R, toDisplayString as B, createCommentVNode as K, createVNode as w, normalizeStyle as L } from "vue";
2
2
  const $ = /* @__PURE__ */ y({
3
3
  name: "MyButton",
4
4
  __name: "MyButton",
@@ -7,17 +7,17 @@ const $ = /* @__PURE__ */ y({
7
7
  const t = e, a = () => {
8
8
  t("click");
9
9
  };
10
- return (s, c) => (m(), d("button", {
10
+ return (r, u) => (m(), d("button", {
11
11
  class: "my-btn",
12
12
  onClick: a
13
13
  }, [
14
- I(s.$slots, "default", {}, void 0, !0)
14
+ I(r.$slots, "default", {}, void 0, !0)
15
15
  ]));
16
16
  }
17
17
  }), U = (n, e) => {
18
18
  const t = n.__vccOpts || n;
19
- for (const [a, s] of e)
20
- t[a] = s;
19
+ for (const [a, r] of e)
20
+ t[a] = r;
21
21
  return t;
22
22
  }, x = /* @__PURE__ */ U($, [["__scopeId", "data-v-c654f959"]]), H = /* @__PURE__ */ y({
23
23
  name: "MyButton",
@@ -27,32 +27,32 @@ const $ = /* @__PURE__ */ y({
27
27
  const t = e, a = () => {
28
28
  t("click");
29
29
  };
30
- return (s, c) => (m(), d("button", {
30
+ return (r, u) => (m(), d("button", {
31
31
  class: "my-btn",
32
32
  onClick: a
33
33
  }, [
34
- I(s.$slots, "default", {}, void 0, !0)
34
+ I(r.$slots, "default", {}, void 0, !0)
35
35
  ]));
36
36
  }
37
- }), te = /* @__PURE__ */ U(H, [["__scopeId", "data-v-1477cfc3"]]), g = /* @__PURE__ */ Symbol("UI_KEY"), O = /* @__PURE__ */ y({
37
+ }), te = /* @__PURE__ */ U(H, [["__scopeId", "data-v-1477cfc3"]]), C = /* @__PURE__ */ Symbol("UI_KEY"), O = /* @__PURE__ */ y({
38
38
  __name: "Input",
39
39
  props: {
40
40
  modelValue: {}
41
41
  },
42
42
  emits: ["update:modelValue"],
43
43
  setup(n, { emit: e }) {
44
- const t = n, a = e, s = V(g);
45
- if (!s || !s.Input)
44
+ const t = n, a = e, r = V(C);
45
+ if (!r || !r.Input)
46
46
  throw new Error("Input not registered");
47
- const c = s.Input, i = c.modelProp ?? "modelValue", r = c.modelEvent ?? "update:modelValue", l = "on" + r.charAt(0).toUpperCase() + r.slice(1), o = C(() => ({
47
+ const u = r.Input, i = u.modelProp ?? "modelValue", s = u.modelEvent ?? "update:modelValue", l = "on" + s.charAt(0).toUpperCase() + s.slice(1), o = g(() => ({
48
48
  [i]: t.modelValue,
49
49
  [l]: (_) => a("update:modelValue", _)
50
- })), f = c.component;
50
+ })), f = u.component;
51
51
  return (_, N) => (m(), T(P(k(f)), A(D(o.value)), null, 16));
52
52
  }
53
53
  }), j = { style: { display: "flex", "align-items": "center" } }, z = {
54
54
  key: 0,
55
- style: { margin: "0 4px" }
55
+ style: { margin: "0 4px", "background-color": "inherit" }
56
56
  }, G = /* @__PURE__ */ y({
57
57
  __name: "IpInput",
58
58
  props: {
@@ -60,39 +60,39 @@ const $ = /* @__PURE__ */ y({
60
60
  },
61
61
  emits: ["update:modelValue"],
62
62
  setup(n, { emit: e }) {
63
- const t = n, a = e, s = C({
63
+ const t = n, a = e, r = g({
64
64
  get: () => {
65
- const r = (t.modelValue || "0.0.0.0").split(":"), l = r[0].split(".");
66
- return r.length > 1 ? [...l, r[1]] : l;
65
+ const s = (t.modelValue || "0.0.0.0").split(":"), l = s[0].split(".");
66
+ return s.length > 1 ? [...l, s[1]] : l;
67
67
  },
68
68
  set: (i) => {
69
69
  if (i.length > 4) {
70
- const r = i.slice(0, 4), l = i[4];
71
- a("update:modelValue", `${r.join(".")}:${l}`);
70
+ const s = i.slice(0, 4), l = i[4];
71
+ a("update:modelValue", `${s.join(".")}:${l}`);
72
72
  } else
73
73
  a("update:modelValue", i.join("."));
74
74
  }
75
- }), c = (i, r) => {
76
- const l = [...s.value];
75
+ }), u = (i, s) => {
76
+ const l = [...r.value];
77
77
  if (i < 4) {
78
- let o = parseInt(r, 10);
78
+ let o = parseInt(s, 10);
79
79
  isNaN(o) && (o = 0), o < 0 && (o = 0), o > 255 && (o = 255), l[i] = o.toString();
80
80
  } else {
81
- let o = parseInt(r, 10);
81
+ let o = parseInt(s, 10);
82
82
  isNaN(o) && (o = 0), o < 0 && (o = 0), o > 65535 && (o = 65535), l[i] = o.toString();
83
83
  }
84
- s.value = l;
84
+ r.value = l;
85
85
  };
86
- return (i, r) => (m(), d("div", j, [
87
- (m(!0), d(v, null, R(s.value, (l, o) => (m(), d(v, { key: o }, [
86
+ return (i, s) => (m(), d("div", j, [
87
+ (m(!0), d(v, null, R(r.value, (l, o) => (m(), d(v, { key: o }, [
88
88
  o > 0 ? (m(), d("span", z, B(o === 4 ? ":" : "."), 1)) : K("", !0),
89
89
  w(O, {
90
90
  "model-value": l,
91
- "onUpdate:modelValue": (f) => c(o, f),
91
+ "onUpdate:modelValue": (f) => u(o, f),
92
92
  style: L({
93
93
  borderLeft: o > 0 ? "none" : "",
94
- borderRight: o < s.value.length - 1 ? "none" : "",
95
- borderRadius: o === 0 ? "4px 0 0 4px" : o === s.value.length - 1 ? "0 4px 4px 0" : "0"
94
+ borderRight: o < r.value.length - 1 ? "none" : "",
95
+ borderRadius: o === 0 ? "4px 0 0 4px" : o === r.value.length - 1 ? "0 4px 4px 0" : "0"
96
96
  })
97
97
  }, null, 8, ["model-value", "onUpdate:modelValue", "style"])
98
98
  ], 64))), 128))
@@ -105,17 +105,17 @@ const $ = /* @__PURE__ */ y({
105
105
  },
106
106
  emits: ["update:modelValue"],
107
107
  setup(n, { emit: e }) {
108
- const t = n, a = e, s = V(g);
109
- if (console.log("inject result:", s), !s || !s.InputNumber)
108
+ const t = n, a = e, r = V(C);
109
+ if (console.log("inject result:", r), !r || !r.InputNumber)
110
110
  throw new Error("InputNumber not registered");
111
- const c = s.InputNumber, i = c.modelProp ?? "modelValue", r = c.modelEvent ?? "update:modelValue", l = "on" + r.charAt(0).toUpperCase() + r.slice(1), o = C(() => ({
111
+ const u = r.InputNumber, i = u.modelProp ?? "modelValue", s = u.modelEvent ?? "update:modelValue", l = "on" + s.charAt(0).toUpperCase() + s.slice(1), o = g(() => ({
112
112
  [i]: t.modelValue,
113
113
  [l]: (_) => a("update:modelValue", _)
114
- })), f = c.component;
114
+ })), f = u.component;
115
115
  return (_, N) => (m(), T(P(k(f)), A(D(o.value)), null, 16));
116
116
  }
117
117
  });
118
- class u {
118
+ class c {
119
119
  id;
120
120
  deviceId;
121
121
  type;
@@ -124,10 +124,10 @@ class u {
124
124
  this.id = e.id, this.deviceId = e.deviceId;
125
125
  }
126
126
  static register(e, t) {
127
- u.registry[e] = t;
127
+ c.registry[e] = t;
128
128
  }
129
129
  static fromPlain(e) {
130
- const t = u.registry[e.type];
130
+ const t = c.registry[e.type];
131
131
  if (!t) throw new Error(`Unsupported protocol type: ${e.type}`);
132
132
  return t.fromPlain(e);
133
133
  }
@@ -135,11 +135,11 @@ class u {
135
135
  class F {
136
136
  static getDefaultConfig(e) {
137
137
  console.log(1231231, e);
138
- const t = e.baseInfo, a = e.configuration, s = e.tab;
138
+ const t = e.baseInfo, a = e.configuration, r = e.tab;
139
139
  return {
140
140
  baseInfo: t,
141
141
  config: a,
142
- tab: s
142
+ tab: r
143
143
  };
144
144
  }
145
145
  }
@@ -149,7 +149,7 @@ const J = "Ethernet", q = [{ key: "name", name: { i18nKey: "name" }, defaultValu
149
149
  tab: Q,
150
150
  configuration: W
151
151
  };
152
- class h extends u {
152
+ class h extends c {
153
153
  type = p.ETHERNET;
154
154
  moduleType = E[p.ETHERNET];
155
155
  baseInfo;
@@ -157,34 +157,34 @@ class h extends u {
157
157
  tab;
158
158
  constructor(e) {
159
159
  super(e);
160
- const { baseInfo: t, config: a, tab: s } = F.getDefaultConfig(X);
161
- this.baseInfo = t, this.config = a, this.tab = s;
160
+ const { baseInfo: t, config: a, tab: r } = F.getDefaultConfig(X);
161
+ this.baseInfo = t, this.config = a, this.tab = r;
162
162
  }
163
163
  static fromPlain(e) {
164
164
  return new h(e);
165
165
  }
166
166
  }
167
- class S extends u {
167
+ class b extends c {
168
168
  type = p.MODBUS_TCP_SERVER;
169
169
  moduleType = E[p.MODBUS_TCP_SERVER];
170
170
  constructor(e) {
171
171
  super(e);
172
172
  }
173
173
  static fromPlain(e) {
174
- return new S(e);
174
+ return new b(e);
175
175
  }
176
176
  }
177
- class b extends u {
177
+ class S extends c {
178
178
  type = p.MODBUS_TCP_CLIENT;
179
179
  moduleType = E[p.MODBUS_TCP_CLIENT];
180
180
  constructor(e) {
181
181
  super(e);
182
182
  }
183
183
  static fromPlain(e) {
184
- return new b(e);
184
+ return new S(e);
185
185
  }
186
186
  }
187
- class M extends u {
187
+ class M extends c {
188
188
  type = p.MODBUS_TCP_SLAVE_DEVICE;
189
189
  moduleType = E[p.MODBUS_TCP_SLAVE_DEVICE];
190
190
  constructor(e) {
@@ -252,11 +252,11 @@ const E = {
252
252
  class ne {
253
253
  map = /* @__PURE__ */ new Map();
254
254
  constructor() {
255
- u.register("Ethernet", h), u.register("ModbusTCPServer", S), u.register("ModbusTCPClient", b), u.register("ModbusTCPSlaveDevice", M);
255
+ c.register("Ethernet", h), c.register("ModbusTCPServer", b), c.register("ModbusTCPClient", S), c.register("ModbusTCPSlaveDevice", M);
256
256
  }
257
257
  init(e) {
258
258
  this.clear(), e.forEach((t) => {
259
- const a = u.fromPlain(t);
259
+ const a = c.fromPlain(t);
260
260
  this.map.set(t.id, a);
261
261
  });
262
262
  }
@@ -281,7 +281,7 @@ class ne {
281
281
  }
282
282
  const Z = [x, O, Y, G], oe = {
283
283
  install(n, e) {
284
- e && n.provide(g, e), Z.forEach((t) => {
284
+ e && n.provide(C, e), Z.forEach((t) => {
285
285
  n.component(t.name, t);
286
286
  });
287
287
  }
@@ -292,14 +292,14 @@ export {
292
292
  O as Input,
293
293
  Y as InputNumber,
294
294
  G as IpInput,
295
- b as ModbusTCPClientProtocolItem,
296
- S as ModbusTCPServerProtocolItem,
295
+ S as ModbusTCPClientProtocolItem,
296
+ b as ModbusTCPServerProtocolItem,
297
297
  M as ModbusTCPSlaveDeviceProtocolItem,
298
298
  x as MyButton,
299
299
  ne as ProtocolCollection,
300
- u as ProtocolItem,
300
+ c as ProtocolItem,
301
301
  p as ProtocolType,
302
- g as UI_KEY,
302
+ C as UI_KEY,
303
303
  oe as default,
304
304
  E as protocolMap
305
305
  };
@@ -1 +1 @@
1
- (function(l,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(l=typeof globalThis<"u"?globalThis:l||self,t(l["lty-protocol"]={},l.Vue))})(this,(function(l,t){"use strict";const V=t.defineComponent({name:"MyButton",__name:"MyButton",emits:["click"],setup(o,{emit:e}){const n=e,s=()=>{n("click")};return(a,m)=>(t.openBlock(),t.createElementBlock("button",{class:"my-btn",onClick:s},[t.renderSlot(a.$slots,"default",{},void 0,!0)]))}}),S=(o,e)=>{const n=o.__vccOpts||o;for(const[s,a]of e)n[s]=a;return n},I=S(V,[["__scopeId","data-v-c654f959"]]),k=S(t.defineComponent({name:"MyButton",__name:"button2",emits:["click"],setup(o,{emit:e}){const n=e,s=()=>{n("click")};return(a,m)=>(t.openBlock(),t.createElementBlock("button",{class:"my-btn",onClick:s},[t.renderSlot(a.$slots,"default",{},void 0,!0)]))}}),[["__scopeId","data-v-1477cfc3"]]),E=Symbol("UI_KEY"),h=t.defineComponent({__name:"Input",props:{modelValue:{}},emits:["update:modelValue"],setup(o,{emit:e}){const n=o,s=e,a=t.inject(E);if(!a||!a.Input)throw new Error("Input not registered");const m=a.Input,i=m.modelProp??"modelValue",c=m.modelEvent??"update:modelValue",u="on"+c.charAt(0).toUpperCase()+c.slice(1),r=t.computed(()=>({[i]:n.modelValue,[u]:y=>s("update:modelValue",y)})),_=m.component;return(y,K)=>(t.openBlock(),t.createBlock(t.resolveDynamicComponent(t.unref(_)),t.normalizeProps(t.guardReactiveProps(r.value)),null,16))}}),B={style:{display:"flex","align-items":"center"}},A={key:0,style:{margin:"0 4px"}},P=t.defineComponent({__name:"IpInput",props:{modelValue:{}},emits:["update:modelValue"],setup(o,{emit:e}){const n=o,s=e,a=t.computed({get:()=>{const c=(n.modelValue||"0.0.0.0").split(":"),u=c[0].split(".");return c.length>1?[...u,c[1]]:u},set:i=>{if(i.length>4){const c=i.slice(0,4),u=i[4];s("update:modelValue",`${c.join(".")}:${u}`)}else s("update:modelValue",i.join("."))}}),m=(i,c)=>{const u=[...a.value];if(i<4){let r=parseInt(c,10);isNaN(r)&&(r=0),r<0&&(r=0),r>255&&(r=255),u[i]=r.toString()}else{let r=parseInt(c,10);isNaN(r)&&(r=0),r<0&&(r=0),r>65535&&(r=65535),u[i]=r.toString()}a.value=u};return(i,c)=>(t.openBlock(),t.createElementBlock("div",B,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(a.value,(u,r)=>(t.openBlock(),t.createElementBlock(t.Fragment,{key:r},[r>0?(t.openBlock(),t.createElementBlock("span",A,t.toDisplayString(r===4?":":"."),1)):t.createCommentVNode("",!0),t.createVNode(h,{"model-value":u,"onUpdate:modelValue":_=>m(r,_),style:t.normalizeStyle({borderLeft:r>0?"none":"",borderRight:r<a.value.length-1?"none":"",borderRadius:r===0?"4px 0 0 4px":r===a.value.length-1?"0 4px 4px 0":"0"})},null,8,["model-value","onUpdate:modelValue","style"])],64))),128))]))}}),T=t.defineComponent({__name:"InputNumber",props:{modelValue:{}},emits:["update:modelValue"],setup(o,{emit:e}){const n=o,s=e,a=t.inject(E);if(console.log("inject result:",a),!a||!a.InputNumber)throw new Error("InputNumber not registered");const m=a.InputNumber,i=m.modelProp??"modelValue",c=m.modelEvent??"update:modelValue",u="on"+c.charAt(0).toUpperCase()+c.slice(1),r=t.computed(()=>({[i]:n.modelValue,[u]:y=>s("update:modelValue",y)})),_=m.component;return(y,K)=>(t.openBlock(),t.createBlock(t.resolveDynamicComponent(t.unref(_)),t.normalizeProps(t.guardReactiveProps(r.value)),null,16))}});class p{id;deviceId;type;static registry={};constructor(e){this.id=e.id,this.deviceId=e.deviceId}static register(e,n){p.registry[e]=n}static fromPlain(e){const n=p.registry[e.type];if(!n)throw new Error(`Unsupported protocol type: ${e.type}`);return n.fromPlain(e)}}class D{static getDefaultConfig(e){console.log(1231231,e);const n=e.baseInfo,s=e.configuration,a=e.tab;return{baseInfo:n,config:s,tab:a}}}const U={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 p{type=d.ETHERNET;moduleType=f[d.ETHERNET];baseInfo;config;tab;constructor(e){super(e);const{baseInfo:n,config:s,tab:a}=D.getDefaultConfig(U);this.baseInfo=n,this.config=s,this.tab=a}static fromPlain(e){return new C(e)}}class g extends p{type=d.MODBUS_TCP_SERVER;moduleType=f[d.MODBUS_TCP_SERVER];constructor(e){super(e)}static fromPlain(e){return new g(e)}}class b extends p{type=d.MODBUS_TCP_CLIENT;moduleType=f[d.MODBUS_TCP_CLIENT];constructor(e){super(e)}static fromPlain(e){return new b(e)}}class M extends p{type=d.MODBUS_TCP_SLAVE_DEVICE;moduleType=f[d.MODBUS_TCP_SLAVE_DEVICE];constructor(e){super(e)}static fromPlain(e){return new M(e)}}var d=(o=>(o.ETHERNET="Ethernet",o.MODBUS_TCP_SERVER="ModbusTCPServer",o.MODBUS_TCP_CLIENT="ModbusTCPClient",o.MODBUS_TCP_SLAVE_DEVICE="ModbusTCPSlaveDevice",o.MODBUS_SERIAL_PORT="ModbusSerialPort",o.MODBUS_MASTER="ModbusMaster",o.MODBUS_SLAVE="ModbusSlave",o.MODBUS_SERIAL="ModbusSerial",o.OPCUA_SERVER="OPCUAServer",o.ETHER_CAT_MASTER="EtherCatMaster",o.ETHER_CAT_SLAVE="EtherCatSlave",o.ETHER_CAT_MODULE="EtherCatModule",o))(d||{});const f={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 O{map=new Map;constructor(){p.register("Ethernet",C),p.register("ModbusTCPServer",g),p.register("ModbusTCPClient",b),p.register("ModbusTCPSlaveDevice",M)}init(e){this.clear(),e.forEach(n=>{const s=p.fromPlain(n);this.map.set(n.id,s)})}build(e){return""}get(e){const n=Array.isArray(e)?e.map(s=>this.map.get(s)).filter(s=>s!==void 0):this.map.get(e);if(Array.isArray(n)&&!n.length||!n)throw new Error(`Protocol ${e} is not found.`);return n}add(e){this.map.set(e.id,e)}delete(e){Array.isArray(e)?e.forEach(n=>this.map.delete(n)):this.map.delete(e)}clear(){this.map.clear()}}const R=[I,h,T,P],N={install(o,e){e&&o.provide(E,e),R.forEach(n=>{o.component(n.name,n)})}};l.Button2=k,l.EthernetProtocolItem=C,l.Input=h,l.InputNumber=T,l.IpInput=P,l.ModbusTCPClientProtocolItem=b,l.ModbusTCPServerProtocolItem=g,l.ModbusTCPSlaveDeviceProtocolItem=M,l.MyButton=I,l.ProtocolCollection=O,l.ProtocolItem=p,l.ProtocolType=d,l.UI_KEY=E,l.default=N,l.protocolMap=f,Object.defineProperties(l,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
1
+ (function(l,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(l=typeof globalThis<"u"?globalThis:l||self,t(l["lty-protocol"]={},l.Vue))})(this,(function(l,t){"use strict";const k=t.defineComponent({name:"MyButton",__name:"MyButton",emits:["click"],setup(o,{emit:e}){const n=e,s=()=>{n("click")};return(a,m)=>(t.openBlock(),t.createElementBlock("button",{class:"my-btn",onClick:s},[t.renderSlot(a.$slots,"default",{},void 0,!0)]))}}),S=(o,e)=>{const n=o.__vccOpts||o;for(const[s,a]of e)n[s]=a;return n},I=S(k,[["__scopeId","data-v-c654f959"]]),V=S(t.defineComponent({name:"MyButton",__name:"button2",emits:["click"],setup(o,{emit:e}){const n=e,s=()=>{n("click")};return(a,m)=>(t.openBlock(),t.createElementBlock("button",{class:"my-btn",onClick:s},[t.renderSlot(a.$slots,"default",{},void 0,!0)]))}}),[["__scopeId","data-v-1477cfc3"]]),E=Symbol("UI_KEY"),M=t.defineComponent({__name:"Input",props:{modelValue:{}},emits:["update:modelValue"],setup(o,{emit:e}){const n=o,s=e,a=t.inject(E);if(!a||!a.Input)throw new Error("Input not registered");const m=a.Input,i=m.modelProp??"modelValue",c=m.modelEvent??"update:modelValue",u="on"+c.charAt(0).toUpperCase()+c.slice(1),r=t.computed(()=>({[i]:n.modelValue,[u]:y=>s("update:modelValue",y)})),_=m.component;return(y,K)=>(t.openBlock(),t.createBlock(t.resolveDynamicComponent(t.unref(_)),t.normalizeProps(t.guardReactiveProps(r.value)),null,16))}}),B={style:{display:"flex","align-items":"center"}},A={key:0,style:{margin:"0 4px","background-color":"inherit"}},P=t.defineComponent({__name:"IpInput",props:{modelValue:{}},emits:["update:modelValue"],setup(o,{emit:e}){const n=o,s=e,a=t.computed({get:()=>{const c=(n.modelValue||"0.0.0.0").split(":"),u=c[0].split(".");return c.length>1?[...u,c[1]]:u},set:i=>{if(i.length>4){const c=i.slice(0,4),u=i[4];s("update:modelValue",`${c.join(".")}:${u}`)}else s("update:modelValue",i.join("."))}}),m=(i,c)=>{const u=[...a.value];if(i<4){let r=parseInt(c,10);isNaN(r)&&(r=0),r<0&&(r=0),r>255&&(r=255),u[i]=r.toString()}else{let r=parseInt(c,10);isNaN(r)&&(r=0),r<0&&(r=0),r>65535&&(r=65535),u[i]=r.toString()}a.value=u};return(i,c)=>(t.openBlock(),t.createElementBlock("div",B,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(a.value,(u,r)=>(t.openBlock(),t.createElementBlock(t.Fragment,{key:r},[r>0?(t.openBlock(),t.createElementBlock("span",A,t.toDisplayString(r===4?":":"."),1)):t.createCommentVNode("",!0),t.createVNode(M,{"model-value":u,"onUpdate:modelValue":_=>m(r,_),style:t.normalizeStyle({borderLeft:r>0?"none":"",borderRight:r<a.value.length-1?"none":"",borderRadius:r===0?"4px 0 0 4px":r===a.value.length-1?"0 4px 4px 0":"0"})},null,8,["model-value","onUpdate:modelValue","style"])],64))),128))]))}}),T=t.defineComponent({__name:"InputNumber",props:{modelValue:{}},emits:["update:modelValue"],setup(o,{emit:e}){const n=o,s=e,a=t.inject(E);if(console.log("inject result:",a),!a||!a.InputNumber)throw new Error("InputNumber not registered");const m=a.InputNumber,i=m.modelProp??"modelValue",c=m.modelEvent??"update:modelValue",u="on"+c.charAt(0).toUpperCase()+c.slice(1),r=t.computed(()=>({[i]:n.modelValue,[u]:y=>s("update:modelValue",y)})),_=m.component;return(y,K)=>(t.openBlock(),t.createBlock(t.resolveDynamicComponent(t.unref(_)),t.normalizeProps(t.guardReactiveProps(r.value)),null,16))}});class p{id;deviceId;type;static registry={};constructor(e){this.id=e.id,this.deviceId=e.deviceId}static register(e,n){p.registry[e]=n}static fromPlain(e){const n=p.registry[e.type];if(!n)throw new Error(`Unsupported protocol type: ${e.type}`);return n.fromPlain(e)}}class D{static getDefaultConfig(e){console.log(1231231,e);const n=e.baseInfo,s=e.configuration,a=e.tab;return{baseInfo:n,config:s,tab:a}}}const U={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 p{type=d.ETHERNET;moduleType=f[d.ETHERNET];baseInfo;config;tab;constructor(e){super(e);const{baseInfo:n,config:s,tab:a}=D.getDefaultConfig(U);this.baseInfo=n,this.config=s,this.tab=a}static fromPlain(e){return new C(e)}}class g extends p{type=d.MODBUS_TCP_SERVER;moduleType=f[d.MODBUS_TCP_SERVER];constructor(e){super(e)}static fromPlain(e){return new g(e)}}class b extends p{type=d.MODBUS_TCP_CLIENT;moduleType=f[d.MODBUS_TCP_CLIENT];constructor(e){super(e)}static fromPlain(e){return new b(e)}}class h extends p{type=d.MODBUS_TCP_SLAVE_DEVICE;moduleType=f[d.MODBUS_TCP_SLAVE_DEVICE];constructor(e){super(e)}static fromPlain(e){return new h(e)}}var d=(o=>(o.ETHERNET="Ethernet",o.MODBUS_TCP_SERVER="ModbusTCPServer",o.MODBUS_TCP_CLIENT="ModbusTCPClient",o.MODBUS_TCP_SLAVE_DEVICE="ModbusTCPSlaveDevice",o.MODBUS_SERIAL_PORT="ModbusSerialPort",o.MODBUS_MASTER="ModbusMaster",o.MODBUS_SLAVE="ModbusSlave",o.MODBUS_SERIAL="ModbusSerial",o.OPCUA_SERVER="OPCUAServer",o.ETHER_CAT_MASTER="EtherCatMaster",o.ETHER_CAT_SLAVE="EtherCatSlave",o.ETHER_CAT_MODULE="EtherCatModule",o))(d||{});const f={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 O{map=new Map;constructor(){p.register("Ethernet",C),p.register("ModbusTCPServer",g),p.register("ModbusTCPClient",b),p.register("ModbusTCPSlaveDevice",h)}init(e){this.clear(),e.forEach(n=>{const s=p.fromPlain(n);this.map.set(n.id,s)})}build(e){return""}get(e){const n=Array.isArray(e)?e.map(s=>this.map.get(s)).filter(s=>s!==void 0):this.map.get(e);if(Array.isArray(n)&&!n.length||!n)throw new Error(`Protocol ${e} is not found.`);return n}add(e){this.map.set(e.id,e)}delete(e){Array.isArray(e)?e.forEach(n=>this.map.delete(n)):this.map.delete(e)}clear(){this.map.clear()}}const R=[I,M,T,P],N={install(o,e){e&&o.provide(E,e),R.forEach(n=>{o.component(n.name,n)})}};l.Button2=V,l.EthernetProtocolItem=C,l.Input=M,l.InputNumber=T,l.IpInput=P,l.ModbusTCPClientProtocolItem=b,l.ModbusTCPServerProtocolItem=g,l.ModbusTCPSlaveDeviceProtocolItem=h,l.MyButton=I,l.ProtocolCollection=O,l.ProtocolItem=p,l.ProtocolType=d,l.UI_KEY=E,l.default=N,l.protocolMap=f,Object.defineProperties(l,{__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.35",
3
+ "version": "1.0.36",
4
4
  "main": "dist/lty-protocol.umd.js",
5
5
  "module": "dist/lty-protocol.mjs",
6
6
  "style": "dist/lty-protocol.css",