lty-protocol 1.0.33 → 1.0.34

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,5 +1,5 @@
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";
2
- const $ = /* @__PURE__ */ y({
1
+ import { defineComponent as f, openBlock as p, createElementBlock as y, renderSlot as I, inject as T, computed as C, createBlock as M, resolveDynamicComponent as V, unref as P, normalizeProps as k, guardReactiveProps as A, Fragment as B, renderList as R } from "vue";
2
+ const K = /* @__PURE__ */ f({
3
3
  name: "MyButton",
4
4
  __name: "MyButton",
5
5
  emits: ["click"],
@@ -7,19 +7,19 @@ const $ = /* @__PURE__ */ y({
7
7
  const t = e, a = () => {
8
8
  t("click");
9
9
  };
10
- return (s, c) => (m(), d("button", {
10
+ return (o, r) => (p(), y("button", {
11
11
  class: "my-btn",
12
12
  onClick: a
13
13
  }, [
14
- I(s.$slots, "default", {}, void 0, !0)
14
+ I(o.$slots, "default", {}, void 0, !0)
15
15
  ]));
16
16
  }
17
- }), U = (n, e) => {
17
+ }), D = (n, e) => {
18
18
  const t = n.__vccOpts || n;
19
- for (const [a, s] of e)
20
- t[a] = s;
19
+ for (const [a, o] of e)
20
+ t[a] = o;
21
21
  return t;
22
- }, x = /* @__PURE__ */ U($, [["__scopeId", "data-v-c654f959"]]), H = /* @__PURE__ */ y({
22
+ }, w = /* @__PURE__ */ D(K, [["__scopeId", "data-v-c654f959"]]), N = /* @__PURE__ */ f({
23
23
  name: "MyButton",
24
24
  __name: "button2",
25
25
  emits: ["click"],
@@ -27,95 +27,69 @@ const $ = /* @__PURE__ */ y({
27
27
  const t = e, a = () => {
28
28
  t("click");
29
29
  };
30
- return (s, c) => (m(), d("button", {
30
+ return (o, r) => (p(), y("button", {
31
31
  class: "my-btn",
32
32
  onClick: a
33
33
  }, [
34
- I(s.$slots, "default", {}, void 0, !0)
34
+ I(o.$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
+ }), Q = /* @__PURE__ */ D(N, [["__scopeId", "data-v-1477cfc3"]]), g = /* @__PURE__ */ Symbol("UI_KEY"), U = /* @__PURE__ */ f({
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, o = T(g);
45
+ if (!o || !o.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(() => ({
48
- [i]: t.modelValue,
49
- [l]: (_) => a("update:modelValue", _)
50
- })), f = c.component;
51
- return (_, N) => (m(), T(P(k(f)), A(D(o.value)), null, 16));
47
+ const r = o.Input, l = r.modelProp ?? "modelValue", c = r.modelEvent ?? "update:modelValue", u = "on" + c.charAt(0).toUpperCase() + c.slice(1), d = C(() => ({
48
+ [l]: t.modelValue,
49
+ [u]: (_) => a("update:modelValue", _)
50
+ })), m = r.component;
51
+ return (_, O) => (p(), M(V(P(m)), k(A(d.value)), null, 16));
52
52
  }
53
- }), j = { style: { display: "flex", "align-items": "center" } }, z = {
54
- key: 0,
55
- style: { margin: "0 4px" }
56
- }, G = /* @__PURE__ */ y({
53
+ }), L = { style: { display: "flex", gap: "6px" } }, x = /* @__PURE__ */ f({
57
54
  __name: "IpInput",
58
55
  props: {
59
56
  modelValue: {}
60
57
  },
61
58
  emits: ["update:modelValue"],
62
59
  setup(n, { emit: e }) {
63
- const t = n, a = e, s = C({
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;
67
- },
68
- set: (i) => {
69
- if (i.length > 4) {
70
- const r = i.slice(0, 4), l = i[4];
71
- a("update:modelValue", `${r.join(".")}:${l}`);
72
- } else
73
- a("update:modelValue", i.join("."));
74
- }
75
- }), c = (i, r) => {
76
- const l = [...s.value];
77
- if (i < 4) {
78
- let o = parseInt(r, 10);
79
- isNaN(o) && (o = 0), o < 0 && (o = 0), o > 255 && (o = 255), l[i] = o.toString();
80
- } else {
81
- let o = parseInt(r, 10);
82
- isNaN(o) && (o = 0), o < 0 && (o = 0), o > 65535 && (o = 65535), l[i] = o.toString();
83
- }
84
- s.value = l;
60
+ const t = n, a = e, o = C({
61
+ get: () => (t.modelValue || "0.0.0.0").split("."),
62
+ set: (l) => a("update:modelValue", l.join("."))
63
+ }), r = (l, c) => {
64
+ const u = [...o.value];
65
+ u[l] = c, o.value = u;
85
66
  };
86
- return (i, r) => (m(), d("div", j, [
87
- (m(!0), d(v, null, R(s.value, (l, o) => (m(), d(v, { key: o }, [
88
- o > 0 ? (m(), d("span", z, B(o === 4 ? ":" : "."), 1)) : K("", !0),
89
- w(O, {
90
- "model-value": l,
91
- "onUpdate:modelValue": (f) => c(o, f),
92
- style: L({
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"
96
- })
97
- }, null, 8, ["model-value", "onUpdate:modelValue", "style"])
98
- ], 64))), 128))
67
+ return (l, c) => (p(), y("div", L, [
68
+ (p(!0), y(B, null, R(o.value, (u, d) => (p(), M(U, {
69
+ key: d,
70
+ "model-value": u,
71
+ "onUpdate:modelValue": (m) => r(d, m)
72
+ }, null, 8, ["model-value", "onUpdate:modelValue"]))), 128))
99
73
  ]));
100
74
  }
101
- }), Y = /* @__PURE__ */ y({
75
+ }), $ = /* @__PURE__ */ f({
102
76
  __name: "InputNumber",
103
77
  props: {
104
78
  modelValue: {}
105
79
  },
106
80
  emits: ["update:modelValue"],
107
81
  setup(n, { emit: e }) {
108
- const t = n, a = e, s = V(g);
109
- if (console.log("inject result:", s), !s || !s.InputNumber)
82
+ const t = n, a = e, o = T(g);
83
+ if (console.log("inject result:", o), !o || !o.InputNumber)
110
84
  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(() => ({
112
- [i]: t.modelValue,
113
- [l]: (_) => a("update:modelValue", _)
114
- })), f = c.component;
115
- return (_, N) => (m(), T(P(k(f)), A(D(o.value)), null, 16));
85
+ const r = o.InputNumber, l = r.modelProp ?? "modelValue", c = r.modelEvent ?? "update:modelValue", u = "on" + c.charAt(0).toUpperCase() + c.slice(1), d = C(() => ({
86
+ [l]: t.modelValue,
87
+ [u]: (_) => a("update:modelValue", _)
88
+ })), m = r.component;
89
+ return (_, O) => (p(), M(V(P(m)), k(A(d.value)), null, 16));
116
90
  }
117
91
  });
118
- class u {
92
+ class s {
119
93
  id;
120
94
  deviceId;
121
95
  type;
@@ -124,49 +98,49 @@ class u {
124
98
  this.id = e.id, this.deviceId = e.deviceId;
125
99
  }
126
100
  static register(e, t) {
127
- u.registry[e] = t;
101
+ s.registry[e] = t;
128
102
  }
129
103
  static fromPlain(e) {
130
- const t = u.registry[e.type];
104
+ const t = s.registry[e.type];
131
105
  if (!t) throw new Error(`Unsupported protocol type: ${e.type}`);
132
106
  return t.fromPlain(e);
133
107
  }
134
108
  }
135
- class F {
109
+ class H {
136
110
  static getDefaultConfig(e) {
137
111
  console.log(1231231, e);
138
- const t = e.baseInfo, a = e.configuration, s = e.tab;
112
+ const t = e.baseInfo, a = e.configuration, o = e.tab;
139
113
  return {
140
114
  baseInfo: t,
141
115
  config: a,
142
- tab: s
116
+ tab: o
143
117
  };
144
118
  }
145
119
  }
146
- const J = "Ethernet", q = [{ 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" } }], Q = [{ name: { i18nKey: "general" }, key: "general" }, { name: { i18nKey: "ioMapping" }, key: "ioMapping" }], W = { 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" }] }, X = {
147
- type: J,
148
- baseInfo: q,
149
- tab: Q,
150
- configuration: W
120
+ const j = "Ethernet", G = [{ 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" } }], Y = [{ name: { i18nKey: "general" }, key: "general" }, { name: { i18nKey: "ioMapping" }, key: "ioMapping" }], z = { 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" }] }, F = {
121
+ type: j,
122
+ baseInfo: G,
123
+ tab: Y,
124
+ configuration: z
151
125
  };
152
- class h extends u {
153
- type = p.ETHERNET;
154
- moduleType = E[p.ETHERNET];
126
+ class b extends s {
127
+ type = i.ETHERNET;
128
+ moduleType = E[i.ETHERNET];
155
129
  baseInfo;
156
130
  config;
157
131
  tab;
158
132
  constructor(e) {
159
133
  super(e);
160
- const { baseInfo: t, config: a, tab: s } = F.getDefaultConfig(X);
161
- this.baseInfo = t, this.config = a, this.tab = s;
134
+ const { baseInfo: t, config: a, tab: o } = H.getDefaultConfig(F);
135
+ this.baseInfo = t, this.config = a, this.tab = o;
162
136
  }
163
137
  static fromPlain(e) {
164
- return new h(e);
138
+ return new b(e);
165
139
  }
166
140
  }
167
- class S extends u {
168
- type = p.MODBUS_TCP_SERVER;
169
- moduleType = E[p.MODBUS_TCP_SERVER];
141
+ class S extends s {
142
+ type = i.MODBUS_TCP_SERVER;
143
+ moduleType = E[i.MODBUS_TCP_SERVER];
170
144
  constructor(e) {
171
145
  super(e);
172
146
  }
@@ -174,27 +148,27 @@ class S extends u {
174
148
  return new S(e);
175
149
  }
176
150
  }
177
- class b extends u {
178
- type = p.MODBUS_TCP_CLIENT;
179
- moduleType = E[p.MODBUS_TCP_CLIENT];
151
+ class h extends s {
152
+ type = i.MODBUS_TCP_CLIENT;
153
+ moduleType = E[i.MODBUS_TCP_CLIENT];
180
154
  constructor(e) {
181
155
  super(e);
182
156
  }
183
157
  static fromPlain(e) {
184
- return new b(e);
158
+ return new h(e);
185
159
  }
186
160
  }
187
- class M extends u {
188
- type = p.MODBUS_TCP_SLAVE_DEVICE;
189
- moduleType = E[p.MODBUS_TCP_SLAVE_DEVICE];
161
+ class v extends s {
162
+ type = i.MODBUS_TCP_SLAVE_DEVICE;
163
+ moduleType = E[i.MODBUS_TCP_SLAVE_DEVICE];
190
164
  constructor(e) {
191
165
  super(e);
192
166
  }
193
167
  static fromPlain(e) {
194
- return new M(e);
168
+ return new v(e);
195
169
  }
196
170
  }
197
- var p = /* @__PURE__ */ ((n) => (n.ETHERNET = "Ethernet", n.MODBUS_TCP_SERVER = "ModbusTCPServer", n.MODBUS_TCP_CLIENT = "ModbusTCPClient", n.MODBUS_TCP_SLAVE_DEVICE = "ModbusTCPSlaveDevice", n.MODBUS_SERIAL_PORT = "ModbusSerialPort", n.MODBUS_MASTER = "ModbusMaster", n.MODBUS_SLAVE = "ModbusSlave", n.MODBUS_SERIAL = "ModbusSerial", n.OPCUA_SERVER = "OPCUAServer", n.ETHER_CAT_MASTER = "EtherCatMaster", n.ETHER_CAT_SLAVE = "EtherCatSlave", n.ETHER_CAT_MODULE = "EtherCatModule", n))(p || {});
171
+ var i = /* @__PURE__ */ ((n) => (n.ETHERNET = "Ethernet", n.MODBUS_TCP_SERVER = "ModbusTCPServer", n.MODBUS_TCP_CLIENT = "ModbusTCPClient", n.MODBUS_TCP_SLAVE_DEVICE = "ModbusTCPSlaveDevice", n.MODBUS_SERIAL_PORT = "ModbusSerialPort", n.MODBUS_MASTER = "ModbusMaster", n.MODBUS_SLAVE = "ModbusSlave", n.MODBUS_SERIAL = "ModbusSerial", n.OPCUA_SERVER = "OPCUAServer", n.ETHER_CAT_MASTER = "EtherCatMaster", n.ETHER_CAT_SLAVE = "EtherCatSlave", n.ETHER_CAT_MODULE = "EtherCatModule", n))(i || {});
198
172
  const E = {
199
173
  Pprogrammable: 4096,
200
174
  // 根节点
@@ -249,14 +223,14 @@ const E = {
249
223
  EtherCatModule: 16384
250
224
  // Ethercat子模块
251
225
  };
252
- class ne {
226
+ class W {
253
227
  map = /* @__PURE__ */ new Map();
254
228
  constructor() {
255
- u.register("Ethernet", h), u.register("ModbusTCPServer", S), u.register("ModbusTCPClient", b), u.register("ModbusTCPSlaveDevice", M);
229
+ s.register("Ethernet", b), s.register("ModbusTCPServer", S), s.register("ModbusTCPClient", h), s.register("ModbusTCPSlaveDevice", v);
256
230
  }
257
231
  init(e) {
258
232
  this.clear(), e.forEach((t) => {
259
- const a = u.fromPlain(t);
233
+ const a = s.fromPlain(t);
260
234
  this.map.set(t.id, a);
261
235
  });
262
236
  }
@@ -279,27 +253,27 @@ class ne {
279
253
  this.map.clear();
280
254
  }
281
255
  }
282
- const Z = [x, O, Y, G], oe = {
256
+ const J = [w, U, $, x], X = {
283
257
  install(n, e) {
284
- e && n.provide(g, e), Z.forEach((t) => {
258
+ e && n.provide(g, e), J.forEach((t) => {
285
259
  n.component(t.name, t);
286
260
  });
287
261
  }
288
262
  };
289
263
  export {
290
- te as Button2,
291
- h as EthernetProtocolItem,
292
- O as Input,
293
- Y as InputNumber,
294
- G as IpInput,
295
- b as ModbusTCPClientProtocolItem,
264
+ Q as Button2,
265
+ b as EthernetProtocolItem,
266
+ U as Input,
267
+ $ as InputNumber,
268
+ x as IpInput,
269
+ h as ModbusTCPClientProtocolItem,
296
270
  S as ModbusTCPServerProtocolItem,
297
- M as ModbusTCPSlaveDeviceProtocolItem,
298
- x as MyButton,
299
- ne as ProtocolCollection,
300
- u as ProtocolItem,
301
- p as ProtocolType,
271
+ v as ModbusTCPSlaveDeviceProtocolItem,
272
+ w as MyButton,
273
+ W as ProtocolCollection,
274
+ s as ProtocolItem,
275
+ i as ProtocolType,
302
276
  g as UI_KEY,
303
- oe as default,
277
+ X as default,
304
278
  E as protocolMap
305
279
  };
@@ -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(r,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(r=typeof globalThis<"u"?globalThis:r||self,t(r["lty-protocol"]={},r.Vue))})(this,(function(r,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,l)=>(t.openBlock(),t.createElementBlock("button",{class:"my-btn",onClick:s},[t.renderSlot(a.$slots,"default",{},void 0,!0)]))}}),h=(o,e)=>{const n=o.__vccOpts||o;for(const[s,a]of e)n[s]=a;return n},I=h(V,[["__scopeId","data-v-c654f959"]]),k=h(t.defineComponent({name:"MyButton",__name:"button2",emits:["click"],setup(o,{emit:e}){const n=e,s=()=>{n("click")};return(a,l)=>(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"),g=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 l=a.Input,u=l.modelProp??"modelValue",p=l.modelEvent??"update:modelValue",d="on"+p.charAt(0).toUpperCase()+p.slice(1),m=t.computed(()=>({[u]:n.modelValue,[d]:y=>s("update:modelValue",y)})),_=l.component;return(y,R)=>(t.openBlock(),t.createBlock(t.resolveDynamicComponent(t.unref(_)),t.normalizeProps(t.guardReactiveProps(m.value)),null,16))}}),B={style:{display:"flex",gap:"6px"}},P=t.defineComponent({__name:"IpInput",props:{modelValue:{}},emits:["update:modelValue"],setup(o,{emit:e}){const n=o,s=e,a=t.computed({get:()=>(n.modelValue||"0.0.0.0").split("."),set:u=>s("update:modelValue",u.join("."))}),l=(u,p)=>{const d=[...a.value];d[u]=p,a.value=d};return(u,p)=>(t.openBlock(),t.createElementBlock("div",B,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(a.value,(d,m)=>(t.openBlock(),t.createBlock(g,{key:m,"model-value":d,"onUpdate:modelValue":_=>l(m,_)},null,8,["model-value","onUpdate:modelValue"]))),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 l=a.InputNumber,u=l.modelProp??"modelValue",p=l.modelEvent??"update:modelValue",d="on"+p.charAt(0).toUpperCase()+p.slice(1),m=t.computed(()=>({[u]:n.modelValue,[d]:y=>s("update:modelValue",y)})),_=l.component;return(y,R)=>(t.openBlock(),t.createBlock(t.resolveDynamicComponent(t.unref(_)),t.normalizeProps(t.guardReactiveProps(m.value)),null,16))}});class c{id;deviceId;type;static registry={};constructor(e){this.id=e.id,this.deviceId=e.deviceId}static register(e,n){c.registry[e]=n}static fromPlain(e){const n=c.registry[e.type];if(!n)throw new Error(`Unsupported protocol type: ${e.type}`);return n.fromPlain(e)}}class A{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 D={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 c{type=i.ETHERNET;moduleType=f[i.ETHERNET];baseInfo;config;tab;constructor(e){super(e);const{baseInfo:n,config:s,tab:a}=A.getDefaultConfig(D);this.baseInfo=n,this.config=s,this.tab=a}static fromPlain(e){return new C(e)}}class M extends c{type=i.MODBUS_TCP_SERVER;moduleType=f[i.MODBUS_TCP_SERVER];constructor(e){super(e)}static fromPlain(e){return new M(e)}}class b extends c{type=i.MODBUS_TCP_CLIENT;moduleType=f[i.MODBUS_TCP_CLIENT];constructor(e){super(e)}static fromPlain(e){return new b(e)}}class S extends c{type=i.MODBUS_TCP_SLAVE_DEVICE;moduleType=f[i.MODBUS_TCP_SLAVE_DEVICE];constructor(e){super(e)}static fromPlain(e){return new S(e)}}var i=(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))(i||{});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 U{map=new Map;constructor(){c.register("Ethernet",C),c.register("ModbusTCPServer",M),c.register("ModbusTCPClient",b),c.register("ModbusTCPSlaveDevice",S)}init(e){this.clear(),e.forEach(n=>{const s=c.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 v=[I,g,T,P],O={install(o,e){e&&o.provide(E,e),v.forEach(n=>{o.component(n.name,n)})}};r.Button2=k,r.EthernetProtocolItem=C,r.Input=g,r.InputNumber=T,r.IpInput=P,r.ModbusTCPClientProtocolItem=b,r.ModbusTCPServerProtocolItem=M,r.ModbusTCPSlaveDeviceProtocolItem=S,r.MyButton=I,r.ProtocolCollection=U,r.ProtocolItem=c,r.ProtocolType=i,r.UI_KEY=E,r.default=O,r.protocolMap=f,Object.defineProperties(r,{__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.33",
3
+ "version": "1.0.34",
4
4
  "main": "dist/lty-protocol.umd.js",
5
5
  "module": "dist/lty-protocol.mjs",
6
6
  "style": "dist/lty-protocol.css",