lty-protocol 1.0.29 → 1.0.30

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/index.d.ts CHANGED
@@ -1,8 +1,10 @@
1
+ import { Plugin } from 'vue';
1
2
  import { default as MyButton } from './components/MyButton.vue';
2
3
  import { default as Button2 } from './components/button2.vue';
3
4
  import { default as Input } from './components/Input.vue';
4
5
  import { default as IpInput } from './components/IpInput.vue';
5
6
  import { default as InputNumber } from './components/InputNumber.vue';
7
+ declare const Protocol: Plugin;
6
8
  /**
7
9
  * 导出组件
8
10
  */
@@ -16,4 +18,4 @@ export * from './keys';
16
18
  /**
17
19
  * 导出插件
18
20
  */
19
- export * from './plugin';
21
+ export default Protocol;
@@ -1,5 +1,5 @@
1
- import { defineComponent as y, openBlock as p, createElementBlock as f, renderSlot as v, inject as I, computed as C, createBlock as M, resolveDynamicComponent as T, unref as V, normalizeProps as P, guardReactiveProps as k, Fragment as U, renderList as O } from "vue";
2
- const B = /* @__PURE__ */ y({
1
+ import { defineComponent as f, openBlock as p, createElementBlock as y, renderSlot as v, inject as I, computed as C, createBlock as M, resolveDynamicComponent as T, unref as V, normalizeProps as P, guardReactiveProps as k, 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,7 +7,7 @@ const B = /* @__PURE__ */ y({
7
7
  const t = e, o = () => {
8
8
  t("click");
9
9
  };
10
- return (a, r) => (p(), f("button", {
10
+ return (a, s) => (p(), y("button", {
11
11
  class: "my-btn",
12
12
  onClick: o
13
13
  }, [
@@ -19,7 +19,7 @@ const B = /* @__PURE__ */ y({
19
19
  for (const [o, a] of e)
20
20
  t[o] = a;
21
21
  return t;
22
- }, z = /* @__PURE__ */ A(B, [["__scopeId", "data-v-c654f959"]]), R = /* @__PURE__ */ y({
22
+ }, w = /* @__PURE__ */ A(K, [["__scopeId", "data-v-c654f959"]]), N = /* @__PURE__ */ f({
23
23
  name: "MyButton",
24
24
  __name: "button2",
25
25
  emits: ["click"],
@@ -27,30 +27,30 @@ const B = /* @__PURE__ */ y({
27
27
  const t = e, o = () => {
28
28
  t("click");
29
29
  };
30
- return (a, r) => (p(), f("button", {
30
+ return (a, s) => (p(), y("button", {
31
31
  class: "my-btn",
32
32
  onClick: o
33
33
  }, [
34
34
  v(a.$slots, "default", {}, void 0, !0)
35
35
  ]));
36
36
  }
37
- }), F = /* @__PURE__ */ A(R, [["__scopeId", "data-v-1477cfc3"]]), K = /* @__PURE__ */ Symbol("UI_KEY"), w = /* @__PURE__ */ y({
37
+ }), Q = /* @__PURE__ */ A(N, [["__scopeId", "data-v-1477cfc3"]]), D = /* @__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, o = e, a = I(K);
44
+ const t = n, o = e, a = I(D);
45
45
  if (console.log("inject result:", a), !a || !a.Input)
46
46
  throw new Error("Input not registered");
47
- const r = a.Input, l = r.modelProp ?? "modelValue", u = r.modelEvent ?? "update:modelValue", c = "on" + u.charAt(0).toUpperCase() + u.slice(1), d = C(() => ({
47
+ const s = a.Input, l = s.modelProp ?? "modelValue", c = s.modelEvent ?? "update:modelValue", u = "on" + c.charAt(0).toUpperCase() + c.slice(1), d = C(() => ({
48
48
  [l]: t.modelValue,
49
- [c]: (_) => o("update:modelValue", _)
50
- })), m = r.component;
51
- return (_, D) => (p(), M(T(V(m)), P(k(d.value)), null, 16));
49
+ [u]: (_) => o("update:modelValue", _)
50
+ })), m = s.component;
51
+ return (_, O) => (p(), M(T(V(m)), P(k(d.value)), null, 16));
52
52
  }
53
- }), N = { style: { display: "flex", gap: "6px" } }, J = /* @__PURE__ */ y({
53
+ }), L = { style: { display: "flex", gap: "6px" } }, x = /* @__PURE__ */ f({
54
54
  __name: "IpInput",
55
55
  props: {
56
56
  modelValue: {}
@@ -60,36 +60,36 @@ const B = /* @__PURE__ */ y({
60
60
  const t = n, o = e, a = C({
61
61
  get: () => (t.modelValue || "0.0.0.0").split("."),
62
62
  set: (l) => o("update:modelValue", l.join("."))
63
- }), r = (l, u) => {
64
- const c = [...a.value];
65
- c[l] = u, a.value = c;
63
+ }), s = (l, c) => {
64
+ const u = [...a.value];
65
+ u[l] = c, a.value = u;
66
66
  };
67
- return (l, u) => (p(), f("div", N, [
68
- (p(!0), f(U, null, O(a.value, (c, d) => (p(), M(w, {
67
+ return (l, c) => (p(), y("div", L, [
68
+ (p(!0), y(B, null, R(a.value, (u, d) => (p(), M(U, {
69
69
  key: d,
70
- "model-value": c,
71
- "onUpdate:modelValue": (m) => r(d, m)
70
+ "model-value": u,
71
+ "onUpdate:modelValue": (m) => s(d, m)
72
72
  }, null, 8, ["model-value", "onUpdate:modelValue"]))), 128))
73
73
  ]));
74
74
  }
75
- }), q = /* @__PURE__ */ y({
75
+ }), $ = /* @__PURE__ */ f({
76
76
  __name: "InputNumber",
77
77
  props: {
78
78
  modelValue: {}
79
79
  },
80
80
  emits: ["update:modelValue"],
81
81
  setup(n, { emit: e }) {
82
- const t = n, o = e, r = I("UIComponents", {}).InputNumber;
83
- if (!r)
82
+ const t = n, o = e, s = I("UIComponents", {}).InputNumber;
83
+ if (!s)
84
84
  throw new Error("InputNumber not registered");
85
- const l = r.modelProp ?? "modelValue", u = r.modelEvent ?? "update:modelValue", c = "on" + u.charAt(0).toUpperCase() + u.slice(1), d = C(() => ({
85
+ const l = s.modelProp ?? "modelValue", c = s.modelEvent ?? "update:modelValue", u = "on" + c.charAt(0).toUpperCase() + c.slice(1), d = C(() => ({
86
86
  [l]: t.modelValue,
87
- [c]: (_) => o("update:modelValue", _)
88
- })), m = r.component;
89
- return (_, D) => (p(), M(T(V(m)), P(k(d.value)), null, 16));
87
+ [u]: (_) => o("update:modelValue", _)
88
+ })), m = s.component;
89
+ return (_, O) => (p(), M(T(V(m)), P(k(d.value)), null, 16));
90
90
  }
91
91
  });
92
- class s {
92
+ class r {
93
93
  id;
94
94
  deviceId;
95
95
  type;
@@ -98,15 +98,15 @@ class s {
98
98
  this.id = e.id, this.deviceId = e.deviceId;
99
99
  }
100
100
  static register(e, t) {
101
- s.registry[e] = t;
101
+ r.registry[e] = t;
102
102
  }
103
103
  static fromPlain(e) {
104
- const t = s.registry[e.type];
104
+ const t = r.registry[e.type];
105
105
  if (!t) throw new Error(`Unsupported protocol type: ${e.type}`);
106
106
  return t.fromPlain(e);
107
107
  }
108
108
  }
109
- class L {
109
+ class H {
110
110
  static getDefaultConfig(e) {
111
111
  console.log(1231231, e);
112
112
  const t = e.baseInfo, o = e.configuration, a = e.tab;
@@ -117,13 +117,13 @@ class L {
117
117
  };
118
118
  }
119
119
  }
120
- const x = "Ethernet", $ = [{ 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" } }], H = [{ name: { i18nKey: "general" }, key: "general" }, { name: { i18nKey: "ioMapping" }, key: "ioMapping" }], j = { 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" }] }, G = {
121
- type: x,
122
- baseInfo: $,
123
- tab: H,
124
- configuration: j
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
125
125
  };
126
- class g extends s {
126
+ class g extends r {
127
127
  type = i.ETHERNET;
128
128
  moduleType = E[i.ETHERNET];
129
129
  baseInfo;
@@ -131,14 +131,14 @@ class g extends s {
131
131
  tab;
132
132
  constructor(e) {
133
133
  super(e);
134
- const { baseInfo: t, config: o, tab: a } = L.getDefaultConfig(G);
134
+ const { baseInfo: t, config: o, tab: a } = H.getDefaultConfig(F);
135
135
  this.baseInfo = t, this.config = o, this.tab = a;
136
136
  }
137
137
  static fromPlain(e) {
138
138
  return new g(e);
139
139
  }
140
140
  }
141
- class S extends s {
141
+ class S extends r {
142
142
  type = i.MODBUS_TCP_SERVER;
143
143
  moduleType = E[i.MODBUS_TCP_SERVER];
144
144
  constructor(e) {
@@ -148,7 +148,7 @@ class S extends s {
148
148
  return new S(e);
149
149
  }
150
150
  }
151
- class b extends s {
151
+ class b extends r {
152
152
  type = i.MODBUS_TCP_CLIENT;
153
153
  moduleType = E[i.MODBUS_TCP_CLIENT];
154
154
  constructor(e) {
@@ -158,7 +158,7 @@ class b extends s {
158
158
  return new b(e);
159
159
  }
160
160
  }
161
- class h extends s {
161
+ class h extends r {
162
162
  type = i.MODBUS_TCP_SLAVE_DEVICE;
163
163
  moduleType = E[i.MODBUS_TCP_SLAVE_DEVICE];
164
164
  constructor(e) {
@@ -223,14 +223,14 @@ const E = {
223
223
  EtherCatModule: 16384
224
224
  // Ethercat子模块
225
225
  };
226
- class Q {
226
+ class W {
227
227
  map = /* @__PURE__ */ new Map();
228
228
  constructor() {
229
- s.register("Ethernet", g), s.register("ModbusTCPServer", S), s.register("ModbusTCPClient", b), s.register("ModbusTCPSlaveDevice", h);
229
+ r.register("Ethernet", g), r.register("ModbusTCPServer", S), r.register("ModbusTCPClient", b), r.register("ModbusTCPSlaveDevice", h);
230
230
  }
231
231
  init(e) {
232
232
  this.clear(), e.forEach((t) => {
233
- const o = s.fromPlain(t);
233
+ const o = r.fromPlain(t);
234
234
  this.map.set(t.id, o);
235
235
  });
236
236
  }
@@ -253,19 +253,27 @@ class Q {
253
253
  this.map.clear();
254
254
  }
255
255
  }
256
+ const J = [w, U, $, x], X = {
257
+ install(n, e) {
258
+ e && n.provide(D, e), J.forEach((t) => {
259
+ n.component(t.name, t);
260
+ });
261
+ }
262
+ };
256
263
  export {
257
- F as Button2,
264
+ Q as Button2,
258
265
  g as EthernetProtocolItem,
259
- w as Input,
260
- q as InputNumber,
261
- J as IpInput,
266
+ U as Input,
267
+ $ as InputNumber,
268
+ x as IpInput,
262
269
  b as ModbusTCPClientProtocolItem,
263
270
  S as ModbusTCPServerProtocolItem,
264
271
  h as ModbusTCPSlaveDeviceProtocolItem,
265
- z as MyButton,
266
- Q as ProtocolCollection,
267
- s as ProtocolItem,
272
+ w as MyButton,
273
+ W as ProtocolCollection,
274
+ r as ProtocolItem,
268
275
  i as ProtocolType,
269
- K as UI_KEY,
276
+ D as UI_KEY,
277
+ X as default,
270
278
  E as protocolMap
271
279
  };
@@ -1 +1 @@
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 I=t.defineComponent({name:"MyButton",__name:"MyButton",emits:["click"],setup(o,{emit:e}){const n=e,a=()=>{n("click")};return(s,l)=>(t.openBlock(),t.createElementBlock("button",{class:"my-btn",onClick:a},[t.renderSlot(s.$slots,"default",{},void 0,!0)]))}}),g=(o,e)=>{const n=o.__vccOpts||o;for(const[a,s]of e)n[a]=s;return n},T=g(I,[["__scopeId","data-v-c654f959"]]),P=g(t.defineComponent({name:"MyButton",__name:"button2",emits:["click"],setup(o,{emit:e}){const n=e,a=()=>{n("click")};return(s,l)=>(t.openBlock(),t.createElementBlock("button",{class:"my-btn",onClick:a},[t.renderSlot(s.$slots,"default",{},void 0,!0)]))}}),[["__scopeId","data-v-1477cfc3"]]),S=Symbol("UI_KEY"),h=t.defineComponent({__name:"Input",props:{modelValue:{}},emits:["update:modelValue"],setup(o,{emit:e}){const n=o,a=e,s=t.inject(S);if(console.log("inject result:",s),!s||!s.Input)throw new Error("Input not registered");const l=s.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=>a("update:modelValue",y)})),_=l.component;return(y,O)=>(t.openBlock(),t.createBlock(t.resolveDynamicComponent(t.unref(_)),t.normalizeProps(t.guardReactiveProps(m.value)),null,16))}}),V={style:{display:"flex",gap:"6px"}},k=t.defineComponent({__name:"IpInput",props:{modelValue:{}},emits:["update:modelValue"],setup(o,{emit:e}){const n=o,a=e,s=t.computed({get:()=>(n.modelValue||"0.0.0.0").split("."),set:u=>a("update:modelValue",u.join("."))}),l=(u,p)=>{const d=[...s.value];d[u]=p,s.value=d};return(u,p)=>(t.openBlock(),t.createElementBlock("div",V,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(s.value,(d,m)=>(t.openBlock(),t.createBlock(h,{key:m,"model-value":d,"onUpdate:modelValue":_=>l(m,_)},null,8,["model-value","onUpdate:modelValue"]))),128))]))}}),B=t.defineComponent({__name:"InputNumber",props:{modelValue:{}},emits:["update:modelValue"],setup(o,{emit:e}){const n=o,a=e,l=t.inject("UIComponents",{}).InputNumber;if(!l)throw new Error("InputNumber not registered");const 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=>a("update:modelValue",y)})),_=l.component;return(y,O)=>(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,a=e.configuration,s=e.tab;return{baseInfo:n,config:a,tab:s}}}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 E extends c{type=i.ETHERNET;moduleType=f[i.ETHERNET];baseInfo;config;tab;constructor(e){super(e);const{baseInfo:n,config:a,tab:s}=A.getDefaultConfig(D);this.baseInfo=n,this.config=a,this.tab=s}static fromPlain(e){return new E(e)}}class C extends c{type=i.MODBUS_TCP_SERVER;moduleType=f[i.MODBUS_TCP_SERVER];constructor(e){super(e)}static fromPlain(e){return new C(e)}}class M extends c{type=i.MODBUS_TCP_CLIENT;moduleType=f[i.MODBUS_TCP_CLIENT];constructor(e){super(e)}static fromPlain(e){return new M(e)}}class b extends c{type=i.MODBUS_TCP_SLAVE_DEVICE;moduleType=f[i.MODBUS_TCP_SLAVE_DEVICE];constructor(e){super(e)}static fromPlain(e){return new b(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",E),c.register("ModbusTCPServer",C),c.register("ModbusTCPClient",M),c.register("ModbusTCPSlaveDevice",b)}init(e){this.clear(),e.forEach(n=>{const a=c.fromPlain(n);this.map.set(n.id,a)})}build(e){return""}get(e){const n=Array.isArray(e)?e.map(a=>this.map.get(a)).filter(a=>a!==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()}}r.Button2=P,r.EthernetProtocolItem=E,r.Input=h,r.InputNumber=B,r.IpInput=k,r.ModbusTCPClientProtocolItem=M,r.ModbusTCPServerProtocolItem=C,r.ModbusTCPSlaveDeviceProtocolItem=b,r.MyButton=T,r.ProtocolCollection=U,r.ProtocolItem=c,r.ProtocolType=i,r.UI_KEY=S,r.protocolMap=f,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(a,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(a=typeof globalThis<"u"?globalThis:a||self,t(a["lty-protocol"]={},a.Vue))})(this,(function(a,t){"use strict";const V=t.defineComponent({name:"MyButton",__name:"MyButton",emits:["click"],setup(o,{emit:e}){const n=e,r=()=>{n("click")};return(s,l)=>(t.openBlock(),t.createElementBlock("button",{class:"my-btn",onClick:r},[t.renderSlot(s.$slots,"default",{},void 0,!0)]))}}),h=(o,e)=>{const n=o.__vccOpts||o;for(const[r,s]of e)n[r]=s;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,r=()=>{n("click")};return(s,l)=>(t.openBlock(),t.createElementBlock("button",{class:"my-btn",onClick:r},[t.renderSlot(s.$slots,"default",{},void 0,!0)]))}}),[["__scopeId","data-v-1477cfc3"]]),S=Symbol("UI_KEY"),g=t.defineComponent({__name:"Input",props:{modelValue:{}},emits:["update:modelValue"],setup(o,{emit:e}){const n=o,r=e,s=t.inject(S);if(console.log("inject result:",s),!s||!s.Input)throw new Error("Input not registered");const l=s.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=>r("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,r=e,s=t.computed({get:()=>(n.modelValue||"0.0.0.0").split("."),set:u=>r("update:modelValue",u.join("."))}),l=(u,p)=>{const d=[...s.value];d[u]=p,s.value=d};return(u,p)=>(t.openBlock(),t.createElementBlock("div",B,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(s.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,r=e,l=t.inject("UIComponents",{}).InputNumber;if(!l)throw new Error("InputNumber not registered");const 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=>r("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,r=e.configuration,s=e.tab;return{baseInfo:n,config:r,tab:s}}}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 E extends c{type=i.ETHERNET;moduleType=f[i.ETHERNET];baseInfo;config;tab;constructor(e){super(e);const{baseInfo:n,config:r,tab:s}=A.getDefaultConfig(D);this.baseInfo=n,this.config=r,this.tab=s}static fromPlain(e){return new E(e)}}class C extends c{type=i.MODBUS_TCP_SERVER;moduleType=f[i.MODBUS_TCP_SERVER];constructor(e){super(e)}static fromPlain(e){return new C(e)}}class M extends c{type=i.MODBUS_TCP_CLIENT;moduleType=f[i.MODBUS_TCP_CLIENT];constructor(e){super(e)}static fromPlain(e){return new M(e)}}class b extends c{type=i.MODBUS_TCP_SLAVE_DEVICE;moduleType=f[i.MODBUS_TCP_SLAVE_DEVICE];constructor(e){super(e)}static fromPlain(e){return new b(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",E),c.register("ModbusTCPServer",C),c.register("ModbusTCPClient",M),c.register("ModbusTCPSlaveDevice",b)}init(e){this.clear(),e.forEach(n=>{const r=c.fromPlain(n);this.map.set(n.id,r)})}build(e){return""}get(e){const n=Array.isArray(e)?e.map(r=>this.map.get(r)).filter(r=>r!==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(S,e),v.forEach(n=>{o.component(n.name,n)})}};a.Button2=k,a.EthernetProtocolItem=E,a.Input=g,a.InputNumber=T,a.IpInput=P,a.ModbusTCPClientProtocolItem=M,a.ModbusTCPServerProtocolItem=C,a.ModbusTCPSlaveDeviceProtocolItem=b,a.MyButton=I,a.ProtocolCollection=U,a.ProtocolItem=c,a.ProtocolType=i,a.UI_KEY=S,a.default=O,a.protocolMap=f,Object.defineProperties(a,{__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.29",
3
+ "version": "1.0.30",
4
4
  "main": "dist/lty-protocol.umd.js",
5
5
  "module": "dist/lty-protocol.mjs",
6
6
  "style": "dist/lty-protocol.css",
package/dist/App.vue.d.ts DELETED
@@ -1,2 +0,0 @@
1
- declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, HTMLDivElement>;
2
- export default _default;
@@ -1,5 +0,0 @@
1
- type __VLS_Props = {
2
- config: any;
3
- };
4
- declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
5
- export default _default;