lty-protocol 1.0.31 → 1.0.32

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/keys.d.ts CHANGED
@@ -4,5 +4,34 @@ export interface ComponentModelConfig {
4
4
  modelProp?: string;
5
5
  modelEvent?: string;
6
6
  }
7
- export type UIComponentsMap = Partial<Record<string, ComponentModelConfig>>;
8
- export declare const UI_KEY: InjectionKey<UIComponentsMap>;
7
+ export interface ThemeConfig {
8
+ colors?: {
9
+ primary?: string;
10
+ secondary?: string;
11
+ success?: string;
12
+ warning?: string;
13
+ error?: string;
14
+ info?: string;
15
+ };
16
+ spacing?: {
17
+ small?: string;
18
+ medium?: string;
19
+ large?: string;
20
+ };
21
+ borderRadius?: {
22
+ small?: string;
23
+ medium?: string;
24
+ large?: string;
25
+ };
26
+ fontSize?: {
27
+ small?: string;
28
+ medium?: string;
29
+ large?: string;
30
+ };
31
+ [key: string]: any;
32
+ }
33
+ export interface UIConfig {
34
+ components?: Partial<Record<string, ComponentModelConfig>>;
35
+ theme?: ThemeConfig;
36
+ }
37
+ export declare const UI_KEY: InjectionKey<UIConfig>;
@@ -1 +1 @@
1
- .my-btn[data-v-c654f959],.my-btn[data-v-1477cfc3]{padding:6px 12px;border:1px solid #ccc}
1
+ .my-btn[data-v-2ba85ace]{outline:none}.my-btn[data-v-2ba85ace]:hover{opacity:.8}.my-btn[data-v-2ba85ace]:active{transform:translateY(1px)}.my-btn[data-v-1477cfc3]{padding:6px 12px;border:1px solid #ccc}
@@ -1,95 +1,114 @@
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({
1
+ import { inject as h, defineComponent as f, computed as E, openBlock as m, createElementBlock as y, normalizeStyle as B, renderSlot as T, createBlock as S, resolveDynamicComponent as V, unref as P, normalizeProps as k, guardReactiveProps as A, Fragment as O, renderList as K } from "vue";
2
+ const g = /* @__PURE__ */ Symbol("UI_KEY"), w = () => {
3
+ const n = h(g, {}), e = () => n.theme || {}, t = (s, a) => e().colors?.[s] || a, o = (s, a) => e().spacing?.[s] || a, r = (s, a) => e().borderRadius?.[s] || a, c = (s, a) => e().fontSize?.[s] || a;
4
+ return {
5
+ theme: e(),
6
+ getColor: t,
7
+ getSpacing: o,
8
+ getBorderRadius: r,
9
+ getFontSize: c
10
+ };
11
+ }, x = /* @__PURE__ */ f({
3
12
  name: "MyButton",
4
13
  __name: "MyButton",
5
14
  emits: ["click"],
6
15
  setup(n, { emit: e }) {
7
- const t = e, a = () => {
16
+ const t = e, { getColor: o, getSpacing: r, getBorderRadius: c, getFontSize: s } = w(), a = E(() => ({
17
+ padding: r("medium", "6px 12px"),
18
+ border: `1px solid ${o("secondary", "#ccc")}`,
19
+ borderRadius: c("medium", "4px"),
20
+ fontSize: s("medium", "14px"),
21
+ backgroundColor: o("primary", "#fff"),
22
+ color: o("text", "#333"),
23
+ cursor: "pointer",
24
+ transition: "all 0.3s ease"
25
+ })), i = () => {
8
26
  t("click");
9
27
  };
10
- return (o, r) => (p(), y("button", {
28
+ return (p, d) => (m(), y("button", {
11
29
  class: "my-btn",
12
- onClick: a
30
+ onClick: i,
31
+ style: B(a.value)
13
32
  }, [
14
- I(o.$slots, "default", {}, void 0, !0)
15
- ]));
33
+ T(p.$slots, "default", {}, void 0, !0)
34
+ ], 4));
16
35
  }
17
36
  }), D = (n, e) => {
18
37
  const t = n.__vccOpts || n;
19
- for (const [a, o] of e)
20
- t[a] = o;
38
+ for (const [o, r] of e)
39
+ t[o] = r;
21
40
  return t;
22
- }, w = /* @__PURE__ */ D(K, [["__scopeId", "data-v-c654f959"]]), N = /* @__PURE__ */ f({
41
+ }, N = /* @__PURE__ */ D(x, [["__scopeId", "data-v-2ba85ace"]]), L = /* @__PURE__ */ f({
23
42
  name: "MyButton",
24
43
  __name: "button2",
25
44
  emits: ["click"],
26
45
  setup(n, { emit: e }) {
27
- const t = e, a = () => {
46
+ const t = e, o = () => {
28
47
  t("click");
29
48
  };
30
- return (o, r) => (p(), y("button", {
49
+ return (r, c) => (m(), y("button", {
31
50
  class: "my-btn",
32
- onClick: a
51
+ onClick: o
33
52
  }, [
34
- I(o.$slots, "default", {}, void 0, !0)
53
+ T(r.$slots, "default", {}, void 0, !0)
35
54
  ]));
36
55
  }
37
- }), Q = /* @__PURE__ */ D(N, [["__scopeId", "data-v-1477cfc3"]]), g = /* @__PURE__ */ Symbol("UI_KEY"), U = /* @__PURE__ */ f({
56
+ }), X = /* @__PURE__ */ D(L, [["__scopeId", "data-v-1477cfc3"]]), R = /* @__PURE__ */ f({
38
57
  __name: "Input",
39
58
  props: {
40
59
  modelValue: {}
41
60
  },
42
61
  emits: ["update:modelValue"],
43
62
  setup(n, { emit: e }) {
44
- const t = n, a = e, o = T(g);
45
- if (console.log("inject result:", o), !o || !o.Input)
63
+ const t = n, o = e, r = h(g);
64
+ if (console.log("inject result:", r), !r || !r.components?.Input)
46
65
  throw new Error("Input not registered");
47
- const r = o.Input, i = r.modelProp ?? "modelValue", c = r.modelEvent ?? "update:modelValue", u = "on" + c.charAt(0).toUpperCase() + c.slice(1), d = C(() => ({
48
- [i]: 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));
66
+ const c = r.components.Input, s = c.modelProp ?? "modelValue", a = c.modelEvent ?? "update:modelValue", i = "on" + a.charAt(0).toUpperCase() + a.slice(1), p = E(() => ({
67
+ [s]: t.modelValue,
68
+ [i]: (_) => o("update:modelValue", _)
69
+ })), d = c.component;
70
+ return (_, U) => (m(), S(V(P(d)), k(A(p.value)), null, 16));
52
71
  }
53
- }), L = { style: { display: "flex", gap: "6px" } }, x = /* @__PURE__ */ f({
72
+ }), $ = { style: { display: "flex", gap: "6px" } }, z = /* @__PURE__ */ f({
54
73
  __name: "IpInput",
55
74
  props: {
56
75
  modelValue: {}
57
76
  },
58
77
  emits: ["update:modelValue"],
59
78
  setup(n, { emit: e }) {
60
- const t = n, a = e, o = C({
79
+ const t = n, o = e, r = E({
61
80
  get: () => (t.modelValue || "0.0.0.0").split("."),
62
- set: (i) => a("update:modelValue", i.join("."))
63
- }), r = (i, c) => {
64
- const u = [...o.value];
65
- u[i] = c, o.value = u;
81
+ set: (s) => o("update:modelValue", s.join("."))
82
+ }), c = (s, a) => {
83
+ const i = [...r.value];
84
+ i[s] = a, r.value = i;
66
85
  };
67
- return (i, 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)
86
+ return (s, a) => (m(), y("div", $, [
87
+ (m(!0), y(O, null, K(r.value, (i, p) => (m(), S(R, {
88
+ key: p,
89
+ "model-value": i,
90
+ "onUpdate:modelValue": (d) => c(p, d)
72
91
  }, null, 8, ["model-value", "onUpdate:modelValue"]))), 128))
73
92
  ]));
74
93
  }
75
- }), $ = /* @__PURE__ */ f({
94
+ }), H = /* @__PURE__ */ f({
76
95
  __name: "InputNumber",
77
96
  props: {
78
97
  modelValue: {}
79
98
  },
80
99
  emits: ["update:modelValue"],
81
100
  setup(n, { emit: e }) {
82
- const t = n, a = e, o = T(g);
83
- if (console.log("inject result:", o), !o || !o.InputNumber)
101
+ const t = n, o = e, r = h(g);
102
+ if (console.log("inject result:", r), !r || !r.components?.InputNumber)
84
103
  throw new Error("InputNumber not registered");
85
- const r = o.InputNumber, i = r.modelProp ?? "modelValue", c = r.modelEvent ?? "update:modelValue", u = "on" + c.charAt(0).toUpperCase() + c.slice(1), d = C(() => ({
86
- [i]: 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));
104
+ const c = r.components.InputNumber, s = c.modelProp ?? "modelValue", a = c.modelEvent ?? "update:modelValue", i = "on" + a.charAt(0).toUpperCase() + a.slice(1), p = E(() => ({
105
+ [s]: t.modelValue,
106
+ [i]: (_) => o("update:modelValue", _)
107
+ })), d = c.component;
108
+ return (_, U) => (m(), S(V(P(d)), k(A(p.value)), null, 16));
90
109
  }
91
110
  });
92
- class s {
111
+ class u {
93
112
  id;
94
113
  deviceId;
95
114
  type;
@@ -98,78 +117,78 @@ class s {
98
117
  this.id = e.id, this.deviceId = e.deviceId;
99
118
  }
100
119
  static register(e, t) {
101
- s.registry[e] = t;
120
+ u.registry[e] = t;
102
121
  }
103
122
  static fromPlain(e) {
104
- const t = s.registry[e.type];
123
+ const t = u.registry[e.type];
105
124
  if (!t) throw new Error(`Unsupported protocol type: ${e.type}`);
106
125
  return t.fromPlain(e);
107
126
  }
108
127
  }
109
- class H {
128
+ class j {
110
129
  static getDefaultConfig(e) {
111
130
  console.log(1231231, e);
112
- const t = e.baseInfo, a = e.configuration, o = e.tab;
131
+ const t = e.baseInfo, o = e.configuration, r = e.tab;
113
132
  return {
114
133
  baseInfo: t,
115
- config: a,
116
- tab: o
134
+ config: o,
135
+ tab: r
117
136
  };
118
137
  }
119
138
  }
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,
139
+ const F = "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" }], 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" }] }, q = {
140
+ type: F,
122
141
  baseInfo: G,
123
142
  tab: Y,
124
- configuration: z
143
+ configuration: J
125
144
  };
126
- class b extends s {
145
+ class b extends u {
127
146
  type = l.ETHERNET;
128
- moduleType = E[l.ETHERNET];
147
+ moduleType = C[l.ETHERNET];
129
148
  baseInfo;
130
149
  config;
131
150
  tab;
132
151
  constructor(e) {
133
152
  super(e);
134
- const { baseInfo: t, config: a, tab: o } = H.getDefaultConfig(F);
135
- this.baseInfo = t, this.config = a, this.tab = o;
153
+ const { baseInfo: t, config: o, tab: r } = j.getDefaultConfig(q);
154
+ this.baseInfo = t, this.config = o, this.tab = r;
136
155
  }
137
156
  static fromPlain(e) {
138
157
  return new b(e);
139
158
  }
140
159
  }
141
- class S extends s {
160
+ class M extends u {
142
161
  type = l.MODBUS_TCP_SERVER;
143
- moduleType = E[l.MODBUS_TCP_SERVER];
162
+ moduleType = C[l.MODBUS_TCP_SERVER];
144
163
  constructor(e) {
145
164
  super(e);
146
165
  }
147
166
  static fromPlain(e) {
148
- return new S(e);
167
+ return new M(e);
149
168
  }
150
169
  }
151
- class h extends s {
170
+ class v extends u {
152
171
  type = l.MODBUS_TCP_CLIENT;
153
- moduleType = E[l.MODBUS_TCP_CLIENT];
172
+ moduleType = C[l.MODBUS_TCP_CLIENT];
154
173
  constructor(e) {
155
174
  super(e);
156
175
  }
157
176
  static fromPlain(e) {
158
- return new h(e);
177
+ return new v(e);
159
178
  }
160
179
  }
161
- class v extends s {
180
+ class I extends u {
162
181
  type = l.MODBUS_TCP_SLAVE_DEVICE;
163
- moduleType = E[l.MODBUS_TCP_SLAVE_DEVICE];
182
+ moduleType = C[l.MODBUS_TCP_SLAVE_DEVICE];
164
183
  constructor(e) {
165
184
  super(e);
166
185
  }
167
186
  static fromPlain(e) {
168
- return new v(e);
187
+ return new I(e);
169
188
  }
170
189
  }
171
190
  var l = /* @__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))(l || {});
172
- const E = {
191
+ const C = {
173
192
  Pprogrammable: 4096,
174
193
  // 根节点
175
194
  Protgrammable_Safety: 4098,
@@ -223,22 +242,22 @@ const E = {
223
242
  EtherCatModule: 16384
224
243
  // Ethercat子模块
225
244
  };
226
- class W {
245
+ class Z {
227
246
  map = /* @__PURE__ */ new Map();
228
247
  constructor() {
229
- s.register("Ethernet", b), s.register("ModbusTCPServer", S), s.register("ModbusTCPClient", h), s.register("ModbusTCPSlaveDevice", v);
248
+ u.register("Ethernet", b), u.register("ModbusTCPServer", M), u.register("ModbusTCPClient", v), u.register("ModbusTCPSlaveDevice", I);
230
249
  }
231
250
  init(e) {
232
251
  this.clear(), e.forEach((t) => {
233
- const a = s.fromPlain(t);
234
- this.map.set(t.id, a);
252
+ const o = u.fromPlain(t);
253
+ this.map.set(t.id, o);
235
254
  });
236
255
  }
237
256
  build(e) {
238
257
  return "";
239
258
  }
240
259
  get(e) {
241
- const t = Array.isArray(e) ? e.map((a) => this.map.get(a)).filter((a) => a !== void 0) : this.map.get(e);
260
+ const t = Array.isArray(e) ? e.map((o) => this.map.get(o)).filter((o) => o !== void 0) : this.map.get(e);
242
261
  if (Array.isArray(t) && !t.length || !t)
243
262
  throw new Error(`Protocol ${e} is not found.`);
244
263
  return t;
@@ -253,27 +272,27 @@ class W {
253
272
  this.map.clear();
254
273
  }
255
274
  }
256
- const J = [w, U, $, x], X = {
275
+ const Q = [N, R, H, z], ee = {
257
276
  install(n, e) {
258
- e && n.provide(g, e), J.forEach((t) => {
277
+ e && n.provide(g, e), Q.forEach((t) => {
259
278
  n.component(t.name, t);
260
279
  });
261
280
  }
262
281
  };
263
282
  export {
264
- Q as Button2,
283
+ X as Button2,
265
284
  b as EthernetProtocolItem,
266
- U as Input,
267
- $ as InputNumber,
268
- x as IpInput,
269
- h as ModbusTCPClientProtocolItem,
270
- S as ModbusTCPServerProtocolItem,
271
- v as ModbusTCPSlaveDeviceProtocolItem,
272
- w as MyButton,
273
- W as ProtocolCollection,
274
- s as ProtocolItem,
285
+ R as Input,
286
+ H as InputNumber,
287
+ z as IpInput,
288
+ v as ModbusTCPClientProtocolItem,
289
+ M as ModbusTCPServerProtocolItem,
290
+ I as ModbusTCPSlaveDeviceProtocolItem,
291
+ N as MyButton,
292
+ Z as ProtocolCollection,
293
+ u as ProtocolItem,
275
294
  l as ProtocolType,
276
295
  g as UI_KEY,
277
- X as default,
278
- E as protocolMap
296
+ ee as default,
297
+ C as protocolMap
279
298
  };
@@ -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 V=t.defineComponent({name:"MyButton",__name:"MyButton",emits:["click"],setup(o,{emit:e}){const n=e,s=()=>{n("click")};return(a,c)=>(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,c)=>(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"),S=t.defineComponent({__name:"Input",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.Input)throw new Error("Input not registered");const c=a.Input,u=c.modelProp??"modelValue",p=c.modelEvent??"update:modelValue",d="on"+p.charAt(0).toUpperCase()+p.slice(1),m=t.computed(()=>({[u]:n.modelValue,[d]:y=>s("update:modelValue",y)})),_=c.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("."))}),c=(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(S,{key:m,"model-value":d,"onUpdate:modelValue":_=>c(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 c=a.InputNumber,u=c.modelProp??"modelValue",p=c.modelEvent??"update:modelValue",d="on"+p.charAt(0).toUpperCase()+p.slice(1),m=t.computed(()=>({[u]:n.modelValue,[d]:y=>s("update:modelValue",y)})),_=c.component;return(y,R)=>(t.openBlock(),t.createBlock(t.resolveDynamicComponent(t.unref(_)),t.normalizeProps(t.guardReactiveProps(m.value)),null,16))}});class l{id;deviceId;type;static registry={};constructor(e){this.id=e.id,this.deviceId=e.deviceId}static register(e,n){l.registry[e]=n}static fromPlain(e){const n=l.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 l{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 l{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 l{type=i.MODBUS_TCP_CLIENT;moduleType=f[i.MODBUS_TCP_CLIENT];constructor(e){super(e)}static fromPlain(e){return new b(e)}}class g extends l{type=i.MODBUS_TCP_SLAVE_DEVICE;moduleType=f[i.MODBUS_TCP_SLAVE_DEVICE];constructor(e){super(e)}static fromPlain(e){return new g(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(){l.register("Ethernet",C),l.register("ModbusTCPServer",M),l.register("ModbusTCPClient",b),l.register("ModbusTCPSlaveDevice",g)}init(e){this.clear(),e.forEach(n=>{const s=l.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,S,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=S,r.InputNumber=T,r.IpInput=P,r.ModbusTCPClientProtocolItem=b,r.ModbusTCPServerProtocolItem=M,r.ModbusTCPSlaveDeviceProtocolItem=g,r.MyButton=I,r.ProtocolCollection=U,r.ProtocolItem=l,r.ProtocolType=i,r.UI_KEY=E,r.default=O,r.protocolMap=f,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
1
+ (function(s,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(s=typeof globalThis<"u"?globalThis:s||self,t(s["lty-protocol"]={},s.Vue))})(this,(function(s,t){"use strict";const y=Symbol("UI_KEY"),k=()=>{const o=t.inject(y,{}),e=()=>o.theme||{},n=(c,i)=>e().colors?.[c]||i,r=(c,i)=>e().spacing?.[c]||i,a=(c,i)=>e().borderRadius?.[c]||i,l=(c,i)=>e().fontSize?.[c]||i;return{theme:e(),getColor:n,getSpacing:r,getBorderRadius:a,getFontSize:l}},V=t.defineComponent({name:"MyButton",__name:"MyButton",emits:["click"],setup(o,{emit:e}){const n=e,{getColor:r,getSpacing:a,getBorderRadius:l,getFontSize:c}=k(),i=t.computed(()=>({padding:a("medium","6px 12px"),border:`1px solid ${r("secondary","#ccc")}`,borderRadius:l("medium","4px"),fontSize:c("medium","14px"),backgroundColor:r("primary","#fff"),color:r("text","#333"),cursor:"pointer",transition:"all 0.3s ease"})),u=()=>{n("click")};return(d,f)=>(t.openBlock(),t.createElementBlock("button",{class:"my-btn",onClick:u,style:t.normalizeStyle(i.value)},[t.renderSlot(d.$slots,"default",{},void 0,!0)],4))}}),M=(o,e)=>{const n=o.__vccOpts||o;for(const[r,a]of e)n[r]=a;return n},I=M(V,[["__scopeId","data-v-2ba85ace"]]),B=M(t.defineComponent({name:"MyButton",__name:"button2",emits:["click"],setup(o,{emit:e}){const n=e,r=()=>{n("click")};return(a,l)=>(t.openBlock(),t.createElementBlock("button",{class:"my-btn",onClick:r},[t.renderSlot(a.$slots,"default",{},void 0,!0)]))}}),[["__scopeId","data-v-1477cfc3"]]),S=t.defineComponent({__name:"Input",props:{modelValue:{}},emits:["update:modelValue"],setup(o,{emit:e}){const n=o,r=e,a=t.inject(y);if(console.log("inject result:",a),!a||!a.components?.Input)throw new Error("Input not registered");const l=a.components.Input,c=l.modelProp??"modelValue",i=l.modelEvent??"update:modelValue",u="on"+i.charAt(0).toUpperCase()+i.slice(1),d=t.computed(()=>({[c]:n.modelValue,[u]:E=>r("update:modelValue",E)})),f=l.component;return(E,K)=>(t.openBlock(),t.createBlock(t.resolveDynamicComponent(t.unref(f)),t.normalizeProps(t.guardReactiveProps(d.value)),null,16))}}),A={style:{display:"flex",gap:"6px"}},T=t.defineComponent({__name:"IpInput",props:{modelValue:{}},emits:["update:modelValue"],setup(o,{emit:e}){const n=o,r=e,a=t.computed({get:()=>(n.modelValue||"0.0.0.0").split("."),set:c=>r("update:modelValue",c.join("."))}),l=(c,i)=>{const u=[...a.value];u[c]=i,a.value=u};return(c,i)=>(t.openBlock(),t.createElementBlock("div",A,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(a.value,(u,d)=>(t.openBlock(),t.createBlock(S,{key:d,"model-value":u,"onUpdate:modelValue":f=>l(d,f)},null,8,["model-value","onUpdate:modelValue"]))),128))]))}}),P=t.defineComponent({__name:"InputNumber",props:{modelValue:{}},emits:["update:modelValue"],setup(o,{emit:e}){const n=o,r=e,a=t.inject(y);if(console.log("inject result:",a),!a||!a.components?.InputNumber)throw new Error("InputNumber not registered");const l=a.components.InputNumber,c=l.modelProp??"modelValue",i=l.modelEvent??"update:modelValue",u="on"+i.charAt(0).toUpperCase()+i.slice(1),d=t.computed(()=>({[c]:n.modelValue,[u]:E=>r("update:modelValue",E)})),f=l.component;return(E,K)=>(t.openBlock(),t.createBlock(t.resolveDynamicComponent(t.unref(f)),t.normalizeProps(t.guardReactiveProps(d.value)),null,16))}});class m{id;deviceId;type;static registry={};constructor(e){this.id=e.id,this.deviceId=e.deviceId}static register(e,n){m.registry[e]=n}static fromPlain(e){const n=m.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,r=e.configuration,a=e.tab;return{baseInfo:n,config:r,tab:a}}}const R={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 m{type=p.ETHERNET;moduleType=_[p.ETHERNET];baseInfo;config;tab;constructor(e){super(e);const{baseInfo:n,config:r,tab:a}=D.getDefaultConfig(R);this.baseInfo=n,this.config=r,this.tab=a}static fromPlain(e){return new C(e)}}class g extends m{type=p.MODBUS_TCP_SERVER;moduleType=_[p.MODBUS_TCP_SERVER];constructor(e){super(e)}static fromPlain(e){return new g(e)}}class h extends m{type=p.MODBUS_TCP_CLIENT;moduleType=_[p.MODBUS_TCP_CLIENT];constructor(e){super(e)}static fromPlain(e){return new h(e)}}class b extends m{type=p.MODBUS_TCP_SLAVE_DEVICE;moduleType=_[p.MODBUS_TCP_SLAVE_DEVICE];constructor(e){super(e)}static fromPlain(e){return new b(e)}}var p=(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))(p||{});const _={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(){m.register("Ethernet",C),m.register("ModbusTCPServer",g),m.register("ModbusTCPClient",h),m.register("ModbusTCPSlaveDevice",b)}init(e){this.clear(),e.forEach(n=>{const r=m.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 O=[I,S,P,T],v={install(o,e){e&&o.provide(y,e),O.forEach(n=>{o.component(n.name,n)})}};s.Button2=B,s.EthernetProtocolItem=C,s.Input=S,s.InputNumber=P,s.IpInput=T,s.ModbusTCPClientProtocolItem=h,s.ModbusTCPServerProtocolItem=g,s.ModbusTCPSlaveDeviceProtocolItem=b,s.MyButton=I,s.ProtocolCollection=U,s.ProtocolItem=m,s.ProtocolType=p,s.UI_KEY=y,s.default=v,s.protocolMap=_,Object.defineProperties(s,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
@@ -0,0 +1,7 @@
1
+ export declare const useTheme: () => {
2
+ theme: import('..').ThemeConfig;
3
+ getColor: (key: string, defaultValue?: string) => any;
4
+ getSpacing: (key: string, defaultValue?: string) => any;
5
+ getBorderRadius: (key: string, defaultValue?: string) => any;
6
+ getFontSize: (key: string, defaultValue?: string) => any;
7
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lty-protocol",
3
- "version": "1.0.31",
3
+ "version": "1.0.32",
4
4
  "main": "dist/lty-protocol.umd.js",
5
5
  "module": "dist/lty-protocol.mjs",
6
6
  "style": "dist/lty-protocol.css",