secs4js 0.3.0 → 0.4.1

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.
Files changed (55) hide show
  1. package/LICENSE.md +20 -20
  2. package/README.md +84 -0
  3. package/lib/core/AbstractSecsCommunicator.d.ts +4 -0
  4. package/lib/core/AbstractSecsCommunicator.d.ts.map +1 -1
  5. package/lib/core/AbstractSecsCommunicator.js +70 -5
  6. package/lib/core/AbstractSecsCommunicator.js.map +1 -1
  7. package/lib/core/AbstractSecsMessage.js.map +1 -1
  8. package/lib/core/enums/HsmsSsControlType.js.map +1 -1
  9. package/lib/core/enums/RejectReason.js.map +1 -1
  10. package/lib/core/enums/SecsItemType.js.map +1 -1
  11. package/lib/core/enums/SelectStatus.js.map +1 -1
  12. package/lib/core/secs2item/AbstractSecs2Item.js.map +1 -1
  13. package/lib/core/secs2item/Secs2ItemAscii.js.map +1 -1
  14. package/lib/core/secs2item/Secs2ItemBinary.js.map +1 -1
  15. package/lib/core/secs2item/Secs2ItemBoolean.js.map +1 -1
  16. package/lib/core/secs2item/Secs2ItemFactory.js.map +1 -1
  17. package/lib/core/secs2item/Secs2ItemList.js.map +1 -1
  18. package/lib/core/secs2item/Secs2ItemNumeric.js.map +1 -1
  19. package/lib/core/secs2item/Secs2ItemParser.js.map +1 -1
  20. package/lib/gem/Clock.js.map +1 -1
  21. package/lib/gem/Gem.js.map +1 -1
  22. package/lib/helper/Secs2ItemHelper.js.map +1 -1
  23. package/lib/hsms/HsmsActiveCommunicator.d.ts.map +1 -1
  24. package/lib/hsms/HsmsActiveCommunicator.js +21 -5
  25. package/lib/hsms/HsmsActiveCommunicator.js.map +1 -1
  26. package/lib/hsms/HsmsCommunicator.d.ts +1 -0
  27. package/lib/hsms/HsmsCommunicator.d.ts.map +1 -1
  28. package/lib/hsms/HsmsCommunicator.js +72 -7
  29. package/lib/hsms/HsmsCommunicator.js.map +1 -1
  30. package/lib/hsms/HsmsMessage.js.map +1 -1
  31. package/lib/hsms/HsmsPassiveCommunicator.js.map +1 -1
  32. package/lib/hsms/enums/HsmsControlType.js.map +1 -1
  33. package/lib/hsms/enums/RejectReason.js.map +1 -1
  34. package/lib/hsms/enums/SelectStatus.js.map +1 -1
  35. package/lib/index.d.ts +2 -1
  36. package/lib/index.js +2 -1
  37. package/lib/logging/SecsLogger.d.ts +36 -0
  38. package/lib/logging/SecsLogger.d.ts.map +1 -0
  39. package/lib/logging/SecsLogger.js +415 -0
  40. package/lib/logging/SecsLogger.js.map +1 -0
  41. package/lib/secs1/Secs1Communicator.d.ts +1 -0
  42. package/lib/secs1/Secs1Communicator.d.ts.map +1 -1
  43. package/lib/secs1/Secs1Communicator.js +45 -8
  44. package/lib/secs1/Secs1Communicator.js.map +1 -1
  45. package/lib/secs1/Secs1Message.js.map +1 -1
  46. package/lib/secs1/Secs1MessageBlock.js.map +1 -1
  47. package/lib/secs1/Secs1OnTcpIpActiveCommunicator.d.ts.map +1 -1
  48. package/lib/secs1/Secs1OnTcpIpActiveCommunicator.js +13 -2
  49. package/lib/secs1/Secs1OnTcpIpActiveCommunicator.js.map +1 -1
  50. package/lib/secs1/Secs1OnTcpIpPassiveCommunicator.d.ts.map +1 -1
  51. package/lib/secs1/Secs1OnTcpIpPassiveCommunicator.js +10 -2
  52. package/lib/secs1/Secs1OnTcpIpPassiveCommunicator.js.map +1 -1
  53. package/lib/secs1/Secs1SerialCommunicator.js.map +1 -1
  54. package/lib/sml/SmlParser.js.map +1 -1
  55. package/package.json +15 -1
package/LICENSE.md CHANGED
@@ -1,20 +1,20 @@
1
- # MIT License
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- 'Software'), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ # MIT License
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ 'Software'), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -159,6 +159,33 @@ const parsedBody = SmlParser.parseBody(smlBody);
159
159
  console.log(parsedBody?.toSml());
160
160
  ```
161
161
 
162
+ ## Sending and Replying to Messages
163
+
164
+ In this library, you can actively send messages and passively reply to messages.
165
+
166
+ For actively sent messages, a new `SystemBytes` will be automatically generated. For reply messages, the `SystemBytes` from the primary message will be automatically read and used for the reply.
167
+
168
+ - **Send:** `send(stream: number, func: number, wBit: boolean, body?: AbstractSecs2Item)`
169
+ - **Reply:** `reply(primaryMsg: SecsMessage, stream: number, func: number, body?: AbstractSecs2Item)`
170
+
171
+ ```ts
172
+ active.on("message", (msg: SecsMessage) => {
173
+ void (async () => {
174
+ console.log(`Active received: ${msg.toSml()}`);
175
+
176
+ await active.send(2, 18, true, L());
177
+
178
+ if (msg.stream === 1 && msg.func === 1) {
179
+ await active.reply(msg, 1, 2, L(A("MDLN-A"), A("SOFTREV-1")));
180
+ }
181
+
182
+ if (msg.stream === 1 && msg.func === 13) {
183
+ await active.reply(msg, 1, 14, L(A("ACK")));
184
+ }
185
+ })();
186
+ });
187
+ ```
188
+
162
189
  ## HSMS-SS
163
190
 
164
191
  For HSMS-SS protocol support, you can act as the passive end (Equipment) or the active end (HOST/EAP).
@@ -433,6 +460,63 @@ async function TcpPassive() {
433
460
  }
434
461
  ```
435
462
 
463
+ ## GEM
464
+
465
+ This library provides partial `GEM` (Generic Equipment Model) support. You can access commonly used GEM methods through the `Gem` object.
466
+
467
+ ```ts
468
+ // 1. Set up equipment side (Passive)
469
+ const equipComm = new HsmsPassiveCommunicator({
470
+ ip: "127.0.0.1",
471
+ port: 5000,
472
+ deviceId: 1,
473
+ isEquip: true,
474
+ name: "Equipment",
475
+ });
476
+
477
+ // Use the GEM helper class (optional)
478
+ const equipGem = new Gem(equipComm);
479
+ equipGem.mdln = "MyEquip";
480
+ equipGem.softrev = "1.0.0";
481
+
482
+ equipComm.on("message", (msg: SecsMessage) => {
483
+ void (async () => {
484
+ console.log(`Passive received: ${msg.toSml()}`);
485
+
486
+ // Reply to Host using messages defined in the Generic Equipment Model
487
+ if (msg.stream === 1 && msg.func === 1) {
488
+ await equipGem.s1f2(msg);
489
+ }
490
+ })();
491
+ });
492
+ ```
493
+
494
+ ## Logging
495
+
496
+ Logging is implemented using the `Pino` library.
497
+
498
+ There are two types of logs: `DETAIL` logs that record all detailed information, and SECS-II `SML` logs that only record bidirectional communication. The default level for DETAIL logs is `DEBUG`, and the default level for SECS-II logs is `INFO`.
499
+
500
+ You can configure logging properties by passing the `log` configuration parameter when initializing the communicator.
501
+
502
+ ```ts
503
+ const active = new HsmsActiveCommunicator({
504
+ ip: "127.0.0.1",
505
+ port: 5000,
506
+ deviceId: 10,
507
+ isEquip: false,
508
+ log: {
509
+ enabled: true, // Whether to enable logging
510
+ console: true, // Whether to output logs to console
511
+ baseDir: "./secs4js-logs", // Path for log storage
512
+ retentionDays: 30, // Number of days to retain logs
513
+ detailLevel: "trace", // Level for DETAIL logs
514
+ secs2Level: "info", // Level for SECS-II logs
515
+ maxHexBytes: 65536, // Maximum number of hex bytes to record
516
+ },
517
+ });
518
+ ```
519
+
436
520
  ## Development
437
521
 
438
522
  If you are interested in this project, welcome to contribute your code!
@@ -1,5 +1,6 @@
1
1
  import { AbstractSecs2Item } from "./secs2item/AbstractSecs2Item.js";
2
2
  import { SecsMessage } from "./AbstractSecsMessage.js";
3
+ import { SecsLogger, SecsLoggerConfig } from "../logging/SecsLogger.js";
3
4
  import { EventEmitter } from "events";
4
5
 
5
6
  //#region src/core/AbstractSecsCommunicator.d.ts
@@ -33,6 +34,7 @@ interface SecsCommunicatorConfig {
33
34
  deviceId: number;
34
35
  isEquip: boolean;
35
36
  name?: string;
37
+ log?: SecsLoggerConfig;
36
38
  timeoutT1?: number;
37
39
  timeoutT2?: number;
38
40
  timeoutT3?: number;
@@ -46,6 +48,7 @@ declare abstract class AbstractSecsCommunicator<Events extends Record<keyof Even
46
48
  readonly deviceId: number;
47
49
  readonly isEquip: boolean;
48
50
  readonly name: string;
51
+ protected readonly logger: SecsLogger;
49
52
  timeoutT1: number;
50
53
  timeoutT2: number;
51
54
  timeoutT3: number;
@@ -65,6 +68,7 @@ declare abstract class AbstractSecsCommunicator<Events extends Record<keyof Even
65
68
  abstract close(): Promise<void>;
66
69
  protected emitInternal(eventName: string | symbol, ...args: unknown[]): boolean;
67
70
  protected abstract sendBuffer(buffer: Buffer): Promise<void>;
71
+ protected sendBufferWithLogs(direction: "Sent" | "Received", protocol: string, buffer: Buffer, meta?: Record<string, unknown>): Promise<void>;
68
72
  protected abstract createMessage(stream: number, func: number, wBit: boolean, body: AbstractSecs2Item | null, systemBytes: number): SecsMessage;
69
73
  send(stream: number, func: number, wBit: boolean, body?: AbstractSecs2Item | null): Promise<SecsMessage | null>;
70
74
  reply(primaryMsg: SecsMessage, stream: number, func: number, body?: AbstractSecs2Item | null): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"AbstractSecsCommunicator.d.ts","names":[],"sources":["../../src/core/AbstractSecsCommunicator.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAUA;AAoBA;AAcA;;AACgB,UAnCC,sBAAA,CAmCD;EAAkC,OAAA,EAAA,CAlCvC,WAkCuC,CAAA;EAChD,KAAA,EAAA,CAlCO,KAkCP,CAAA;EAmBgB,SAAA,EAAA,EAAA;EACD,YAAA,EAAA,EAAA;;;;;;;;;;;;;;;AAwFb,UA5Ha,sBAAA,CA4Hb;EAkB0B,QAAA,EAAA,MAAA;EA7HpB,OAAA,EAAA,OAAA;EAAY,IAAA,CAAA,EAAA,MAAA;;;;;;;;;;uBAHA,wCACN,aAAa,qBAAqB,yBAChD,gCACQ,YAAA;;;;;;;;;;;;;2BAec;mBAGN;kBACD;WACP,MAAA,CAAO;;sBAII;mBAeH;oBACC;;wCAgBoB,SAAS;sFAMxC,gDAEJ;2DAMI,2BACJ,QAAQ;oBAgCE,kDAGN,2BACJ;;+BAkB0B"}
1
+ {"version":3,"file":"AbstractSecsCommunicator.d.ts","names":[],"sources":["../../src/core/AbstractSecsCommunicator.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAWA;AAoBA;AAeA;;AACgB,UApCC,sBAAA,CAoCD;EAAkC,OAAA,EAAA,CAnCvC,WAmCuC,CAAA;EAChD,KAAA,EAAA,CAnCO,KAmCP,CAAA;EAK0B,SAAA,EAAA,EAAA;EAeV,YAAA,EAAA,EAAA;;;;;;;;;;;;;;;AAoEN,UAzGK,sBAAA,CAyGL;EAAR,QAAA,EAAA,MAAA;EAkEU,OAAA,EAAA,OAAA;EAGN,IAAA,CAAA,EAAA,MAAA;EACJ,GAAA,CAAA,EA3KG,gBA2KH;EAmC0B,SAAA,CAAA,EAAA,MAAA;EAhMpB,SAAA,CAAA,EAAA,MAAA;EAAY,SAAA,CAAA,EAAA,MAAA;;;;;;;uBAHA,wCACN,aAAa,qBAAqB,yBAChD,gCACQ,YAAA;;;;6BAIkB;;;;;;;;;;2BAYJ;mBAGN;kBACD;WACP,MAAA,CAAO;;sBAII;mBAoBH;oBACC;;wCAgBoB,SAAS;yFAKtC,eACD,0BACL;sFASI,gDAEJ;2DAMI,2BACJ,QAAQ;oBAkEE,kDAGN,2BACJ;;+BAmC0B"}
@@ -1,3 +1,4 @@
1
+ import { SecsLogger } from "../logging/SecsLogger.js";
1
2
  import { EventEmitter } from "events";
2
3
 
3
4
  //#region src/core/AbstractSecsCommunicator.ts
@@ -5,6 +6,7 @@ var AbstractSecsCommunicator = class extends EventEmitter {
5
6
  deviceId;
6
7
  isEquip;
7
8
  name;
9
+ logger;
8
10
  timeoutT1 = 1;
9
11
  timeoutT2 = 15;
10
12
  timeoutT3 = 45;
@@ -28,13 +30,33 @@ var AbstractSecsCommunicator = class extends EventEmitter {
28
30
  if (config.timeoutT6 !== void 0) this.timeoutT6 = config.timeoutT6;
29
31
  if (config.timeoutT7 !== void 0) this.timeoutT7 = config.timeoutT7;
30
32
  if (config.timeoutT8 !== void 0) this.timeoutT8 = config.timeoutT8;
33
+ this.logger = SecsLogger.create(config.log, {
34
+ name: this.name,
35
+ deviceId: this.deviceId,
36
+ isEquip: this.isEquip
37
+ });
31
38
  }
32
39
  emitInternal(eventName, ...args) {
33
40
  return super.emit.call(this, eventName, ...args);
34
41
  }
42
+ async sendBufferWithLogs(direction, protocol, buffer, meta) {
43
+ this.logger.logBytes(direction, protocol, buffer, meta);
44
+ await this.sendBuffer(buffer);
45
+ }
35
46
  async send(stream, func, wBit, body = null) {
36
47
  const systemBytes = this.getNextSystemBytes();
37
48
  const msg = this.createMessage(stream, func, wBit, body, systemBytes);
49
+ const sml = msg.toSml();
50
+ this.logger.logSecs2("Sent", sml);
51
+ this.logger.detail.debug({
52
+ protocol: "SECS",
53
+ dir: "Sent",
54
+ stream,
55
+ func,
56
+ wBit,
57
+ systemBytes,
58
+ sml
59
+ }, "sml");
38
60
  if (wBit) return new Promise((resolve, reject) => {
39
61
  const timer = setTimeout(() => {
40
62
  if (this._transactions.has(systemBytes)) {
@@ -47,28 +69,71 @@ var AbstractSecsCommunicator = class extends EventEmitter {
47
69
  reject,
48
70
  timer
49
71
  });
50
- this.sendBuffer(msg.toBuffer()).catch((err) => {
72
+ this.sendBufferWithLogs("Sent", "SECS", msg.toBuffer(), {
73
+ stream,
74
+ func,
75
+ wBit,
76
+ systemBytes
77
+ }).catch((err) => {
51
78
  clearTimeout(timer);
52
79
  this._transactions.delete(systemBytes);
80
+ this.logger.detail.error({
81
+ err: err instanceof Error ? err : new Error(String(err)),
82
+ stream,
83
+ func,
84
+ wBit,
85
+ systemBytes
86
+ }, "send failed");
53
87
  reject(err instanceof Error ? err : new Error(String(err)));
54
88
  });
55
89
  });
56
90
  else {
57
- await this.sendBuffer(msg.toBuffer());
91
+ await this.sendBufferWithLogs("Sent", "SECS", msg.toBuffer(), {
92
+ stream,
93
+ func,
94
+ wBit,
95
+ systemBytes
96
+ });
58
97
  return null;
59
98
  }
60
99
  }
61
100
  async reply(primaryMsg, stream, func, body = null) {
62
101
  const msg = this.createMessage(stream, func, false, body, primaryMsg.systemBytes);
63
- console.log("Reply Buffer:", msg.toBuffer());
64
- console.log(`Reply: ${msg.toSml()}`);
65
- await this.sendBuffer(msg.toBuffer());
102
+ const sml = msg.toSml();
103
+ this.logger.logSecs2("Sent", sml);
104
+ this.logger.detail.debug({
105
+ protocol: "SECS",
106
+ dir: "Sent",
107
+ stream,
108
+ func,
109
+ wBit: false,
110
+ systemBytes: primaryMsg.systemBytes,
111
+ sml
112
+ }, "sml");
113
+ await this.sendBufferWithLogs("Sent", "SECS", msg.toBuffer(), {
114
+ stream,
115
+ func,
116
+ wBit: false,
117
+ systemBytes: primaryMsg.systemBytes
118
+ });
66
119
  }
67
120
  getNextSystemBytes() {
68
121
  this._systemBytesCounter = this._systemBytesCounter + 1 >>> 0;
69
122
  return this._systemBytesCounter;
70
123
  }
71
124
  handleMessage(msg) {
125
+ const sml = msg.toSml();
126
+ this.logger.logSecs2("Received", sml);
127
+ this.logger.detail.debug({
128
+ protocol: "SECS",
129
+ dir: "Received",
130
+ stream: msg.stream,
131
+ func: msg.func,
132
+ wBit: msg.wBit,
133
+ systemBytes: msg.systemBytes,
134
+ deviceId: msg.deviceId,
135
+ sml
136
+ }, "message");
72
137
  const tx = this._transactions.get(msg.systemBytes);
73
138
  if (tx) {
74
139
  clearTimeout(tx.timer);
@@ -1 +1 @@
1
- {"version":3,"file":"AbstractSecsCommunicator.js","names":[],"sources":["../../src/core/AbstractSecsCommunicator.ts"],"sourcesContent":["import { EventEmitter } from \"events\";\nimport { SecsMessage } from \"./AbstractSecsMessage.js\";\nimport { AbstractSecs2Item } from \"./secs2item/AbstractSecs2Item.js\";\n\n/**\n * @param message The message received.\n * @param error The error occurred.\n * @param connected The connection is established.\n * @param disconnected The connection is closed.\n */\nexport interface SecsCommunicatorEvents {\n\tmessage: [SecsMessage];\n\terror: [Error];\n\tconnected: [];\n\tdisconnected: [];\n}\n\n/**\n * @param deviceId The device ID.\n * @param isEquip Whether the device is an equip.\n * @param name The name of the connection.\n * @param timeoutT1 Only SECS-I supports this parameter, ENQ retransmission interval.\n * @param timeoutT2 Only SECS-I supports this parameter, ENQ wait-for-response timeout.\n * @param timeoutT3 Support SECS-I and SECS-II, W-Bit timeout.\n * @param timeoutT4 Only SECS-I supports this parameter, data block retransmission interval.\n * @param timeoutT5 Support SECS-I and SECS-II, establishment of communication session timeout.\n * @param timeoutT6 Only HSMS supports this parameter, reply control message timeout.\n * @param timeoutT7 Only HSMS supports this parameter, create connection timeout.\n * @param timeoutT8 Only HSMS supports this parameter, the maximum time interval between message bytes when receiving a message\n */\nexport interface SecsCommunicatorConfig {\n\tdeviceId: number;\n\tisEquip: boolean;\n\tname?: string;\n\ttimeoutT1?: number;\n\ttimeoutT2?: number;\n\ttimeoutT3?: number;\n\ttimeoutT4?: number;\n\ttimeoutT5?: number;\n\ttimeoutT6?: number;\n\ttimeoutT7?: number;\n\ttimeoutT8?: number;\n}\n\nexport abstract class AbstractSecsCommunicator<\n\tEvents extends Record<keyof Events, unknown[]> & SecsCommunicatorEvents =\n\t\tSecsCommunicatorEvents,\n> extends EventEmitter {\n\tpublic readonly deviceId: number;\n\tpublic readonly isEquip: boolean;\n\tpublic readonly name: string;\n\n\tpublic timeoutT1 = 1;\n\tpublic timeoutT2 = 15;\n\tpublic timeoutT3 = 45;\n\tpublic timeoutT4 = 45;\n\tpublic timeoutT5 = 10;\n\tpublic timeoutT6 = 5;\n\tpublic timeoutT7 = 10;\n\tpublic timeoutT8 = 5;\n\n\tprotected _systemBytesCounter = 0;\n\tprotected _transactions = new Map<\n\t\tnumber,\n\t\t{\n\t\t\tresolve: (msg: SecsMessage) => void;\n\t\t\treject: (err: Error) => void;\n\t\t\ttimer: NodeJS.Timeout;\n\t\t}\n\t>();\n\n\tconstructor(config: SecsCommunicatorConfig) {\n\t\tsuper();\n\t\tthis.deviceId = config.deviceId;\n\t\tthis.isEquip = config.isEquip;\n\t\tthis.name = config.name ?? \"SecsCommunicator\";\n\t\tif (config.timeoutT1 !== undefined) this.timeoutT1 = config.timeoutT1;\n\t\tif (config.timeoutT2 !== undefined) this.timeoutT2 = config.timeoutT2;\n\t\tif (config.timeoutT3 !== undefined) this.timeoutT3 = config.timeoutT3;\n\t\tif (config.timeoutT4 !== undefined) this.timeoutT4 = config.timeoutT4;\n\t\tif (config.timeoutT5 !== undefined) this.timeoutT5 = config.timeoutT5;\n\t\tif (config.timeoutT6 !== undefined) this.timeoutT6 = config.timeoutT6;\n\t\tif (config.timeoutT7 !== undefined) this.timeoutT7 = config.timeoutT7;\n\t\tif (config.timeoutT8 !== undefined) this.timeoutT8 = config.timeoutT8;\n\t}\n\n\tabstract open(): Promise<void>;\n\tabstract close(): Promise<void>;\n\n\tprotected emitInternal(\n\t\teventName: string | symbol,\n\t\t...args: unknown[]\n\t): boolean {\n\t\treturn (\n\t\t\tsuper.emit as (\n\t\t\t\tthis: AbstractSecsCommunicator<Events>,\n\t\t\t\teventName: string | symbol,\n\t\t\t\t...args: unknown[]\n\t\t\t) => boolean\n\t\t).call(this, eventName, ...args);\n\t}\n\n\t// This method sends the message bytes. To be implemented by subclasses.\n\tprotected abstract sendBuffer(buffer: Buffer): Promise<void>;\n\n\tprotected abstract createMessage(\n\t\tstream: number,\n\t\tfunc: number,\n\t\twBit: boolean,\n\t\tbody: AbstractSecs2Item | null,\n\t\tsystemBytes: number,\n\t): SecsMessage;\n\n\tasync send(\n\t\tstream: number,\n\t\tfunc: number,\n\t\twBit: boolean,\n\t\tbody: AbstractSecs2Item | null = null,\n\t): Promise<SecsMessage | null> {\n\t\tconst systemBytes = this.getNextSystemBytes();\n\t\tconst msg = this.createMessage(stream, func, wBit, body, systemBytes);\n\n\t\tif (wBit) {\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tconst timer = setTimeout(() => {\n\t\t\t\t\tif (this._transactions.has(systemBytes)) {\n\t\t\t\t\t\tthis._transactions.delete(systemBytes);\n\t\t\t\t\t\treject(\n\t\t\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\t\t`T3 Timeout waiting for reply to S${String(stream)}F${String(func)} [SysBytes=${String(systemBytes)}]`,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}, this.timeoutT3 * 1000);\n\n\t\t\t\tthis._transactions.set(systemBytes, { resolve, reject, timer });\n\n\t\t\t\tthis.sendBuffer(msg.toBuffer()).catch((err: unknown) => {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\tthis._transactions.delete(systemBytes);\n\t\t\t\t\treject(err instanceof Error ? err : new Error(String(err)));\n\t\t\t\t});\n\t\t\t});\n\t\t} else {\n\t\t\tawait this.sendBuffer(msg.toBuffer());\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tasync reply(\n\t\tprimaryMsg: SecsMessage,\n\t\tstream: number,\n\t\tfunc: number,\n\t\tbody: AbstractSecs2Item | null = null,\n\t): Promise<void> {\n\t\tconst msg = this.createMessage(\n\t\t\tstream,\n\t\t\tfunc,\n\t\t\tfalse,\n\t\t\tbody,\n\t\t\tprimaryMsg.systemBytes,\n\t\t);\n\t\tconsole.log(\"Reply Buffer:\", msg.toBuffer());\n\t\tconsole.log(`Reply: ${msg.toSml()}`);\n\t\tawait this.sendBuffer(msg.toBuffer());\n\t}\n\n\tprotected getNextSystemBytes(): number {\n\t\tthis._systemBytesCounter = (this._systemBytesCounter + 1) >>> 0; // Ensure 32-bit unsigned\n\t\treturn this._systemBytesCounter;\n\t}\n\n\tprotected handleMessage(msg: SecsMessage) {\n\t\t// Check if it's a reply\n\t\t// Usually, if we have a transaction waiting for this SystemBytes, we treat it as a reply.\n\t\t// However, Stream 0 (HSMS Control) messages are never replies to SECS-II messages.\n\t\t// SECS-II replies usually have the same SystemBytes as the primary.\n\n\t\tconst tx = this._transactions.get(msg.systemBytes);\n\t\tif (tx) {\n\t\t\tclearTimeout(tx.timer);\n\t\t\tthis._transactions.delete(msg.systemBytes);\n\t\t\ttx.resolve(msg);\n\t\t\treturn;\n\t\t}\n\n\t\t// If not a reply, emit event\n\t\tthis.emitInternal(\"message\", msg);\n\t}\n}\n"],"mappings":";;;AA4CA,IAAsB,2BAAtB,cAGU,aAAa;CACtB,AAAgB;CAChB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IAAK;AAEzB,QAAK,cAAc,IAAI,aAAa;IAAE;IAAS;IAAQ;IAAO,CAAC;AAE/D,QAAK,WAAW,IAAI,UAAU,CAAC,CAAC,OAAO,QAAiB;AACvD,iBAAa,MAAM;AACnB,SAAK,cAAc,OAAO,YAAY;AACtC,WAAO,eAAe,QAAQ,MAAM,IAAI,MAAM,OAAO,IAAI,CAAC,CAAC;KAC1D;IACD;OACI;AACN,SAAM,KAAK,WAAW,IAAI,UAAU,CAAC;AACrC,UAAO;;;CAIT,MAAM,MACL,YACA,QACA,MACA,OAAiC,MACjB;EAChB,MAAM,MAAM,KAAK,cAChB,QACA,MACA,OACA,MACA,WAAW,YACX;AACD,UAAQ,IAAI,iBAAiB,IAAI,UAAU,CAAC;AAC5C,UAAQ,IAAI,UAAU,IAAI,OAAO,GAAG;AACpC,QAAM,KAAK,WAAW,IAAI,UAAU,CAAC;;CAGtC,AAAU,qBAA6B;AACtC,OAAK,sBAAuB,KAAK,sBAAsB,MAAO;AAC9D,SAAO,KAAK;;CAGb,AAAU,cAAc,KAAkB;EAMzC,MAAM,KAAK,KAAK,cAAc,IAAI,IAAI,YAAY;AAClD,MAAI,IAAI;AACP,gBAAa,GAAG,MAAM;AACtB,QAAK,cAAc,OAAO,IAAI,YAAY;AAC1C,MAAG,QAAQ,IAAI;AACf;;AAID,OAAK,aAAa,WAAW,IAAI"}
1
+ {"version":3,"file":"AbstractSecsCommunicator.js","names":[],"sources":["../../src/core/AbstractSecsCommunicator.ts"],"sourcesContent":["import { EventEmitter } from \"events\";\nimport { SecsMessage } from \"./AbstractSecsMessage.js\";\nimport { AbstractSecs2Item } from \"./secs2item/AbstractSecs2Item.js\";\nimport { SecsLogger, type SecsLoggerConfig } from \"../logging/SecsLogger.js\";\n\n/**\n * @param message The message received.\n * @param error The error occurred.\n * @param connected The connection is established.\n * @param disconnected The connection is closed.\n */\nexport interface SecsCommunicatorEvents {\n\tmessage: [SecsMessage];\n\terror: [Error];\n\tconnected: [];\n\tdisconnected: [];\n}\n\n/**\n * @param deviceId The device ID.\n * @param isEquip Whether the device is an equip.\n * @param name The name of the connection.\n * @param timeoutT1 Only SECS-I supports this parameter, ENQ retransmission interval.\n * @param timeoutT2 Only SECS-I supports this parameter, ENQ wait-for-response timeout.\n * @param timeoutT3 Support SECS-I and SECS-II, W-Bit timeout.\n * @param timeoutT4 Only SECS-I supports this parameter, data block retransmission interval.\n * @param timeoutT5 Support SECS-I and SECS-II, establishment of communication session timeout.\n * @param timeoutT6 Only HSMS supports this parameter, reply control message timeout.\n * @param timeoutT7 Only HSMS supports this parameter, create connection timeout.\n * @param timeoutT8 Only HSMS supports this parameter, the maximum time interval between message bytes when receiving a message\n */\nexport interface SecsCommunicatorConfig {\n\tdeviceId: number;\n\tisEquip: boolean;\n\tname?: string;\n\tlog?: SecsLoggerConfig;\n\ttimeoutT1?: number;\n\ttimeoutT2?: number;\n\ttimeoutT3?: number;\n\ttimeoutT4?: number;\n\ttimeoutT5?: number;\n\ttimeoutT6?: number;\n\ttimeoutT7?: number;\n\ttimeoutT8?: number;\n}\n\nexport abstract class AbstractSecsCommunicator<\n\tEvents extends Record<keyof Events, unknown[]> & SecsCommunicatorEvents =\n\t\tSecsCommunicatorEvents,\n> extends EventEmitter {\n\tpublic readonly deviceId: number;\n\tpublic readonly isEquip: boolean;\n\tpublic readonly name: string;\n\tprotected readonly logger: SecsLogger;\n\n\tpublic timeoutT1 = 1;\n\tpublic timeoutT2 = 15;\n\tpublic timeoutT3 = 45;\n\tpublic timeoutT4 = 45;\n\tpublic timeoutT5 = 10;\n\tpublic timeoutT6 = 5;\n\tpublic timeoutT7 = 10;\n\tpublic timeoutT8 = 5;\n\n\tprotected _systemBytesCounter = 0;\n\tprotected _transactions = new Map<\n\t\tnumber,\n\t\t{\n\t\t\tresolve: (msg: SecsMessage) => void;\n\t\t\treject: (err: Error) => void;\n\t\t\ttimer: NodeJS.Timeout;\n\t\t}\n\t>();\n\n\tconstructor(config: SecsCommunicatorConfig) {\n\t\tsuper();\n\t\tthis.deviceId = config.deviceId;\n\t\tthis.isEquip = config.isEquip;\n\t\tthis.name = config.name ?? \"SecsCommunicator\";\n\t\tif (config.timeoutT1 !== undefined) this.timeoutT1 = config.timeoutT1;\n\t\tif (config.timeoutT2 !== undefined) this.timeoutT2 = config.timeoutT2;\n\t\tif (config.timeoutT3 !== undefined) this.timeoutT3 = config.timeoutT3;\n\t\tif (config.timeoutT4 !== undefined) this.timeoutT4 = config.timeoutT4;\n\t\tif (config.timeoutT5 !== undefined) this.timeoutT5 = config.timeoutT5;\n\t\tif (config.timeoutT6 !== undefined) this.timeoutT6 = config.timeoutT6;\n\t\tif (config.timeoutT7 !== undefined) this.timeoutT7 = config.timeoutT7;\n\t\tif (config.timeoutT8 !== undefined) this.timeoutT8 = config.timeoutT8;\n\t\tthis.logger = SecsLogger.create(config.log, {\n\t\t\tname: this.name,\n\t\t\tdeviceId: this.deviceId,\n\t\t\tisEquip: this.isEquip,\n\t\t});\n\t}\n\n\tabstract open(): Promise<void>;\n\tabstract close(): Promise<void>;\n\n\tprotected emitInternal(\n\t\teventName: string | symbol,\n\t\t...args: unknown[]\n\t): boolean {\n\t\treturn (\n\t\t\tsuper.emit as (\n\t\t\t\tthis: AbstractSecsCommunicator<Events>,\n\t\t\t\teventName: string | symbol,\n\t\t\t\t...args: unknown[]\n\t\t\t) => boolean\n\t\t).call(this, eventName, ...args);\n\t}\n\n\t// This method sends the message bytes. To be implemented by subclasses.\n\tprotected abstract sendBuffer(buffer: Buffer): Promise<void>;\n\n\tprotected async sendBufferWithLogs(\n\t\tdirection: \"Sent\" | \"Received\",\n\t\tprotocol: string,\n\t\tbuffer: Buffer,\n\t\tmeta?: Record<string, unknown>,\n\t): Promise<void> {\n\t\tthis.logger.logBytes(direction, protocol, buffer, meta);\n\t\tawait this.sendBuffer(buffer);\n\t}\n\n\tprotected abstract createMessage(\n\t\tstream: number,\n\t\tfunc: number,\n\t\twBit: boolean,\n\t\tbody: AbstractSecs2Item | null,\n\t\tsystemBytes: number,\n\t): SecsMessage;\n\n\tasync send(\n\t\tstream: number,\n\t\tfunc: number,\n\t\twBit: boolean,\n\t\tbody: AbstractSecs2Item | null = null,\n\t): Promise<SecsMessage | null> {\n\t\tconst systemBytes = this.getNextSystemBytes();\n\t\tconst msg = this.createMessage(stream, func, wBit, body, systemBytes);\n\t\tconst sml = msg.toSml();\n\t\tthis.logger.logSecs2(\"Sent\", sml);\n\t\tthis.logger.detail.debug(\n\t\t\t{\n\t\t\t\tprotocol: \"SECS\",\n\t\t\t\tdir: \"Sent\",\n\t\t\t\tstream,\n\t\t\t\tfunc,\n\t\t\t\twBit,\n\t\t\t\tsystemBytes,\n\t\t\t\tsml,\n\t\t\t},\n\t\t\t\"sml\",\n\t\t);\n\n\t\tif (wBit) {\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tconst timer = setTimeout(() => {\n\t\t\t\t\tif (this._transactions.has(systemBytes)) {\n\t\t\t\t\t\tthis._transactions.delete(systemBytes);\n\t\t\t\t\t\treject(\n\t\t\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\t\t`T3 Timeout waiting for reply to S${String(stream)}F${String(func)} [SysBytes=${String(systemBytes)}]`,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}, this.timeoutT3 * 1000);\n\n\t\t\t\tthis._transactions.set(systemBytes, { resolve, reject, timer });\n\n\t\t\t\tthis.sendBufferWithLogs(\"Sent\", \"SECS\", msg.toBuffer(), {\n\t\t\t\t\tstream,\n\t\t\t\t\tfunc,\n\t\t\t\t\twBit,\n\t\t\t\t\tsystemBytes,\n\t\t\t\t}).catch((err: unknown) => {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\tthis._transactions.delete(systemBytes);\n\t\t\t\t\tthis.logger.detail.error(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\terr: err instanceof Error ? err : new Error(String(err)),\n\t\t\t\t\t\t\tstream,\n\t\t\t\t\t\t\tfunc,\n\t\t\t\t\t\t\twBit,\n\t\t\t\t\t\t\tsystemBytes,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"send failed\",\n\t\t\t\t\t);\n\t\t\t\t\treject(err instanceof Error ? err : new Error(String(err)));\n\t\t\t\t});\n\t\t\t});\n\t\t} else {\n\t\t\tawait this.sendBufferWithLogs(\"Sent\", \"SECS\", msg.toBuffer(), {\n\t\t\t\tstream,\n\t\t\t\tfunc,\n\t\t\t\twBit,\n\t\t\t\tsystemBytes,\n\t\t\t});\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tasync reply(\n\t\tprimaryMsg: SecsMessage,\n\t\tstream: number,\n\t\tfunc: number,\n\t\tbody: AbstractSecs2Item | null = null,\n\t): Promise<void> {\n\t\tconst msg = this.createMessage(\n\t\t\tstream,\n\t\t\tfunc,\n\t\t\tfalse,\n\t\t\tbody,\n\t\t\tprimaryMsg.systemBytes,\n\t\t);\n\t\tconst sml = msg.toSml();\n\t\tthis.logger.logSecs2(\"Sent\", sml);\n\t\tthis.logger.detail.debug(\n\t\t\t{\n\t\t\t\tprotocol: \"SECS\",\n\t\t\t\tdir: \"Sent\",\n\t\t\t\tstream,\n\t\t\t\tfunc,\n\t\t\t\twBit: false,\n\t\t\t\tsystemBytes: primaryMsg.systemBytes,\n\t\t\t\tsml,\n\t\t\t},\n\t\t\t\"sml\",\n\t\t);\n\t\tawait this.sendBufferWithLogs(\"Sent\", \"SECS\", msg.toBuffer(), {\n\t\t\tstream,\n\t\t\tfunc,\n\t\t\twBit: false,\n\t\t\tsystemBytes: primaryMsg.systemBytes,\n\t\t});\n\t}\n\n\tprotected getNextSystemBytes(): number {\n\t\tthis._systemBytesCounter = (this._systemBytesCounter + 1) >>> 0; // Ensure 32-bit unsigned\n\t\treturn this._systemBytesCounter;\n\t}\n\n\tprotected handleMessage(msg: SecsMessage) {\n\t\tconst sml = msg.toSml();\n\t\tthis.logger.logSecs2(\"Received\", sml);\n\t\tthis.logger.detail.debug(\n\t\t\t{\n\t\t\t\tprotocol: \"SECS\",\n\t\t\t\tdir: \"Received\",\n\t\t\t\tstream: msg.stream,\n\t\t\t\tfunc: msg.func,\n\t\t\t\twBit: msg.wBit,\n\t\t\t\tsystemBytes: msg.systemBytes,\n\t\t\t\tdeviceId: msg.deviceId,\n\t\t\t\tsml,\n\t\t\t},\n\t\t\t\"message\",\n\t\t);\n\t\t// Check if it's a reply\n\t\t// Usually, if we have a transaction waiting for this SystemBytes, we treat it as a reply.\n\t\t// However, Stream 0 (HSMS Control) messages are never replies to SECS-II messages.\n\t\t// SECS-II replies usually have the same SystemBytes as the primary.\n\n\t\tconst tx = this._transactions.get(msg.systemBytes);\n\t\tif (tx) {\n\t\t\tclearTimeout(tx.timer);\n\t\t\tthis._transactions.delete(msg.systemBytes);\n\t\t\ttx.resolve(msg);\n\t\t\treturn;\n\t\t}\n\n\t\t// If not a reply, emit event\n\t\tthis.emitInternal(\"message\", msg);\n\t}\n}\n"],"mappings":";;;;AA8CA,IAAsB,2BAAtB,cAGU,aAAa;CACtB,AAAgB;CAChB,AAAgB;CAChB,AAAgB;CAChB,AAAmB;CAEnB,AAAO,YAAY;CACnB,AAAO,YAAY;CACnB,AAAO,YAAY;CACnB,AAAO,YAAY;CACnB,AAAO,YAAY;CACnB,AAAO,YAAY;CACnB,AAAO,YAAY;CACnB,AAAO,YAAY;CAEnB,AAAU,sBAAsB;CAChC,AAAU,gCAAgB,IAAI,KAO3B;CAEH,YAAY,QAAgC;AAC3C,SAAO;AACP,OAAK,WAAW,OAAO;AACvB,OAAK,UAAU,OAAO;AACtB,OAAK,OAAO,OAAO,QAAQ;AAC3B,MAAI,OAAO,cAAc,OAAW,MAAK,YAAY,OAAO;AAC5D,MAAI,OAAO,cAAc,OAAW,MAAK,YAAY,OAAO;AAC5D,MAAI,OAAO,cAAc,OAAW,MAAK,YAAY,OAAO;AAC5D,MAAI,OAAO,cAAc,OAAW,MAAK,YAAY,OAAO;AAC5D,MAAI,OAAO,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QAAQ,IAAI;AACf;;AAID,OAAK,aAAa,WAAW,IAAI"}
@@ -1 +1 @@
1
- {"version":3,"file":"AbstractSecsMessage.js","names":["stream: number","func: number","wBit: boolean","body: AbstractSecs2Item | null"],"sources":["../../src/core/AbstractSecsMessage.ts"],"sourcesContent":["import { AbstractSecs2Item } from \"./secs2item/AbstractSecs2Item.js\";\n\n/**\n * @param stream The stream number.\n * @param func The function number.\n * @param wBit Whether the message is a request.\n * @param body The body of the message.\n * @param systemBytes The system bytes.\n * @param deviceId The device ID.\n */\nexport class SecsMessage {\n\tconstructor(\n\t\tpublic readonly stream: number,\n\t\tpublic readonly func: number,\n\t\tpublic readonly wBit: boolean,\n\t\tpublic readonly body: AbstractSecs2Item | null = null,\n\t\tpublic readonly systemBytes = 0, // Typically 4 bytes, treated as integer for convenience if it fits, or Buffer\n\t\tpublic readonly deviceId = 0,\n\t) {\n\t\tif (stream < 0 || stream > 127) throw new Error(\"Stream must be 0-127\");\n\t\tif (func < 0 || func > 255) throw new Error(\"Function must be 0-255\");\n\t}\n\n\t/**\n\t * @description Returns the SML representation of the message.\n\t * @returns The SML representation.\n\t */\n\ttoSml(): string {\n\t\tconst wBitStr = this.wBit ? \"W\" : \"\";\n\t\tconst header = `S${this.stream.toString()}F${this.func.toString()} ${wBitStr}`;\n\t\tif (this.body) {\n\t\t\treturn `${header}\\n${this.body.toSml()}.`;\n\t\t}\n\t\treturn `${header}.`;\n\t}\n\n\t/**\n\t * @description Returns the binary representation of the message.\n\t * @returns The binary representation.\n\t */\n\ttoBuffer(): Buffer {\n\t\tconst header = Buffer.from([\n\t\t\t0x02, // SML header\n\t\t\tthis.stream,\n\t\t\tthis.func,\n\t\t\tthis.wBit ? 0x80 : 0x00,\n\t\t]);\n\t\tconst body = this.body?.toBuffer() ?? Buffer.alloc(0);\n\t\tconst systemBytes =\n\t\t\ttypeof this.systemBytes === \"number\"\n\t\t\t\t? Buffer.from([\n\t\t\t\t\t\tthis.systemBytes >>> 24,\n\t\t\t\t\t\t(this.systemBytes >>> 16) & 0xff,\n\t\t\t\t\t\t(this.systemBytes >>> 8) & 0xff,\n\t\t\t\t\t\tthis.systemBytes & 0xff,\n\t\t\t\t\t])\n\t\t\t\t: this.systemBytes;\n\t\tconst deviceId = Buffer.from([\n\t\t\tthis.deviceId >>> 24,\n\t\t\t(this.deviceId >>> 16) & 0xff,\n\t\t\t(this.deviceId >>> 8) & 0xff,\n\t\t\tthis.deviceId & 0xff,\n\t\t]);\n\t\treturn Buffer.concat([header, systemBytes, deviceId, body]);\n\t}\n}\n"],"mappings":";;;;;;;;;AAUA,IAAa,cAAb,MAAyB;CACxB,YACC,AAAgBA,QAChB,AAAgBC,MAChB,AAAgBC,MAChB,AAAgBC,OAAiC,MACjD,AAAgB,cAAc,GAC9B,AAAgB,WAAW,GAC1B;EANe;EACA;EACA;EACA;EACA;EACA;AAEhB,MAAI,SAAS,KAAK,SAAS,IAAK,OAAM,IAAI,MAAM,uBAAuB;AACvE,MAAI,OAAO,KAAK,OAAO,IAAK,OAAM,IAAI,MAAM,yBAAyB;;;;;;CAOtE,QAAgB;EACf,MAAM,UAAU,KAAK,OAAO,MAAM;EAClC,MAAM,SAAS,IAAI,KAAK,OAAO,UAAU,CAAC,GAAG,KAAK,KAAK,UAAU,CAAC,GAAG;AACrE,MAAI,KAAK,KACR,QAAO,GAAG,OAAO,IAAI,KAAK,KAAK,OAAO,CAAC;AAExC,SAAO,GAAG,OAAO;;;;;;CAOlB,WAAmB;EAClB,MAAM,SAAS,OAAO,KAAK;GAC1B;GACA,KAAK;GACL,KAAK;GACL,KAAK,OAAO,MAAO;GACnB,CAAC;EACF,MAAM,OAAO,KAAK,MAAM,UAAU,IAAI,OAAO,MAAM,EAAE;EACrD,MAAM,cACL,OAAO,KAAK,gBAAgB,WACzB,OAAO,KAAK;GACZ,KAAK,gBAAgB;GACpB,KAAK,gBAAgB,KAAM;GAC3B,KAAK,gBAAgB,IAAK;GAC3B,KAAK,cAAc;GACnB,CAAC,GACD,KAAK;EACT,MAAM,WAAW,OAAO,KAAK;GAC5B,KAAK,aAAa;GACjB,KAAK,aAAa,KAAM;GACxB,KAAK,aAAa,IAAK;GACxB,KAAK,WAAW;GAChB,CAAC;AACF,SAAO,OAAO,OAAO;GAAC;GAAQ;GAAa;GAAU;GAAK,CAAC"}
1
+ {"version":3,"file":"AbstractSecsMessage.js","names":["stream: number","func: number","wBit: boolean","body: AbstractSecs2Item | null"],"sources":["../../src/core/AbstractSecsMessage.ts"],"sourcesContent":["import { AbstractSecs2Item } from \"./secs2item/AbstractSecs2Item.js\";\r\n\r\n/**\r\n * @param stream The stream number.\r\n * @param func The function number.\r\n * @param wBit Whether the message is a request.\r\n * @param body The body of the message.\r\n * @param systemBytes The system bytes.\r\n * @param deviceId The device ID.\r\n */\r\nexport class SecsMessage {\r\n\tconstructor(\r\n\t\tpublic readonly stream: number,\r\n\t\tpublic readonly func: number,\r\n\t\tpublic readonly wBit: boolean,\r\n\t\tpublic readonly body: AbstractSecs2Item | null = null,\r\n\t\tpublic readonly systemBytes = 0, // Typically 4 bytes, treated as integer for convenience if it fits, or Buffer\r\n\t\tpublic readonly deviceId = 0,\r\n\t) {\r\n\t\tif (stream < 0 || stream > 127) throw new Error(\"Stream must be 0-127\");\r\n\t\tif (func < 0 || func > 255) throw new Error(\"Function must be 0-255\");\r\n\t}\r\n\r\n\t/**\r\n\t * @description Returns the SML representation of the message.\r\n\t * @returns The SML representation.\r\n\t */\r\n\ttoSml(): string {\r\n\t\tconst wBitStr = this.wBit ? \"W\" : \"\";\r\n\t\tconst header = `S${this.stream.toString()}F${this.func.toString()} ${wBitStr}`;\r\n\t\tif (this.body) {\r\n\t\t\treturn `${header}\\n${this.body.toSml()}.`;\r\n\t\t}\r\n\t\treturn `${header}.`;\r\n\t}\r\n\r\n\t/**\r\n\t * @description Returns the binary representation of the message.\r\n\t * @returns The binary representation.\r\n\t */\r\n\ttoBuffer(): Buffer {\r\n\t\tconst header = Buffer.from([\r\n\t\t\t0x02, // SML header\r\n\t\t\tthis.stream,\r\n\t\t\tthis.func,\r\n\t\t\tthis.wBit ? 0x80 : 0x00,\r\n\t\t]);\r\n\t\tconst body = this.body?.toBuffer() ?? Buffer.alloc(0);\r\n\t\tconst systemBytes =\r\n\t\t\ttypeof this.systemBytes === \"number\"\r\n\t\t\t\t? Buffer.from([\r\n\t\t\t\t\t\tthis.systemBytes >>> 24,\r\n\t\t\t\t\t\t(this.systemBytes >>> 16) & 0xff,\r\n\t\t\t\t\t\t(this.systemBytes >>> 8) & 0xff,\r\n\t\t\t\t\t\tthis.systemBytes & 0xff,\r\n\t\t\t\t\t])\r\n\t\t\t\t: this.systemBytes;\r\n\t\tconst deviceId = Buffer.from([\r\n\t\t\tthis.deviceId >>> 24,\r\n\t\t\t(this.deviceId >>> 16) & 0xff,\r\n\t\t\t(this.deviceId >>> 8) & 0xff,\r\n\t\t\tthis.deviceId & 0xff,\r\n\t\t]);\r\n\t\treturn Buffer.concat([header, systemBytes, deviceId, body]);\r\n\t}\r\n}\r\n"],"mappings":";;;;;;;;;AAUA,IAAa,cAAb,MAAyB;CACxB,YACC,AAAgBA,QAChB,AAAgBC,MAChB,AAAgBC,MAChB,AAAgBC,OAAiC,MACjD,AAAgB,cAAc,GAC9B,AAAgB,WAAW,GAC1B;EANe;EACA;EACA;EACA;EACA;EACA;AAEhB,MAAI,SAAS,KAAK,SAAS,IAAK,OAAM,IAAI,MAAM,uBAAuB;AACvE,MAAI,OAAO,KAAK,OAAO,IAAK,OAAM,IAAI,MAAM,yBAAyB;;;;;;CAOtE,QAAgB;EACf,MAAM,UAAU,KAAK,OAAO,MAAM;EAClC,MAAM,SAAS,IAAI,KAAK,OAAO,UAAU,CAAC,GAAG,KAAK,KAAK,UAAU,CAAC,GAAG;AACrE,MAAI,KAAK,KACR,QAAO,GAAG,OAAO,IAAI,KAAK,KAAK,OAAO,CAAC;AAExC,SAAO,GAAG,OAAO;;;;;;CAOlB,WAAmB;EAClB,MAAM,SAAS,OAAO,KAAK;GAC1B;GACA,KAAK;GACL,KAAK;GACL,KAAK,OAAO,MAAO;GACnB,CAAC;EACF,MAAM,OAAO,KAAK,MAAM,UAAU,IAAI,OAAO,MAAM,EAAE;EACrD,MAAM,cACL,OAAO,KAAK,gBAAgB,WACzB,OAAO,KAAK;GACZ,KAAK,gBAAgB;GACpB,KAAK,gBAAgB,KAAM;GAC3B,KAAK,gBAAgB,IAAK;GAC3B,KAAK,cAAc;GACnB,CAAC,GACD,KAAK;EACT,MAAM,WAAW,OAAO,KAAK;GAC5B,KAAK,aAAa;GACjB,KAAK,aAAa,KAAM;GACxB,KAAK,aAAa,IAAK;GACxB,KAAK,WAAW;GAChB,CAAC;AACF,SAAO,OAAO,OAAO;GAAC;GAAQ;GAAa;GAAU;GAAK,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"HsmsSsControlType.js","names":[],"sources":["../../../src/core/enums/HsmsSsControlType.ts"],"sourcesContent":["/**\n * HSMS-SS 控制类型(PType + SType 组合)\n * 存储在 Header 的 Byte 4-5\n */\nexport class HsmsSsControlType {\n\t// 只读实例属性\n\treadonly PType: number;\n\treadonly SType: number;\n\n\t// 私有构造函数,防止外部直接实例化\n\tprivate constructor(pType: number, sType: number) {\n\t\tthis.PType = pType;\n\t\tthis.SType = sType;\n\t}\n\n\t// ========== 静态只读实例 ==========\n\n\t// 未定义类型\n\tstatic readonly Undefined = new HsmsSsControlType(0xff, 0xff);\n\n\t// 数据消息(携带 SECS-II 数据)\n\tstatic readonly Data = new HsmsSsControlType(0x00, 0x00);\n\n\t// 连接控制消息\n\tstatic readonly SelectReq = new HsmsSsControlType(0x00, 0x01);\n\tstatic readonly SelectRsp = new HsmsSsControlType(0x00, 0x02);\n\tstatic readonly DeselectReq = new HsmsSsControlType(0x00, 0x03);\n\tstatic readonly DeselectRsp = new HsmsSsControlType(0x00, 0x04);\n\n\t// 链路测试消息\n\tstatic readonly LinktestReq = new HsmsSsControlType(0x00, 0x05);\n\tstatic readonly LinktestRsp = new HsmsSsControlType(0x00, 0x06);\n\n\t// 拒绝消息\n\tstatic readonly RejectReq = new HsmsSsControlType(0x00, 0x07);\n\n\t// 分离请求\n\tstatic readonly SeparateReq = new HsmsSsControlType(0x00, 0x09);\n\n\t// 私有已知类型数组\n\tprivate static readonly KnownTypes: HsmsSsControlType[] = [\n\t\tHsmsSsControlType.Data,\n\t\tHsmsSsControlType.SelectReq,\n\t\tHsmsSsControlType.SelectRsp,\n\t\tHsmsSsControlType.DeselectReq,\n\t\tHsmsSsControlType.DeselectRsp,\n\t\tHsmsSsControlType.LinktestReq,\n\t\tHsmsSsControlType.LinktestRsp,\n\t\tHsmsSsControlType.RejectReq,\n\t\tHsmsSsControlType.SeparateReq,\n\t];\n\n\t// ========== 静态工厂方法 ==========\n\n\t/**\n\t * 从字节解析控制类型\n\t */\n\tstatic fromBytes(pType: number, sType: number): HsmsSsControlType {\n\t\tfor (const known of HsmsSsControlType.KnownTypes) {\n\t\t\tif (known.PType === pType && known.SType === sType) {\n\t\t\t\treturn known;\n\t\t\t}\n\t\t}\n\t\treturn HsmsSsControlType.Undefined;\n\t}\n\n\t/**\n\t * 从 Header Bytes 4-5 解析\n\t */\n\tstatic fromHeaderBytes(\n\t\theaderBytes: Uint8Array | number[],\n\t): HsmsSsControlType {\n\t\treturn HsmsSsControlType.fromBytes(headerBytes[4], headerBytes[5]);\n\t}\n\n\t// ========== 实例方法 ==========\n\n\t/**\n\t * 判断是否为数据消息\n\t */\n\tget isDataMessage(): boolean {\n\t\treturn this === HsmsSsControlType.Data;\n\t}\n\n\t/**\n\t * 判断是否为控制消息\n\t */\n\tget isControlMessage(): boolean {\n\t\treturn !this.isDataMessage && this !== HsmsSsControlType.Undefined;\n\t}\n\n\tget isSelectRequest(): boolean {\n\t\treturn this === HsmsSsControlType.SelectReq;\n\t}\n\n\tget isSelectResponse(): boolean {\n\t\treturn this === HsmsSsControlType.SelectRsp;\n\t}\n\n\tget isLinktestRequest(): boolean {\n\t\treturn this === HsmsSsControlType.LinktestReq;\n\t}\n\n\tget isRejectRequest(): boolean {\n\t\treturn this === HsmsSsControlType.RejectReq;\n\t}\n\n\t/**\n\t * 字符串表示\n\t */\n\ttoString(): string {\n\t\tif (this === HsmsSsControlType.Data) return \"DATA\";\n\t\tif (this === HsmsSsControlType.SelectReq) return \"SELECT.req\";\n\t\tif (this === HsmsSsControlType.SelectRsp) return \"SELECT.rsp\";\n\t\tif (this === HsmsSsControlType.DeselectReq) return \"DESELECT.req\";\n\t\tif (this === HsmsSsControlType.DeselectRsp) return \"DESELECT.rsp\";\n\t\tif (this === HsmsSsControlType.LinktestReq) return \"LINKTEST.req\";\n\t\tif (this === HsmsSsControlType.LinktestRsp) return \"LINKTEST.rsp\";\n\t\tif (this === HsmsSsControlType.RejectReq) return \"REJECT.req\";\n\t\tif (this === HsmsSsControlType.SeparateReq) return \"SEPARATE.req\";\n\t\treturn `Unknown(${this.PType.toString(16).toUpperCase()},${this.SType.toString(16).toUpperCase()})`;\n\t}\n\n\t// ========== 值相等性比较 ==========\n\n\t/**\n\t * 比较两个控制类型是否相等(C# record struct 的值比较语义)\n\t */\n\tequals(other: HsmsSsControlType): boolean {\n\t\treturn this.PType === other.PType && this.SType === other.SType;\n\t}\n\n\t/**\n\t * 支持 === 运算符的比较\n\t */\n\tvalueOf(): { PType: number; SType: number } {\n\t\treturn { PType: this.PType, SType: this.SType };\n\t}\n}\n"],"mappings":";;;;;AAIA,IAAa,oBAAb,MAAa,kBAAkB;CAE9B,AAAS;CACT,AAAS;CAGT,AAAQ,YAAY,OAAe,OAAe;AACjD,OAAK,QAAQ;AACb,OAAK,QAAQ;;CAMd,OAAgB,YAAY,IAAI,kBAAkB,KAAM,IAAK;CAG7D,OAAgB,OAAO,IAAI,kBAAkB,GAAM,EAAK;CAGxD,OAAgB,YAAY,IAAI,kBAAkB,GAAM,EAAK;CAC7D,OAAgB,YAAY,IAAI,kBAAkB,GAAM,EAAK;CAC7D,OAAgB,cAAc,IAAI,kBA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kBAAkB,YAAa,QAAO;AACnD,MAAI,SAAS,kBAAkB,UAAW,QAAO;AACjD,MAAI,SAAS,kBAAkB,YAAa,QAAO;AACnD,SAAO,WAAW,KAAK,MAAM,SAAS,GAAG,CAAC,aAAa,CAAC,GAAG,KAAK,MAAM,SAAS,GAAG,CAAC,aAAa,CAAC;;;;;CAQlG,OAAO,OAAmC;AACzC,SAAO,KAAK,UAAU,MAAM,SAAS,KAAK,UAAU,MAAM;;;;;CAM3D,UAA4C;AAC3C,SAAO;GAAE,OAAO,KAAK;GAAO,OAAO,KAAK;GAAO"}
1
+ {"version":3,"file":"HsmsSsControlType.js","names":[],"sources":["../../../src/core/enums/HsmsSsControlType.ts"],"sourcesContent":["/**\r\n * HSMS-SS 控制类型(PType + SType 组合)\r\n * 存储在 Header 的 Byte 4-5\r\n */\r\nexport class HsmsSsControlType {\r\n\t// 只读实例属性\r\n\treadonly PType: number;\r\n\treadonly SType: number;\r\n\r\n\t// 私有构造函数,防止外部直接实例化\r\n\tprivate constructor(pType: number, sType: number) {\r\n\t\tthis.PType = pType;\r\n\t\tthis.SType = sType;\r\n\t}\r\n\r\n\t// ========== 静态只读实例 ==========\r\n\r\n\t// 未定义类型\r\n\tstatic readonly Undefined = new HsmsSsControlType(0xff, 0xff);\r\n\r\n\t// 数据消息(携带 SECS-II 数据)\r\n\tstatic readonly Data = new HsmsSsControlType(0x00, 0x00);\r\n\r\n\t// 连接控制消息\r\n\tstatic readonly SelectReq = new HsmsSsControlType(0x00, 0x01);\r\n\tstatic readonly SelectRsp = new HsmsSsControlType(0x00, 0x02);\r\n\tstatic readonly DeselectReq = new HsmsSsControlType(0x00, 0x03);\r\n\tstatic readonly DeselectRsp = new HsmsSsControlType(0x00, 0x04);\r\n\r\n\t// 链路测试消息\r\n\tstatic readonly LinktestReq = new HsmsSsControlType(0x00, 0x05);\r\n\tstatic readonly LinktestRsp = new HsmsSsControlType(0x00, 0x06);\r\n\r\n\t// 拒绝消息\r\n\tstatic readonly RejectReq = new HsmsSsControlType(0x00, 0x07);\r\n\r\n\t// 分离请求\r\n\tstatic readonly SeparateReq = new HsmsSsControlType(0x00, 0x09);\r\n\r\n\t// 私有已知类型数组\r\n\tprivate static readonly KnownTypes: HsmsSsControlType[] = [\r\n\t\tHsmsSsControlType.Data,\r\n\t\tHsmsSsControlType.SelectReq,\r\n\t\tHsmsSsControlType.SelectRsp,\r\n\t\tHsmsSsControlType.DeselectReq,\r\n\t\tHsmsSsControlType.DeselectRsp,\r\n\t\tHsmsSsControlType.LinktestReq,\r\n\t\tHsmsSsControlType.LinktestRsp,\r\n\t\tHsmsSsControlType.RejectReq,\r\n\t\tHsmsSsControlType.SeparateReq,\r\n\t];\r\n\r\n\t// ========== 静态工厂方法 ==========\r\n\r\n\t/**\r\n\t * 从字节解析控制类型\r\n\t */\r\n\tstatic fromBytes(pType: number, sType: number): HsmsSsControlType {\r\n\t\tfor (const known of HsmsSsControlType.KnownTypes) {\r\n\t\t\tif (known.PType === pType && known.SType === sType) {\r\n\t\t\t\treturn known;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn HsmsSsControlType.Undefined;\r\n\t}\r\n\r\n\t/**\r\n\t * 从 Header Bytes 4-5 解析\r\n\t */\r\n\tstatic fromHeaderBytes(\r\n\t\theaderBytes: Uint8Array | number[],\r\n\t): HsmsSsControlType {\r\n\t\treturn HsmsSsControlType.fromBytes(headerBytes[4], headerBytes[5]);\r\n\t}\r\n\r\n\t// ========== 实例方法 ==========\r\n\r\n\t/**\r\n\t * 判断是否为数据消息\r\n\t */\r\n\tget isDataMessage(): boolean {\r\n\t\treturn this === HsmsSsControlType.Data;\r\n\t}\r\n\r\n\t/**\r\n\t * 判断是否为控制消息\r\n\t */\r\n\tget isControlMessage(): boolean {\r\n\t\treturn !this.isDataMessage && this !== HsmsSsControlType.Undefined;\r\n\t}\r\n\r\n\tget isSelectRequest(): boolean {\r\n\t\treturn this === HsmsSsControlType.SelectReq;\r\n\t}\r\n\r\n\tget isSelectResponse(): boolean {\r\n\t\treturn this === HsmsSsControlType.SelectRsp;\r\n\t}\r\n\r\n\tget isLinktestRequest(): boolean {\r\n\t\treturn this === HsmsSsControlType.LinktestReq;\r\n\t}\r\n\r\n\tget isRejectRequest(): boolean {\r\n\t\treturn this === HsmsSsControlType.RejectReq;\r\n\t}\r\n\r\n\t/**\r\n\t * 字符串表示\r\n\t */\r\n\ttoString(): string {\r\n\t\tif (this === HsmsSsControlType.Data) return \"DATA\";\r\n\t\tif (this === HsmsSsControlType.SelectReq) return \"SELECT.req\";\r\n\t\tif (this === HsmsSsControlType.SelectRsp) return \"SELECT.rsp\";\r\n\t\tif (this === HsmsSsControlType.DeselectReq) return \"DESELECT.req\";\r\n\t\tif (this === HsmsSsControlType.DeselectRsp) return \"DESELECT.rsp\";\r\n\t\tif (this === HsmsSsControlType.LinktestReq) return \"LINKTEST.req\";\r\n\t\tif (this === HsmsSsControlType.LinktestRsp) return \"LINKTEST.rsp\";\r\n\t\tif (this === HsmsSsControlType.RejectReq) return \"REJECT.req\";\r\n\t\tif (this === HsmsSsControlType.SeparateReq) return \"SEPARATE.req\";\r\n\t\treturn `Unknown(${this.PType.toString(16).toUpperCase()},${this.SType.toString(16).toUpperCase()})`;\r\n\t}\r\n\r\n\t// ========== 值相等性比较 ==========\r\n\r\n\t/**\r\n\t * 比较两个控制类型是否相等(C# record struct 的值比较语义)\r\n\t */\r\n\tequals(other: HsmsSsControlType): boolean {\r\n\t\treturn this.PType === other.PType && this.SType === other.SType;\r\n\t}\r\n\r\n\t/**\r\n\t * 支持 === 运算符的比较\r\n\t */\r\n\tvalueOf(): { PType: number; SType: number } {\r\n\t\treturn { PType: this.PType, SType: this.SType };\r\n\t}\r\n}\r\n"],"mappings":";;;;;AAIA,IAAa,oBAAb,MAAa,kBAAkB;CAE9B,AAAS;CACT,AAAS;CAGT,AAAQ,YAAY,OAAe,OAAe;AACjD,OAAK,QAAQ;AACb,OAAK,QAAQ;;CAMd,OAAgB,YAAY,IAAI,kB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AkB,UAAW,QAAO;AACjD,MAAI,SAAS,kBAAkB,UAAW,QAAO;AACjD,MAAI,SAAS,kBAAkB,YAAa,QAAO;AACnD,MAAI,SAAS,kBAAkB,YAAa,QAAO;AACnD,MAAI,SAAS,kBAAkB,YAAa,QAAO;AACnD,MAAI,SAAS,kBAAkB,YAAa,QAAO;AACnD,MAAI,SAAS,kBAAkB,UAAW,QAAO;AACjD,MAAI,SAAS,kBAAkB,YAAa,QAAO;AACnD,SAAO,WAAW,KAAK,MAAM,SAAS,GAAG,CAAC,aAAa,CAAC,GAAG,KAAK,MAAM,SAAS,GAAG,CAAC,aAAa,CAAC;;;;;CAQlG,OAAO,OAAmC;AACzC,SAAO,KAAK,UAAU,MAAM,SAAS,KAAK,UAAU,MAAM;;;;;CAM3D,UAA4C;AAC3C,SAAO;GAAE,OAAO,KAAK;GAAO,OAAO,KAAK;GAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"RejectReason.js","names":[],"sources":["../../../src/core/enums/RejectReason.ts"],"sourcesContent":["export enum RejectReason {\n\tUnknown = 0xff,\n\tNotSupportTypeS = 0x01,\n\tNotSupportTypeP = 0x02,\n\tTransactionNotOpen = 0x03,\n\tNotSelected = 0x04,\n}\n"],"mappings":";AAAA,IAAY,wDAAL;AACN;AACA;AACA;AACA;AACA"}
1
+ {"version":3,"file":"RejectReason.js","names":[],"sources":["../../../src/core/enums/RejectReason.ts"],"sourcesContent":["export enum RejectReason {\r\n\tUnknown = 0xff,\r\n\tNotSupportTypeS = 0x01,\r\n\tNotSupportTypeP = 0x02,\r\n\tTransactionNotOpen = 0x03,\r\n\tNotSelected = 0x04,\r\n}\r\n"],"mappings":";AAAA,IAAY,wDAAL;AACN;AACA;AACA;AACA;AACA"}
@@ -1 +1 @@
1
- {"version":3,"file":"SecsItemType.js","names":[],"sources":["../../../src/core/enums/SecsItemType.ts"],"sourcesContent":["export enum SecsItemType {\n L = 0x00, // List\n B = 0x20, // Binary\n BOOLEAN = 0x24, // Boolean\n A = 0x40, // ASCII\n I8 = 0x60, // Integer 8\n I1 = 0x64, // Integer 1\n I2 = 0x68, // Integer 2\n I4 = 0x70, // Integer 4\n F8 = 0x80, // Floating Point 8\n F4 = 0x90, // Floating Point 4\n U8 = 0xa0, // Unsigned Integer 8\n U1 = 0xa4, // Unsigned Integer 1\n U2 = 0xa8, // Unsigned Integer 2\n U4 = 0xb0, // Unsigned Integer 4\n}\n"],"mappings":";AAAA,IAAY,wDAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
1
+ {"version":3,"file":"SecsItemType.js","names":[],"sources":["../../../src/core/enums/SecsItemType.ts"],"sourcesContent":["export enum SecsItemType {\r\n L = 0x00, // List\r\n B = 0x20, // Binary\r\n BOOLEAN = 0x24, // Boolean\r\n A = 0x40, // ASCII\r\n I8 = 0x60, // Integer 8\r\n I1 = 0x64, // Integer 1\r\n I2 = 0x68, // Integer 2\r\n I4 = 0x70, // Integer 4\r\n F8 = 0x80, // Floating Point 8\r\n F4 = 0x90, // Floating Point 4\r\n U8 = 0xa0, // Unsigned Integer 8\r\n U1 = 0xa4, // Unsigned Integer 1\r\n U2 = 0xa8, // Unsigned Integer 2\r\n U4 = 0xb0, // Unsigned Integer 4\r\n}\r\n"],"mappings":";AAAA,IAAY,wDAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
@@ -1 +1 @@
1
- {"version":3,"file":"SelectStatus.js","names":[],"sources":["../../../src/core/enums/SelectStatus.ts"],"sourcesContent":["export enum SelectStatus {\n\tUnknown = 0xff,\n\tSuccess = 0x00,\n\tActivated = 0x01,\n\tNotReady = 0x02,\n\tAlreadyUsed = 0x03,\n}\n"],"mappings":";AAAA,IAAY,wDAAL;AACN;AACA;AACA;AACA;AACA"}
1
+ {"version":3,"file":"SelectStatus.js","names":[],"sources":["../../../src/core/enums/SelectStatus.ts"],"sourcesContent":["export enum SelectStatus {\r\n\tUnknown = 0xff,\r\n\tSuccess = 0x00,\r\n\tActivated = 0x01,\r\n\tNotReady = 0x02,\r\n\tAlreadyUsed = 0x03,\r\n}\r\n"],"mappings":";AAAA,IAAY,wDAAL;AACN;AACA;AACA;AACA;AACA"}
@@ -1 +1 @@
1
- {"version":3,"file":"AbstractSecs2Item.js","names":["type: SecsItemType","_value: T","lengthBytes: Buffer"],"sources":["../../../src/core/secs2item/AbstractSecs2Item.ts"],"sourcesContent":["import { SecsItemType } from \"../enums/SecsItemType.js\";\n\nexport abstract class AbstractSecs2Item<T = unknown> {\n\t[index: number]: unknown;\n\n\tconstructor(\n\t\tpublic readonly type: SecsItemType,\n\t\tprotected readonly _value: T,\n\t) {\n\t\treturn new Proxy(this, {\n\t\t\tget: (target, prop, receiver) => {\n\t\t\t\tif (typeof prop === \"string\") {\n\t\t\t\t\tconst index = Number(prop);\n\t\t\t\t\tif (Number.isInteger(index) && index >= 0) {\n\t\t\t\t\t\treturn target.getByIndex(index);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn Reflect.get(target, prop, receiver);\n\t\t\t},\n\t\t});\n\t}\n\n\t/**\n\t * @description Returns the value of the item.\n\t */\n\tget value(): T {\n\t\treturn this._value;\n\t}\n\n\t/**\n\t * @description Returns the value of the item at the given index.\n\t * @param index The index of the value to return.\n\t * @returns The value of the item at the given index.\n\t */\n\tprotected getByIndex(index: number): unknown {\n\t\tconst v = this._value;\n\t\tif (Array.isArray(v) || Buffer.isBuffer(v) || typeof v === \"string\") {\n\t\t\treturn v[index];\n\t\t}\n\t\t// Scalar value\n\t\tif (index === 0) {\n\t\t\treturn v;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * @description Returns the SML representation of the item.\n\t */\n\tabstract toSml(): string;\n\n\t/**\n\t * @description Returns the SECS-II encoded buffer of the item.\n\t */\n\tabstract toBuffer(): Buffer;\n\n\t/**\n\t * @description Helper to create the header (Type + LengthBytes)\n\t */\n\tprotected createHeader(length: number): Buffer {\n\t\tlet headerByte = this.type;\n\t\tlet lengthBytes: Buffer;\n\n\t\tif (length > 0xffffff) {\n\t\t\tthrow new Error(`Length ${length.toString()} is too large for SECS item`);\n\t\t}\n\n\t\tif (length > 0xffff) {\n\t\t\t// 3 bytes length\n\t\t\theaderByte |= 0x03;\n\t\t\tlengthBytes = Buffer.alloc(4);\n\t\t\tlengthBytes.writeUInt8(headerByte, 0);\n\t\t\tlengthBytes.writeUIntBE(length, 1, 3);\n\t\t} else if (length > 0xff) {\n\t\t\t// 2 bytes length\n\t\t\theaderByte |= 0x02;\n\t\t\tlengthBytes = Buffer.alloc(3);\n\t\t\tlengthBytes.writeUInt8(headerByte, 0);\n\t\t\tlengthBytes.writeUInt16BE(length, 1);\n\t\t} else {\n\t\t\t// 1 byte length\n\t\t\theaderByte |= 0x01;\n\t\t\tlengthBytes = Buffer.alloc(2);\n\t\t\tlengthBytes.writeUInt8(headerByte, 0);\n\t\t\tlengthBytes.writeUInt8(length, 1);\n\t\t}\n\t\treturn lengthBytes;\n\t}\n}\n"],"mappings":";AAEA,IAAsB,oBAAtB,MAAqD;CAGpD,YACC,AAAgBA,MAChB,AAAmBC,QAClB;EAFe;EACG;AAEnB,SAAO,IAAI,MAAM,MAAM,EACtB,MAAM,QAAQ,MAAM,aAAa;AAChC,OAAI,OAAO,SAAS,UAAU;IAC7B,MAAM,QAAQ,OAAO,KAAK;AAC1B,QAAI,OAAO,UAAU,MAAM,IAAI,SAAS,EACvC,QAAO,OAAO,WAAW,MAAM;;AAGjC,UAAO,QAAQ,IAAI,QAAQ,MAAM,SAAS;KAE3C,CAAC;;;;;CAMH,IAAI,QAAW;AACd,SAAO,KAAK;;;;;;;CAQb,AAAU,WAAW,OAAwB;EAC5C,MAAM,IAAI,KAAK;AACf,MAAI,MAAM,QAAQ,EAAE,IAAI,OAAO,SAAS,EAAE,IAAI,OAAO,MAAM,SAC1D,QAAO,EAAE;AAGV,MAAI,UAAU,EACb,QAAO;;;;;CAkBT,AAAU,aAAa,QAAwB;EAC9C,IAAI,aAAa,KAAK;EACtB,IAAIC;AAEJ,MAAI,SAAS,SACZ,OAAM,IAAI,MAAM,UAAU,OAAO,UAAU,CAAC,6BAA6B;AAG1E,MAAI,SAAS,OAAQ;AAEpB,iBAAc;AACd,iBAAc,OAAO,MAAM,EAAE;AAC7B,eAAY,WAAW,YAAY,EAAE;AACrC,eAAY,YAAY,QAAQ,GAAG,EAAE;aAC3B,SAAS,KAAM;AAEzB,iBAAc;AACd,iBAAc,OAAO,MAAM,EAAE;AAC7B,eAAY,WAAW,YAAY,EAAE;AACrC,eAAY,cAAc,QAAQ,EAAE;SAC9B;AAEN,iBAAc;AACd,iBAAc,OAAO,MAAM,EAAE;AAC7B,eAAY,WAAW,YAAY,EAAE;AACrC,eAAY,WAAW,QAAQ,EAAE;;AAElC,SAAO"}
1
+ {"version":3,"file":"AbstractSecs2Item.js","names":["type: SecsItemType","_value: T","lengthBytes: Buffer"],"sources":["../../../src/core/secs2item/AbstractSecs2Item.ts"],"sourcesContent":["import { SecsItemType } from \"../enums/SecsItemType.js\";\r\n\r\nexport abstract class AbstractSecs2Item<T = unknown> {\r\n\t[index: number]: unknown;\r\n\r\n\tconstructor(\r\n\t\tpublic readonly type: SecsItemType,\r\n\t\tprotected readonly _value: T,\r\n\t) {\r\n\t\treturn new Proxy(this, {\r\n\t\t\tget: (target, prop, receiver) => {\r\n\t\t\t\tif (typeof prop === \"string\") {\r\n\t\t\t\t\tconst index = Number(prop);\r\n\t\t\t\t\tif (Number.isInteger(index) && index >= 0) {\r\n\t\t\t\t\t\treturn target.getByIndex(index);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\treturn Reflect.get(target, prop, receiver);\r\n\t\t\t},\r\n\t\t});\r\n\t}\r\n\r\n\t/**\r\n\t * @description Returns the value of the item.\r\n\t */\r\n\tget value(): T {\r\n\t\treturn this._value;\r\n\t}\r\n\r\n\t/**\r\n\t * @description Returns the value of the item at the given index.\r\n\t * @param index The index of the value to return.\r\n\t * @returns The value of the item at the given index.\r\n\t */\r\n\tprotected getByIndex(index: number): unknown {\r\n\t\tconst v = this._value;\r\n\t\tif (Array.isArray(v) || Buffer.isBuffer(v) || typeof v === \"string\") {\r\n\t\t\treturn v[index];\r\n\t\t}\r\n\t\t// Scalar value\r\n\t\tif (index === 0) {\r\n\t\t\treturn v;\r\n\t\t}\r\n\t\treturn undefined;\r\n\t}\r\n\r\n\t/**\r\n\t * @description Returns the SML representation of the item.\r\n\t */\r\n\tabstract toSml(): string;\r\n\r\n\t/**\r\n\t * @description Returns the SECS-II encoded buffer of the item.\r\n\t */\r\n\tabstract toBuffer(): Buffer;\r\n\r\n\t/**\r\n\t * @description Helper to create the header (Type + LengthBytes)\r\n\t */\r\n\tprotected createHeader(length: number): Buffer {\r\n\t\tlet headerByte = this.type;\r\n\t\tlet lengthBytes: Buffer;\r\n\r\n\t\tif (length > 0xffffff) {\r\n\t\t\tthrow new Error(`Length ${length.toString()} is too large for SECS item`);\r\n\t\t}\r\n\r\n\t\tif (length > 0xffff) {\r\n\t\t\t// 3 bytes length\r\n\t\t\theaderByte |= 0x03;\r\n\t\t\tlengthBytes = Buffer.alloc(4);\r\n\t\t\tlengthBytes.writeUInt8(headerByte, 0);\r\n\t\t\tlengthBytes.writeUIntBE(length, 1, 3);\r\n\t\t} else if (length > 0xff) {\r\n\t\t\t// 2 bytes length\r\n\t\t\theaderByte |= 0x02;\r\n\t\t\tlengthBytes = Buffer.alloc(3);\r\n\t\t\tlengthBytes.writeUInt8(headerByte, 0);\r\n\t\t\tlengthBytes.writeUInt16BE(length, 1);\r\n\t\t} else {\r\n\t\t\t// 1 byte length\r\n\t\t\theaderByte |= 0x01;\r\n\t\t\tlengthBytes = Buffer.alloc(2);\r\n\t\t\tlengthBytes.writeUInt8(headerByte, 0);\r\n\t\t\tlengthBytes.writeUInt8(length, 1);\r\n\t\t}\r\n\t\treturn lengthBytes;\r\n\t}\r\n}\r\n"],"mappings":";AAEA,IAAsB,oBAAtB,MAAqD;CAGpD,YACC,AAAgBA,MAChB,AAAmBC,QAClB;EAFe;EACG;AAEnB,SAAO,IAAI,MAAM,MAAM,EACtB,MAAM,QAAQ,MAAM,aAAa;AAChC,OAAI,OAAO,SAAS,UAAU;IAC7B,MAAM,QAAQ,OAAO,KAAK;AAC1B,QAAI,OAAO,UAAU,MAAM,IAAI,SAAS,EACvC,QAAO,OAAO,WAAW,MAAM;;AAGjC,UAAO,QAAQ,IAAI,QAAQ,MAAM,SAAS;KAE3C,CAAC;;;;;CAMH,IAAI,QAAW;AACd,SAAO,KAAK;;;;;;;CAQb,AAAU,WAAW,OAAwB;EAC5C,MAAM,IAAI,KAAK;AACf,MAAI,MAAM,QAAQ,EAAE,IAAI,OAAO,SAAS,EAAE,IAAI,OAAO,MAAM,SAC1D,QAAO,EAAE;AAGV,MAAI,UAAU,EACb,QAAO;;;;;CAkBT,AAAU,aAAa,QAAwB;EAC9C,IAAI,aAAa,KAAK;EACtB,IAAIC;AAEJ,MAAI,SAAS,SACZ,OAAM,IAAI,MAAM,UAAU,OAAO,UAAU,CAAC,6BAA6B;AAG1E,MAAI,SAAS,OAAQ;AAEpB,iBAAc;AACd,iBAAc,OAAO,MAAM,EAAE;AAC7B,eAAY,WAAW,YAAY,EAAE;AACrC,eAAY,YAAY,QAAQ,GAAG,EAAE;aAC3B,SAAS,KAAM;AAEzB,iBAAc;AACd,iBAAc,OAAO,MAAM,EAAE;AAC7B,eAAY,WAAW,YAAY,EAAE;AACrC,eAAY,cAAc,QAAQ,EAAE;SAC9B;AAEN,iBAAc;AACd,iBAAc,OAAO,MAAM,EAAE;AAC7B,eAAY,WAAW,YAAY,EAAE;AACrC,eAAY,WAAW,QAAQ,EAAE;;AAElC,SAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"Secs2ItemAscii.js","names":[],"sources":["../../../src/core/secs2item/Secs2ItemAscii.ts"],"sourcesContent":["import { SecsItemType } from \"../enums/SecsItemType.js\";\nimport { AbstractSecs2Item } from \"./AbstractSecs2Item.js\";\n\n/**\n * @description\n * ASCII string item is a string item that contains only ASCII characters.\n * @example\n * new Secs2ItemAscii(\"Hello World\");\n */\nexport class Secs2ItemAscii extends AbstractSecs2Item<string> {\n\tconstructor(value: string) {\n\t\tsuper(SecsItemType.A, value);\n\t}\n\n\toverride toSml(): string {\n\t\treturn `<A [${this._value.length}] \"${this._value}\">`;\n\t}\n\n\toverride toBuffer(): Buffer {\n\t\tconst valueBuffer = Buffer.from(this._value, \"ascii\");\n\t\tconst header = this.createHeader(valueBuffer.length);\n\t\treturn Buffer.concat([header, valueBuffer]);\n\t}\n}\n"],"mappings":";;;;;;;;;;AASA,IAAa,iBAAb,cAAoC,kBAA0B;CAC7D,YAAY,OAAe;AAC1B,QAAM,aAAa,GAAG,MAAM;;CAG7B,AAAS,QAAgB;AACxB,SAAO,OAAO,KAAK,OAAO,OAAO,KAAK,KAAK,OAAO;;CAGnD,AAAS,WAAmB;EAC3B,MAAM,cAAc,OAAO,KAAK,KAAK,QAAQ,QAAQ;EACrD,MAAM,SAAS,KAAK,aAAa,YAAY,OAAO;AACpD,SAAO,OAAO,OAAO,CAAC,QAAQ,YAAY,CAAC"}
1
+ {"version":3,"file":"Secs2ItemAscii.js","names":[],"sources":["../../../src/core/secs2item/Secs2ItemAscii.ts"],"sourcesContent":["import { SecsItemType } from \"../enums/SecsItemType.js\";\r\nimport { AbstractSecs2Item } from \"./AbstractSecs2Item.js\";\r\n\r\n/**\r\n * @description\r\n * ASCII string item is a string item that contains only ASCII characters.\r\n * @example\r\n * new Secs2ItemAscii(\"Hello World\");\r\n */\r\nexport class Secs2ItemAscii extends AbstractSecs2Item<string> {\r\n\tconstructor(value: string) {\r\n\t\tsuper(SecsItemType.A, value);\r\n\t}\r\n\r\n\toverride toSml(): string {\r\n\t\treturn `<A [${this._value.length}] \"${this._value}\">`;\r\n\t}\r\n\r\n\toverride toBuffer(): Buffer {\r\n\t\tconst valueBuffer = Buffer.from(this._value, \"ascii\");\r\n\t\tconst header = this.createHeader(valueBuffer.length);\r\n\t\treturn Buffer.concat([header, valueBuffer]);\r\n\t}\r\n}\r\n"],"mappings":";;;;;;;;;;AASA,IAAa,iBAAb,cAAoC,kBAA0B;CAC7D,YAAY,OAAe;AAC1B,QAAM,aAAa,GAAG,MAAM;;CAG7B,AAAS,QAAgB;AACxB,SAAO,OAAO,KAAK,OAAO,OAAO,KAAK,KAAK,OAAO;;CAGnD,AAAS,WAAmB;EAC3B,MAAM,cAAc,OAAO,KAAK,KAAK,QAAQ,QAAQ;EACrD,MAAM,SAAS,KAAK,aAAa,YAAY,OAAO;AACpD,SAAO,OAAO,OAAO,CAAC,QAAQ,YAAY,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Secs2ItemBinary.js","names":[],"sources":["../../../src/core/secs2item/Secs2ItemBinary.ts"],"sourcesContent":["import { SecsItemType } from \"../enums/SecsItemType.js\";\nimport { AbstractSecs2Item } from \"./AbstractSecs2Item.js\";\n\nexport class Secs2ItemBinary extends AbstractSecs2Item<Buffer> {\n\tconstructor(value: Buffer | number[]) {\n\t\tsuper(SecsItemType.B, Buffer.isBuffer(value) ? value : Buffer.from(value));\n\t}\n\n\toverride toSml(): string {\n\t\tconst hex = [];\n\t\tfor (const byte of this._value) {\n\t\t\thex.push(\"0x\" + byte.toString(16).toUpperCase().padStart(2, \"0\"));\n\t\t}\n\t\treturn `<B [${this._value.length}] ${hex.join(\" \")}>`;\n\t}\n\n\toverride toBuffer(): Buffer {\n\t\tconst header = this.createHeader(this._value.length);\n\t\treturn Buffer.concat([header, this._value]);\n\t}\n}\n"],"mappings":";;;;AAGA,IAAa,kBAAb,cAAqC,kBAA0B;CAC9D,YAAY,OAA0B;AACrC,QAAM,aAAa,GAAG,OAAO,SAAS,MAAM,GAAG,QAAQ,OAAO,KAAK,MAAM,CAAC;;CAG3E,AAAS,QAAgB;EACxB,MAAM,MAAM,EAAE;AACd,OAAK,MAAM,QAAQ,KAAK,OACvB,KAAI,KAAK,OAAO,KAAK,SAAS,GAAG,CAAC,aAAa,CAAC,SAAS,GAAG,IAAI,CAAC;AAElE,SAAO,OAAO,KAAK,OAAO,OAAO,IAAI,IAAI,KAAK,IAAI,CAAC;;CAGpD,AAAS,WAAmB;EAC3B,MAAM,SAAS,KAAK,aAAa,KAAK,OAAO,OAAO;AACpD,SAAO,OAAO,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC"}
1
+ {"version":3,"file":"Secs2ItemBinary.js","names":[],"sources":["../../../src/core/secs2item/Secs2ItemBinary.ts"],"sourcesContent":["import { SecsItemType } from \"../enums/SecsItemType.js\";\r\nimport { AbstractSecs2Item } from \"./AbstractSecs2Item.js\";\r\n\r\nexport class Secs2ItemBinary extends AbstractSecs2Item<Buffer> {\r\n\tconstructor(value: Buffer | number[]) {\r\n\t\tsuper(SecsItemType.B, Buffer.isBuffer(value) ? value : Buffer.from(value));\r\n\t}\r\n\r\n\toverride toSml(): string {\r\n\t\tconst hex = [];\r\n\t\tfor (const byte of this._value) {\r\n\t\t\thex.push(\"0x\" + byte.toString(16).toUpperCase().padStart(2, \"0\"));\r\n\t\t}\r\n\t\treturn `<B [${this._value.length}] ${hex.join(\" \")}>`;\r\n\t}\r\n\r\n\toverride toBuffer(): Buffer {\r\n\t\tconst header = this.createHeader(this._value.length);\r\n\t\treturn Buffer.concat([header, this._value]);\r\n\t}\r\n}\r\n"],"mappings":";;;;AAGA,IAAa,kBAAb,cAAqC,kBAA0B;CAC9D,YAAY,OAA0B;AACrC,QAAM,aAAa,GAAG,OAAO,SAAS,MAAM,GAAG,QAAQ,OAAO,KAAK,MAAM,CAAC;;CAG3E,AAAS,QAAgB;EACxB,MAAM,MAAM,EAAE;AACd,OAAK,MAAM,QAAQ,KAAK,OACvB,KAAI,KAAK,OAAO,KAAK,SAAS,GAAG,CAAC,aAAa,CAAC,SAAS,GAAG,IAAI,CAAC;AAElE,SAAO,OAAO,KAAK,OAAO,OAAO,IAAI,IAAI,KAAK,IAAI,CAAC;;CAGpD,AAAS,WAAmB;EAC3B,MAAM,SAAS,KAAK,aAAa,KAAK,OAAO,OAAO;AACpD,SAAO,OAAO,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Secs2ItemBoolean.js","names":[],"sources":["../../../src/core/secs2item/Secs2ItemBoolean.ts"],"sourcesContent":["import { SecsItemType } from \"../enums/SecsItemType.js\";\nimport { AbstractSecs2Item } from \"./AbstractSecs2Item.js\";\n\nexport class Secs2ItemBoolean extends AbstractSecs2Item<boolean | boolean[]> {\n\tconstructor(value: boolean | boolean[]) {\n\t\tsuper(SecsItemType.BOOLEAN, value);\n\t}\n\n\tget valueAsArray(): boolean[] {\n\t\treturn Array.isArray(this._value) ? this._value : [this._value];\n\t}\n\n\toverride toSml(): string {\n\t\tconst values = this.valueAsArray.map((v) => (v ? \"T\" : \"F\")); // Using T/F for brevity, standard might be TRUE/FALSE\n\t\treturn `<BOOLEAN ${values.join(\" \")}>`;\n\t}\n\n\toverride toBuffer(): Buffer {\n\t\tconst values = this.valueAsArray;\n\t\tconst buffer = Buffer.alloc(values.length);\n\t\tvalues.forEach((v, i) => buffer.writeUInt8(v ? 1 : 0, i)); // Or 0xFF? Python says 0xFF if v else 0x00?\n\t\t// Python code: 0xFF if v else 0x00.\n\t\t// Let's check pysemisecs again.\n\t\t// return bytes([(0xFF if v else 0x00) for v in self._value])\n\t\t// So 0xFF.\n\t\tvalues.forEach((v, i) => buffer.writeUInt8(v ? 0xff : 0x00, i));\n\t\tconst header = this.createHeader(buffer.length);\n\t\treturn Buffer.concat([header, buffer]);\n\t}\n}\n"],"mappings":";;;;AAGA,IAAa,mBAAb,cAAsC,kBAAuC;CAC5E,YAAY,OAA4B;AACvC,QAAM,aAAa,SAAS,MAAM;;CAGnC,IAAI,eAA0B;AAC7B,SAAO,MAAM,QAAQ,KAAK,OAAO,GAAG,KAAK,SAAS,CAAC,KAAK,OAAO;;CAGhE,AAAS,QAAgB;AAExB,SAAO,YADQ,KAAK,aAAa,KAAK,MAAO,IAAI,MAAM,IAAK,CAClC,KAAK,IAAI,CAAC;;CAGrC,AAAS,WAAmB;EAC3B,MAAM,SAAS,KAAK;EACpB,MAAM,SAAS,OAAO,MAAM,OAAO,OAAO;AAC1C,SAAO,SAAS,GAAG,MAAM,OAAO,WAAW,IAAI,IAAI,GAAG,EAAE,CAAC;AAKzD,SAAO,SAAS,GAAG,MAAM,OAAO,WAAW,IAAI,MAAO,GAAM,EAAE,CAAC;EAC/D,MAAM,SAAS,KAAK,aAAa,OAAO,OAAO;AAC/C,SAAO,OAAO,OAAO,CAAC,QAAQ,OAAO,CAAC"}
1
+ {"version":3,"file":"Secs2ItemBoolean.js","names":[],"sources":["../../../src/core/secs2item/Secs2ItemBoolean.ts"],"sourcesContent":["import { SecsItemType } from \"../enums/SecsItemType.js\";\r\nimport { AbstractSecs2Item } from \"./AbstractSecs2Item.js\";\r\n\r\nexport class Secs2ItemBoolean extends AbstractSecs2Item<boolean | boolean[]> {\r\n\tconstructor(value: boolean | boolean[]) {\r\n\t\tsuper(SecsItemType.BOOLEAN, value);\r\n\t}\r\n\r\n\tget valueAsArray(): boolean[] {\r\n\t\treturn Array.isArray(this._value) ? this._value : [this._value];\r\n\t}\r\n\r\n\toverride toSml(): string {\r\n\t\tconst values = this.valueAsArray.map((v) => (v ? \"T\" : \"F\")); // Using T/F for brevity, standard might be TRUE/FALSE\r\n\t\treturn `<BOOLEAN ${values.join(\" \")}>`;\r\n\t}\r\n\r\n\toverride toBuffer(): Buffer {\r\n\t\tconst values = this.valueAsArray;\r\n\t\tconst buffer = Buffer.alloc(values.length);\r\n\t\tvalues.forEach((v, i) => buffer.writeUInt8(v ? 1 : 0, i)); // Or 0xFF? Python says 0xFF if v else 0x00?\r\n\t\t// Python code: 0xFF if v else 0x00.\r\n\t\t// Let's check pysemisecs again.\r\n\t\t// return bytes([(0xFF if v else 0x00) for v in self._value])\r\n\t\t// So 0xFF.\r\n\t\tvalues.forEach((v, i) => buffer.writeUInt8(v ? 0xff : 0x00, i));\r\n\t\tconst header = this.createHeader(buffer.length);\r\n\t\treturn Buffer.concat([header, buffer]);\r\n\t}\r\n}\r\n"],"mappings":";;;;AAGA,IAAa,mBAAb,cAAsC,kBAAuC;CAC5E,YAAY,OAA4B;AACvC,QAAM,aAAa,SAAS,MAAM;;CAGnC,IAAI,eAA0B;AAC7B,SAAO,MAAM,QAAQ,KAAK,OAAO,GAAG,KAAK,SAAS,CAAC,KAAK,OAAO;;CAGhE,AAAS,QAAgB;AAExB,SAAO,YADQ,KAAK,aAAa,KAAK,MAAO,IAAI,MAAM,IAAK,CAClC,KAAK,IAAI,CAAC;;CAGrC,AAAS,WAAmB;EAC3B,MAAM,SAAS,KAAK;EACpB,MAAM,SAAS,OAAO,MAAM,OAAO,OAAO;AAC1C,SAAO,SAAS,GAAG,MAAM,OAAO,WAAW,IAAI,IAAI,GAAG,EAAE,CAAC;AAKzD,SAAO,SAAS,GAAG,MAAM,OAAO,WAAW,IAAI,MAAO,GAAM,EAAE,CAAC;EAC/D,MAAM,SAAS,KAAK,aAAa,OAAO,OAAO;AAC/C,SAAO,OAAO,OAAO,CAAC,QAAQ,OAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Secs2ItemFactory.js","names":[],"sources":["../../../src/core/secs2item/Secs2ItemFactory.ts"],"sourcesContent":["import { SecsItemType } from \"../enums/SecsItemType.js\";\nimport { AbstractSecs2Item } from \"./AbstractSecs2Item.js\";\nimport { Secs2ItemNumeric } from \"./Secs2ItemNumeric.js\";\nimport { Secs2ItemAscii } from \"./Secs2ItemAscii.js\";\nimport { Secs2ItemBinary } from \"./Secs2ItemBinary.js\";\nimport { Secs2ItemBoolean } from \"./Secs2ItemBoolean.js\";\nimport { Secs2ItemList } from \"./Secs2ItemList.js\";\n\nexport class Secs2ItemFactory {\n\tstatic createAsciiItem(value: string): Secs2ItemAscii {\n\t\treturn new Secs2ItemAscii(value);\n\t}\n\n\tstatic createBooleanItem(...value: boolean[]): Secs2ItemBoolean {\n\t\treturn new Secs2ItemBoolean(value);\n\t}\n\n\tstatic createBinaryItem(...value: Buffer[]): Secs2ItemBinary {\n\t\treturn new Secs2ItemBinary(Buffer.concat(value));\n\t}\n\n\tstatic createListItem(...items: AbstractSecs2Item[]): Secs2ItemList {\n\t\treturn new Secs2ItemList(items);\n\t}\n\n\tstatic createU1Item(...value: number[]): Secs2ItemNumeric {\n\t\treturn new Secs2ItemNumeric(SecsItemType.U1, value);\n\t}\n\n\tstatic createU2Item(...value: number[]): Secs2ItemNumeric {\n\t\treturn new Secs2ItemNumeric(SecsItemType.U2, value);\n\t}\n\n\tstatic createU4Item(...value: number[]): Secs2ItemNumeric {\n\t\treturn new Secs2ItemNumeric(SecsItemType.U4, value);\n\t}\n\n\tstatic createU8Item(...value: number[] | bigint[]): Secs2ItemNumeric {\n\t\treturn new Secs2ItemNumeric(SecsItemType.U8, value);\n\t}\n\n\tstatic createI1Item(...value: number[]): Secs2ItemNumeric {\n\t\treturn new Secs2ItemNumeric(SecsItemType.I1, value);\n\t}\n\n\tstatic createI2Item(...value: number[]): Secs2ItemNumeric {\n\t\treturn new Secs2ItemNumeric(SecsItemType.I2, value);\n\t}\n\n\tstatic createI4Item(...value: number[]): Secs2ItemNumeric {\n\t\treturn new Secs2ItemNumeric(SecsItemType.I4, value);\n\t}\n\n\tstatic createI8Item(...value: number[] | bigint[]): Secs2ItemNumeric {\n\t\treturn new Secs2ItemNumeric(SecsItemType.I8, value);\n\t}\n\n\tstatic createF4Item(...value: number[]): Secs2ItemNumeric {\n\t\treturn new Secs2ItemNumeric(SecsItemType.F4, value);\n\t}\n\n\tstatic createF8Item(...value: number[] | bigint[]): Secs2ItemNumeric {\n\t\treturn new Secs2ItemNumeric(SecsItemType.F8, value);\n\t}\n}\n"],"mappings":";;;;;;;;AAQA,IAAa,mBAAb,MAA8B;CAC7B,OAAO,gBAAgB,OAA+B;AACrD,SAAO,IAAI,eAAe,MAAM;;CAGjC,OAAO,kBAAkB,GAAG,OAAoC;AAC/D,SAAO,IAAI,iBAAiB,MAAM;;CAGnC,OAAO,iBAAiB,GAAG,OAAkC;AAC5D,SAAO,IAAI,gBAAgB,OAAO,OAAO,MAAM,CAAC;;CAGjD,OAAO,eAAe,GAAG,OAA2C;AACnE,SAAO,IAAI,cAAc,MAAM;;CAGhC,OAAO,aAAa,GAAG,OAAmC;AACzD,SAAO,IAAI,iBAAiB,aAAa,IAAI,MAAM;;CAGpD,OAAO,aAAa,GAAG,OAAmC;AACzD,SAAO,IAAI,iBAAiB,aAAa,IAAI,MAAM;;CAGpD,OAAO,aAAa,GAAG,OAAmC;AACzD,SAAO,IAAI,iBAAiB,aAAa,IAAI,MAAM;;CAGpD,OAAO,aAAa,GAAG,OAA8C;AACpE,SAAO,IAAI,iBAAiB,aAAa,IAAI,MAAM;;CAGpD,OAAO,aAAa,GAAG,OAAmC;AACzD,SAAO,IAAI,iBAAiB,aAAa,IAAI,MAAM;;CAGpD,OAAO,aAAa,GAAG,OAAmC;AACzD,SAAO,IAAI,iBAAiB,aAAa,IAAI,MAAM;;CAGpD,OAAO,aAAa,GAAG,OAAmC;AACzD,SAAO,IAAI,iBAAiB,aAAa,IAAI,MAAM;;CAGpD,OAAO,aAAa,GAAG,OAA8C;AACpE,SAAO,IAAI,iBAAiB,aAAa,IAAI,MAAM;;CAGpD,OAAO,aAAa,GAAG,OAAmC;AACzD,SAAO,IAAI,iBAAiB,aAAa,IAAI,MAAM;;CAGpD,OAAO,aAAa,GAAG,OAA8C;AACpE,SAAO,IAAI,iBAAiB,aAAa,IAAI,MAAM"}
1
+ {"version":3,"file":"Secs2ItemFactory.js","names":[],"sources":["../../../src/core/secs2item/Secs2ItemFactory.ts"],"sourcesContent":["import { SecsItemType } from \"../enums/SecsItemType.js\";\r\nimport { AbstractSecs2Item } from \"./AbstractSecs2Item.js\";\r\nimport { Secs2ItemNumeric } from \"./Secs2ItemNumeric.js\";\r\nimport { Secs2ItemAscii } from \"./Secs2ItemAscii.js\";\r\nimport { Secs2ItemBinary } from \"./Secs2ItemBinary.js\";\r\nimport { Secs2ItemBoolean } from \"./Secs2ItemBoolean.js\";\r\nimport { Secs2ItemList } from \"./Secs2ItemList.js\";\r\n\r\nexport class Secs2ItemFactory {\r\n\tstatic createAsciiItem(value: string): Secs2ItemAscii {\r\n\t\treturn new Secs2ItemAscii(value);\r\n\t}\r\n\r\n\tstatic createBooleanItem(...value: boolean[]): Secs2ItemBoolean {\r\n\t\treturn new Secs2ItemBoolean(value);\r\n\t}\r\n\r\n\tstatic createBinaryItem(...value: Buffer[]): Secs2ItemBinary {\r\n\t\treturn new Secs2ItemBinary(Buffer.concat(value));\r\n\t}\r\n\r\n\tstatic createListItem(...items: AbstractSecs2Item[]): Secs2ItemList {\r\n\t\treturn new Secs2ItemList(items);\r\n\t}\r\n\r\n\tstatic createU1Item(...value: number[]): Secs2ItemNumeric {\r\n\t\treturn new Secs2ItemNumeric(SecsItemType.U1, value);\r\n\t}\r\n\r\n\tstatic createU2Item(...value: number[]): Secs2ItemNumeric {\r\n\t\treturn new Secs2ItemNumeric(SecsItemType.U2, value);\r\n\t}\r\n\r\n\tstatic createU4Item(...value: number[]): Secs2ItemNumeric {\r\n\t\treturn new Secs2ItemNumeric(SecsItemType.U4, value);\r\n\t}\r\n\r\n\tstatic createU8Item(...value: number[] | bigint[]): Secs2ItemNumeric {\r\n\t\treturn new Secs2ItemNumeric(SecsItemType.U8, value);\r\n\t}\r\n\r\n\tstatic createI1Item(...value: number[]): Secs2ItemNumeric {\r\n\t\treturn new Secs2ItemNumeric(SecsItemType.I1, value);\r\n\t}\r\n\r\n\tstatic createI2Item(...value: number[]): Secs2ItemNumeric {\r\n\t\treturn new Secs2ItemNumeric(SecsItemType.I2, value);\r\n\t}\r\n\r\n\tstatic createI4Item(...value: number[]): Secs2ItemNumeric {\r\n\t\treturn new Secs2ItemNumeric(SecsItemType.I4, value);\r\n\t}\r\n\r\n\tstatic createI8Item(...value: number[] | bigint[]): Secs2ItemNumeric {\r\n\t\treturn new Secs2ItemNumeric(SecsItemType.I8, value);\r\n\t}\r\n\r\n\tstatic createF4Item(...value: number[]): Secs2ItemNumeric {\r\n\t\treturn new Secs2ItemNumeric(SecsItemType.F4, value);\r\n\t}\r\n\r\n\tstatic createF8Item(...value: number[] | bigint[]): Secs2ItemNumeric {\r\n\t\treturn new Secs2ItemNumeric(SecsItemType.F8, value);\r\n\t}\r\n}\r\n"],"mappings":";;;;;;;;AAQA,IAAa,mBAAb,MAA8B;CAC7B,OAAO,gBAAgB,OAA+B;AACrD,SAAO,IAAI,eAAe,MAAM;;CAGjC,OAAO,kBAAkB,GAAG,OAAoC;AAC/D,SAAO,IAAI,iBAAiB,MAAM;;CAGnC,OAAO,iBAAiB,GAAG,OAAkC;AAC5D,SAAO,IAAI,gBAAgB,OAAO,OAAO,MAAM,CAAC;;CAGjD,OAAO,eAAe,GAAG,OAA2C;AACnE,SAAO,IAAI,cAAc,MAAM;;CAGhC,OAAO,aAAa,GAAG,OAAmC;AACzD,SAAO,IAAI,iBAAiB,aAAa,IAAI,MAAM;;CAGpD,OAAO,aAAa,GAAG,OAAmC;AACzD,SAAO,IAAI,iBAAiB,aAAa,IAAI,MAAM;;CAGpD,OAAO,aAAa,GAAG,OAAmC;AACzD,SAAO,IAAI,iBAAiB,aAAa,IAAI,MAAM;;CAGpD,OAAO,aAAa,GAAG,OAA8C;AACpE,SAAO,IAAI,iBAAiB,aAAa,IAAI,MAAM;;CAGpD,OAAO,aAAa,GAAG,OAAmC;AACzD,SAAO,IAAI,iBAAiB,aAAa,IAAI,MAAM;;CAGpD,OAAO,aAAa,GAAG,OAAmC;AACzD,SAAO,IAAI,iBAAiB,aAAa,IAAI,MAAM;;CAGpD,OAAO,aAAa,GAAG,OAAmC;AACzD,SAAO,IAAI,iBAAiB,aAAa,IAAI,MAAM;;CAGpD,OAAO,aAAa,GAAG,OAA8C;AACpE,SAAO,IAAI,iBAAiB,aAAa,IAAI,MAAM;;CAGpD,OAAO,aAAa,GAAG,OAAmC;AACzD,SAAO,IAAI,iBAAiB,aAAa,IAAI,MAAM;;CAGpD,OAAO,aAAa,GAAG,OAA8C;AACpE,SAAO,IAAI,iBAAiB,aAAa,IAAI,MAAM"}
@@ -1 +1 @@
1
- {"version":3,"file":"Secs2ItemList.js","names":[],"sources":["../../../src/core/secs2item/Secs2ItemList.ts"],"sourcesContent":["import { SecsItemType } from \"../enums/SecsItemType.js\";\nimport { AbstractSecs2Item } from \"./AbstractSecs2Item.js\";\n\nexport class Secs2ItemList extends AbstractSecs2Item<AbstractSecs2Item[]> {\n\tconstructor(value: AbstractSecs2Item[]) {\n\t\tsuper(SecsItemType.L, value);\n\t}\n\n\toverride toSml(): string {\n\t\tif (this._value.length === 0) {\n\t\t\treturn \"<L [0] >\";\n\t\t}\n\t\tconst lines = [`<L [${this._value.length.toString()}] `];\n\t\tfor (const item of this._value) {\n\t\t\tlines.push(\" \" + item.toSml().replace(/\\n/g, \"\\n \"));\n\t\t}\n\t\tlines.push(\">\");\n\t\treturn lines.join(\"\\n\");\n\t}\n\n\toverride toBuffer(): Buffer {\n\t\tconst buffers = this._value.map((item) => item.toBuffer());\n\t\tconst valueBuffer = Buffer.concat(buffers);\n\t\t// For List, length is number of items, not byte length\n\t\tconst header = this.createHeader(this._value.length);\n\t\treturn Buffer.concat([header, valueBuffer]);\n\t}\n}\n"],"mappings":";;;;AAGA,IAAa,gBAAb,cAAmC,kBAAuC;CACzE,YAAY,OAA4B;AACvC,QAAM,aAAa,GAAG,MAAM;;CAG7B,AAAS,QAAgB;AACxB,MAAI,KAAK,OAAO,WAAW,EAC1B,QAAO;EAER,MAAM,QAAQ,CAAC,OAAO,KAAK,OAAO,OAAO,UAAU,CAAC,IAAI;AACxD,OAAK,MAAM,QAAQ,KAAK,OACvB,OAAM,KAAK,OAAO,KAAK,OAAO,CAAC,QAAQ,OAAO,OAAO,CAAC;AAEvD,QAAM,KAAK,IAAI;AACf,SAAO,MAAM,KAAK,KAAK;;CAGxB,AAAS,WAAmB;EAC3B,MAAM,UAAU,KAAK,OAAO,KAAK,SAAS,KAAK,UAAU,CAAC;EAC1D,MAAM,cAAc,OAAO,OAAO,QAAQ;EAE1C,MAAM,SAAS,KAAK,aAAa,KAAK,OAAO,OAAO;AACpD,SAAO,OAAO,OAAO,CAAC,QAAQ,YAAY,CAAC"}
1
+ {"version":3,"file":"Secs2ItemList.js","names":[],"sources":["../../../src/core/secs2item/Secs2ItemList.ts"],"sourcesContent":["import { SecsItemType } from \"../enums/SecsItemType.js\";\r\nimport { AbstractSecs2Item } from \"./AbstractSecs2Item.js\";\r\n\r\nexport class Secs2ItemList extends AbstractSecs2Item<AbstractSecs2Item[]> {\r\n\tconstructor(value: AbstractSecs2Item[]) {\r\n\t\tsuper(SecsItemType.L, value);\r\n\t}\r\n\r\n\toverride toSml(): string {\r\n\t\tif (this._value.length === 0) {\r\n\t\t\treturn \"<L [0] >\";\r\n\t\t}\r\n\t\tconst lines = [`<L [${this._value.length.toString()}] `];\r\n\t\tfor (const item of this._value) {\r\n\t\t\tlines.push(\" \" + item.toSml().replace(/\\n/g, \"\\n \"));\r\n\t\t}\r\n\t\tlines.push(\">\");\r\n\t\treturn lines.join(\"\\n\");\r\n\t}\r\n\r\n\toverride toBuffer(): Buffer {\r\n\t\tconst buffers = this._value.map((item) => item.toBuffer());\r\n\t\tconst valueBuffer = Buffer.concat(buffers);\r\n\t\t// For List, length is number of items, not byte length\r\n\t\tconst header = this.createHeader(this._value.length);\r\n\t\treturn Buffer.concat([header, valueBuffer]);\r\n\t}\r\n}\r\n"],"mappings":";;;;AAGA,IAAa,gBAAb,cAAmC,kBAAuC;CACzE,YAAY,OAA4B;AACvC,QAAM,aAAa,GAAG,MAAM;;CAG7B,AAAS,QAAgB;AACxB,MAAI,KAAK,OAAO,WAAW,EAC1B,QAAO;EAER,MAAM,QAAQ,CAAC,OAAO,KAAK,OAAO,OAAO,UAAU,CAAC,IAAI;AACxD,OAAK,MAAM,QAAQ,KAAK,OACvB,OAAM,KAAK,OAAO,KAAK,OAAO,CAAC,QAAQ,OAAO,OAAO,CAAC;AAEvD,QAAM,KAAK,IAAI;AACf,SAAO,MAAM,KAAK,KAAK;;CAGxB,AAAS,WAAmB;EAC3B,MAAM,UAAU,KAAK,OAAO,KAAK,SAAS,KAAK,UAAU,CAAC;EAC1D,MAAM,cAAc,OAAO,OAAO,QAAQ;EAE1C,MAAM,SAAS,KAAK,aAAa,KAAK,OAAO,OAAO;AACpD,SAAO,OAAO,OAAO,CAAC,QAAQ,YAAY,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Secs2ItemNumeric.js","names":["writeFunc: (val: number | bigint, buf: Buffer, offset: number) => void","readFunc: (buf: Buffer, offset: number) => number | bigint","values: (number | bigint)[]"],"sources":["../../../src/core/secs2item/Secs2ItemNumeric.ts"],"sourcesContent":["import { SecsItemType } from \"../enums/SecsItemType.js\";\nimport { AbstractSecs2Item } from \"./AbstractSecs2Item.js\";\n\nexport class Secs2ItemNumeric extends AbstractSecs2Item<\n\tnumber | number[] | bigint | bigint[]\n> {\n\tconstructor(\n\t\ttype: SecsItemType,\n\t\tvalue: number | number[] | bigint | bigint[],\n\t) {\n\t\tsuper(type, value);\n\t}\n\n\tget valueAsArray(): (number | bigint)[] {\n\t\treturn Array.isArray(this._value) ? this._value : [this._value];\n\t}\n\n\toverride toSml(): string {\n\t\tconst typeName = SecsItemType[this.type];\n\t\tconst values = this.valueAsArray.map((v) => v.toString());\n\t\treturn `<${typeName} [${values.length}] ${values.join(\" \")}>`;\n\t}\n\n\toverride toBuffer(): Buffer {\n\t\tconst values = this.valueAsArray;\n\t\tlet elementSize = 0;\n\t\tlet writeFunc: (val: number | bigint, buf: Buffer, offset: number) => void;\n\n\t\tswitch (this.type) {\n\t\t\tcase SecsItemType.I1:\n\t\t\t\telementSize = 1;\n\t\t\t\twriteFunc = (v, b, o) => b.writeInt8(Number(v), o);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.I2:\n\t\t\t\telementSize = 2;\n\t\t\t\twriteFunc = (v, b, o) => b.writeInt16BE(Number(v), o);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.I4:\n\t\t\t\telementSize = 4;\n\t\t\t\twriteFunc = (v, b, o) => b.writeInt32BE(Number(v), o);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.I8:\n\t\t\t\telementSize = 8;\n\t\t\t\twriteFunc = (v, b, o) => b.writeBigInt64BE(BigInt(v), o);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.U1:\n\t\t\t\telementSize = 1;\n\t\t\t\twriteFunc = (v, b, o) => b.writeUInt8(Number(v), o);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.U2:\n\t\t\t\telementSize = 2;\n\t\t\t\twriteFunc = (v, b, o) => b.writeUInt16BE(Number(v), o);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.U4:\n\t\t\t\telementSize = 4;\n\t\t\t\twriteFunc = (v, b, o) => b.writeUInt32BE(Number(v), o);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.U8:\n\t\t\t\telementSize = 8;\n\t\t\t\twriteFunc = (v, b, o) => b.writeBigUInt64BE(BigInt(v), o);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.F4:\n\t\t\t\telementSize = 4;\n\t\t\t\twriteFunc = (v, b, o) => b.writeFloatBE(Number(v), o);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.F8:\n\t\t\t\telementSize = 8;\n\t\t\t\twriteFunc = (v, b, o) => b.writeDoubleBE(Number(v), o);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Unsupported numeric type: ${this.type.toString()}`);\n\t\t}\n\n\t\tconst buffer = Buffer.alloc(values.length * elementSize);\n\t\tvalues.forEach((v, i) => {\n\t\t\twriteFunc(v, buffer, i * elementSize);\n\t\t});\n\t\tconst header = this.createHeader(buffer.length);\n\t\treturn Buffer.concat([header, buffer]);\n\t}\n\n\tstatic fromTypeBuffer(type: SecsItemType, buffer: Buffer): Secs2ItemNumeric {\n\t\tlet elementSize = 0;\n\t\tlet readFunc: (buf: Buffer, offset: number) => number | bigint;\n\n\t\tswitch (type) {\n\t\t\tcase SecsItemType.I1:\n\t\t\t\telementSize = 1;\n\t\t\t\treadFunc = (b, o) => b.readInt8(o);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.I2:\n\t\t\t\telementSize = 2;\n\t\t\t\treadFunc = (b, o) => b.readInt16BE(o);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.I4:\n\t\t\t\telementSize = 4;\n\t\t\t\treadFunc = (b, o) => b.readInt32BE(o);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.I8:\n\t\t\t\telementSize = 8;\n\t\t\t\treadFunc = (b, o) => b.readBigInt64BE(o);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.U1:\n\t\t\t\telementSize = 1;\n\t\t\t\treadFunc = (b, o) => b.readUInt8(o);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.U2:\n\t\t\t\telementSize = 2;\n\t\t\t\treadFunc = (b, o) => b.readUInt16BE(o);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.U4:\n\t\t\t\telementSize = 4;\n\t\t\t\treadFunc = (b, o) => b.readUInt32BE(o);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.U8:\n\t\t\t\telementSize = 8;\n\t\t\t\treadFunc = (b, o) => b.readBigUInt64BE(o);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.F4:\n\t\t\t\telementSize = 4;\n\t\t\t\treadFunc = (b, o) => b.readFloatBE(o);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.F8:\n\t\t\t\telementSize = 8;\n\t\t\t\treadFunc = (b, o) => b.readDoubleBE(o);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Unsupported numeric type: ${type.toString()}`);\n\t\t}\n\n\t\tconst count = buffer.length / elementSize;\n\t\tif (!Number.isInteger(count)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Buffer length ${buffer.length.toString()} is not multiple of element size ${elementSize.toString()}`,\n\t\t\t);\n\t\t}\n\n\t\tconst values: (number | bigint)[] = [];\n\t\tfor (let i = 0; i < count; i++) {\n\t\t\tvalues.push(readFunc(buffer, i * elementSize));\n\t\t}\n\n\t\tif (type === SecsItemType.I8 || type === SecsItemType.U8) {\n\t\t\treturn new Secs2ItemNumeric(\n\t\t\t\ttype,\n\t\t\t\tvalues.length === 1\n\t\t\t\t\t? (values[0] as bigint)\n\t\t\t\t\t: (values as unknown as bigint[]),\n\t\t\t);\n\t\t}\n\n\t\treturn new Secs2ItemNumeric(\n\t\t\ttype,\n\t\t\tvalues.length === 1 ? (values[0] as number) : (values as number[]),\n\t\t);\n\t}\n}\n"],"mappings":";;;;AAGA,IAAa,mBAAb,MAAa,yBAAyB,kBAEpC;CACD,YACC,MACA,OACC;AACD,QAAM,MAAM,MAAM;;CAGnB,IAAI,eAAoC;AACvC,SAAO,MAAM,QAAQ,KAAK,OAAO,GAAG,KAAK,SAAS,CAAC,KAAK,OAAO;;CAGhE,AAAS,QAAgB;EACxB,MAAM,WAAW,aAAa,KAAK;EACnC,MAAM,SAAS,KAAK,aAAa,KAAK,MAAM,EAAE,UAAU,CAAC;AACzD,SAAO,IAAI,SAAS,IAAI,OAAO,OAAO,IAAI,OAAO,KAAK,IAAI,CAAC;;CAG5D,AAAS,WAAmB;EAC3B,MAAM,SAAS,KAAK;EACpB,IAAI,cAAc;EAClB,IAAIA;AAEJ,UAAQ,KAAK,MAAb;GACC,KAAK,aAAa;AACjB,kBAAc;AACd,iBAAa,GAAG,GAAG,MAAM,EAAE,UAAU,OAAO,EAAE,EAAE,EAAE;AAClD;GACD,KAAK,aAAa;AACjB,kBAAc;AACd,iBAAa,GAAG,GAAG,MAAM,EAAE,aAAa,OAAO,EAAE,EAAE,EAAE;AACrD;GACD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/C"}
1
+ {"version":3,"file":"Secs2ItemNumeric.js","names":["writeFunc: (val: number | bigint, buf: Buffer, offset: number) => void","readFunc: (buf: Buffer, offset: number) => number | bigint","values: (number | bigint)[]"],"sources":["../../../src/core/secs2item/Secs2ItemNumeric.ts"],"sourcesContent":["import { SecsItemType } from \"../enums/SecsItemType.js\";\r\nimport { AbstractSecs2Item } from \"./AbstractSecs2Item.js\";\r\n\r\nexport class Secs2ItemNumeric extends AbstractSecs2Item<\r\n\tnumber | number[] | bigint | bigint[]\r\n> {\r\n\tconstructor(\r\n\t\ttype: SecsItemType,\r\n\t\tvalue: number | number[] | bigint | bigint[],\r\n\t) {\r\n\t\tsuper(type, value);\r\n\t}\r\n\r\n\tget valueAsArray(): (number | bigint)[] {\r\n\t\treturn Array.isArray(this._value) ? this._value : [this._value];\r\n\t}\r\n\r\n\toverride toSml(): string {\r\n\t\tconst typeName = SecsItemType[this.type];\r\n\t\tconst values = this.valueAsArray.map((v) => v.toString());\r\n\t\treturn `<${typeName} [${values.length}] ${values.join(\" \")}>`;\r\n\t}\r\n\r\n\toverride toBuffer(): Buffer {\r\n\t\tconst values = this.valueAsArray;\r\n\t\tlet elementSize = 0;\r\n\t\tlet writeFunc: (val: number | bigint, buf: Buffer, offset: number) => void;\r\n\r\n\t\tswitch (this.type) {\r\n\t\t\tcase SecsItemType.I1:\r\n\t\t\t\telementSize = 1;\r\n\t\t\t\twriteFunc = (v, b, o) => b.writeInt8(Number(v), o);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.I2:\r\n\t\t\t\telementSize = 2;\r\n\t\t\t\twriteFunc = (v, b, o) => b.writeInt16BE(Number(v), o);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.I4:\r\n\t\t\t\telementSize = 4;\r\n\t\t\t\twriteFunc = (v, b, o) => b.writeInt32BE(Number(v), o);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.I8:\r\n\t\t\t\telementSize = 8;\r\n\t\t\t\twriteFunc = (v, b, o) => b.writeBigInt64BE(BigInt(v), o);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.U1:\r\n\t\t\t\telementSize = 1;\r\n\t\t\t\twriteFunc = (v, b, o) => b.writeUInt8(Number(v), o);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.U2:\r\n\t\t\t\telementSize = 2;\r\n\t\t\t\twriteFunc = (v, b, o) => b.writeUInt16BE(Number(v), o);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.U4:\r\n\t\t\t\telementSize = 4;\r\n\t\t\t\twriteFunc = (v, b, o) => b.writeUInt32BE(Number(v), o);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.U8:\r\n\t\t\t\telementSize = 8;\r\n\t\t\t\twriteFunc = (v, b, o) => b.writeBigUInt64BE(BigInt(v), o);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.F4:\r\n\t\t\t\telementSize = 4;\r\n\t\t\t\twriteFunc = (v, b, o) => b.writeFloatBE(Number(v), o);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.F8:\r\n\t\t\t\telementSize = 8;\r\n\t\t\t\twriteFunc = (v, b, o) => b.writeDoubleBE(Number(v), o);\r\n\t\t\t\tbreak;\r\n\t\t\tdefault:\r\n\t\t\t\tthrow new Error(`Unsupported numeric type: ${this.type.toString()}`);\r\n\t\t}\r\n\r\n\t\tconst buffer = Buffer.alloc(values.length * elementSize);\r\n\t\tvalues.forEach((v, i) => {\r\n\t\t\twriteFunc(v, buffer, i * elementSize);\r\n\t\t});\r\n\t\tconst header = this.createHeader(buffer.length);\r\n\t\treturn Buffer.concat([header, buffer]);\r\n\t}\r\n\r\n\tstatic fromTypeBuffer(type: SecsItemType, buffer: Buffer): Secs2ItemNumeric {\r\n\t\tlet elementSize = 0;\r\n\t\tlet readFunc: (buf: Buffer, offset: number) => number | bigint;\r\n\r\n\t\tswitch (type) {\r\n\t\t\tcase SecsItemType.I1:\r\n\t\t\t\telementSize = 1;\r\n\t\t\t\treadFunc = (b, o) => b.readInt8(o);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.I2:\r\n\t\t\t\telementSize = 2;\r\n\t\t\t\treadFunc = (b, o) => b.readInt16BE(o);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.I4:\r\n\t\t\t\telementSize = 4;\r\n\t\t\t\treadFunc = (b, o) => b.readInt32BE(o);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.I8:\r\n\t\t\t\telementSize = 8;\r\n\t\t\t\treadFunc = (b, o) => b.readBigInt64BE(o);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.U1:\r\n\t\t\t\telementSize = 1;\r\n\t\t\t\treadFunc = (b, o) => b.readUInt8(o);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.U2:\r\n\t\t\t\telementSize = 2;\r\n\t\t\t\treadFunc = (b, o) => b.readUInt16BE(o);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.U4:\r\n\t\t\t\telementSize = 4;\r\n\t\t\t\treadFunc = (b, o) => b.readUInt32BE(o);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.U8:\r\n\t\t\t\telementSize = 8;\r\n\t\t\t\treadFunc = (b, o) => b.readBigUInt64BE(o);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.F4:\r\n\t\t\t\telementSize = 4;\r\n\t\t\t\treadFunc = (b, o) => b.readFloatBE(o);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.F8:\r\n\t\t\t\telementSize = 8;\r\n\t\t\t\treadFunc = (b, o) => b.readDoubleBE(o);\r\n\t\t\t\tbreak;\r\n\t\t\tdefault:\r\n\t\t\t\tthrow new Error(`Unsupported numeric type: ${type.toString()}`);\r\n\t\t}\r\n\r\n\t\tconst count = buffer.length / elementSize;\r\n\t\tif (!Number.isInteger(count)) {\r\n\t\t\tthrow new Error(\r\n\t\t\t\t`Buffer length ${buffer.length.toString()} is not multiple of element size ${elementSize.toString()}`,\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\tconst values: (number | bigint)[] = [];\r\n\t\tfor (let i = 0; i < count; i++) {\r\n\t\t\tvalues.push(readFunc(buffer, i * elementSize));\r\n\t\t}\r\n\r\n\t\tif (type === SecsItemType.I8 || type === SecsItemType.U8) {\r\n\t\t\treturn new Secs2ItemNumeric(\r\n\t\t\t\ttype,\r\n\t\t\t\tvalues.length === 1\r\n\t\t\t\t\t? (values[0] as bigint)\r\n\t\t\t\t\t: (values as unknown as bigint[]),\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\treturn new Secs2ItemNumeric(\r\n\t\t\ttype,\r\n\t\t\tvalues.length === 1 ? (values[0] as number) : (values as number[]),\r\n\t\t);\r\n\t}\r\n}\r\n"],"mappings":";;;;AAGA,IAAa,mBAAb,MAAa,yBAAyB,kBAEpC;CACD,YACC,MACA,OACC;AACD,QAAM,MAAM,MAAM;;CAGnB,IAAI,eAAoC;AACvC,SAAO,MAAM,QAAQ,KAAK,OAAO,GAAG,KAAK,SAAS,CAAC,KAAK,OAAO;;CAGhE,AAAS,QAAgB;EACxB,MAAM,WAAW,aAAa,KAAK;EACnC,MAAM,SAAS,KAAK,aAAa,KAAK,MAAM,EAAE,UAAU,CAAC;AACzD,SAAO,IAAI,SAAS,IAAI,OAAO,OAAO,IAAI,OAAO,KAAK,IAAI,CAAC;;CAG5D,AAAS,WAAmB;EAC3B,MAAM,SAAS,KAAK;EACpB,IAAI,cAAc;EAClB,IAAIA;AAEJ,UAAQ,KAAK,MAAb;GACC,KAAK,aAAa;AACjB,kBAAc;AACd,iBAAa,GAAG,GAAG,MAAM,EAAE,UAAU,OAAO,EAAE,EAAE,EAAE;AAClD;GACD,KAAK,aAAa;AACjB,kBAAc;AACd,iBAAa,GAAG,GAAG,MAAM,EAAE,aAAa,OAAO,EAAE,EAAE,EAAE;AACrD;GACD,KAAK,aAAa;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+1 @@
1
- {"version":3,"file":"Secs2ItemParser.js","names":["items: AbstractSecs2Item[]","item: AbstractSecs2Item"],"sources":["../../../src/core/secs2item/Secs2ItemParser.ts"],"sourcesContent":["import { SecsItemType } from \"../enums/SecsItemType.js\";\nimport { AbstractSecs2Item } from \"./AbstractSecs2Item.js\";\nimport { Secs2ItemFactory } from \"./Secs2ItemFactory.js\";\nimport { Secs2ItemNumeric } from \"./Secs2ItemNumeric.js\";\n\nexport class Secs2ItemParser {\n\tstatic fromBuffer(buffer: Buffer): {\n\t\titem: AbstractSecs2Item;\n\t\tconsumed: number;\n\t} {\n\t\tif (buffer.length === 0) {\n\t\t\tthrow new Error(\"Empty buffer\");\n\t\t}\n\n\t\tconst headerByte = buffer.readUInt8(0);\n\t\tconst itemType = (headerByte & 0xfc) as SecsItemType; // Clear last 2 bits\n\t\tconst lengthBytes = headerByte & 0x03;\n\n\t\tlet length = 0;\n\t\tif (lengthBytes === 1) {\n\t\t\tlength = buffer.readUInt8(1);\n\t\t} else if (lengthBytes === 2) {\n\t\t\tlength = buffer.readUInt16BE(1);\n\t\t} else if (lengthBytes === 3) {\n\t\t\tlength = buffer.readUIntBE(1, 3);\n\t\t} else {\n\t\t\tthrow new Error(`Invalid length bytes count: ${lengthBytes.toString()}`);\n\t\t}\n\n\t\tconst valueStart = 1 + lengthBytes;\n\n\t\t// Handle List items differently: length is number of items, not byte length\n\t\tif (itemType === SecsItemType.L) {\n\t\t\tconst items: AbstractSecs2Item[] = [];\n\t\t\tlet offset = valueStart;\n\t\t\tconst numItems = length;\n\n\t\t\tfor (let i = 0; i < numItems; i++) {\n\t\t\t\tif (offset >= buffer.length) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Insufficient buffer for List items. Expected ${numItems} items, got incomplete data.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst result = Secs2ItemParser.fromBuffer(buffer.subarray(offset));\n\t\t\t\titems.push(result.item);\n\t\t\t\toffset += result.consumed;\n\t\t\t}\n\n\t\t\tconst item = Secs2ItemFactory.createListItem(...items);\n\t\t\treturn { item, consumed: offset };\n\t\t}\n\n\t\t// For other types, length is byte length\n\t\tconst valueEnd = valueStart + length;\n\n\t\tif (buffer.length < valueEnd) {\n\t\t\tthrow new Error(\n\t\t\t\t`Insufficient buffer length. Expected ${valueEnd.toString()}, got ${buffer.length.toString()}`,\n\t\t\t);\n\t\t}\n\n\t\tconst valueBuffer = buffer.subarray(valueStart, valueEnd);\n\t\tconst consumed = valueEnd;\n\n\t\tlet item: AbstractSecs2Item;\n\n\t\tswitch (itemType) {\n\t\t\tcase SecsItemType.A:\n\t\t\t\titem = Secs2ItemFactory.createAsciiItem(valueBuffer.toString(\"ascii\"));\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.B:\n\t\t\t\titem = Secs2ItemFactory.createBinaryItem(valueBuffer);\n\t\t\t\tbreak;\n\t\t\tcase SecsItemType.BOOLEAN: {\n\t\t\t\t// Parse boolean array\n\t\t\t\tconst bools = [];\n\t\t\t\tfor (const byte of valueBuffer) {\n\t\t\t\t\tbools.push(byte !== 0);\n\t\t\t\t}\n\t\t\t\titem = Secs2ItemFactory.createBooleanItem(...bools);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SecsItemType.I1:\n\t\t\tcase SecsItemType.I2:\n\t\t\tcase SecsItemType.I4:\n\t\t\tcase SecsItemType.I8:\n\t\t\tcase SecsItemType.U1:\n\t\t\tcase SecsItemType.U2:\n\t\t\tcase SecsItemType.U4:\n\t\t\tcase SecsItemType.U8:\n\t\t\tcase SecsItemType.F4:\n\t\t\tcase SecsItemType.F8:\n\t\t\t\titem = Secs2ItemNumeric.fromTypeBuffer(itemType, valueBuffer);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Unknown item type: 0x${(itemType as number).toString(16)}`,\n\t\t\t\t);\n\t\t}\n\n\t\treturn { item, consumed };\n\t}\n}\n"],"mappings":";;;;;AAK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EAAE;AAChB,SAAK,MAAM,QAAQ,YAClB,OAAM,KAAK,SAAS,EAAE;AAEvB,WAAO,iBAAiB,kBAAkB,GAAG,MAAM;AACnD;;GAED,KAAK,aAAa;GAClB,KAAK,aAAa;GAClB,KAAK,aAAa;GAClB,KAAK,aAAa;GAClB,KAAK,aAAa;GAClB,KAAK,aAAa;GAClB,KAAK,aAAa;GAClB,KAAK,aAAa;GAClB,KAAK,aAAa;GAClB,KAAK,aAAa;AACjB,WAAO,iBAAiB,eAAe,UAAU,YAAY;AAC7D;GACD,QACC,OAAM,IAAI,MACT,wBAAyB,SAAoB,SAAS,GAAG,GACzD;;AAGH,SAAO;GAAE;GAAM;GAAU"}
1
+ {"version":3,"file":"Secs2ItemParser.js","names":["items: AbstractSecs2Item[]","item: AbstractSecs2Item"],"sources":["../../../src/core/secs2item/Secs2ItemParser.ts"],"sourcesContent":["import { SecsItemType } from \"../enums/SecsItemType.js\";\r\nimport { AbstractSecs2Item } from \"./AbstractSecs2Item.js\";\r\nimport { Secs2ItemFactory } from \"./Secs2ItemFactory.js\";\r\nimport { Secs2ItemNumeric } from \"./Secs2ItemNumeric.js\";\r\n\r\nexport class Secs2ItemParser {\r\n\tstatic fromBuffer(buffer: Buffer): {\r\n\t\titem: AbstractSecs2Item;\r\n\t\tconsumed: number;\r\n\t} {\r\n\t\tif (buffer.length === 0) {\r\n\t\t\tthrow new Error(\"Empty buffer\");\r\n\t\t}\r\n\r\n\t\tconst headerByte = buffer.readUInt8(0);\r\n\t\tconst itemType = (headerByte & 0xfc) as SecsItemType; // Clear last 2 bits\r\n\t\tconst lengthBytes = headerByte & 0x03;\r\n\r\n\t\tlet length = 0;\r\n\t\tif (lengthBytes === 1) {\r\n\t\t\tlength = buffer.readUInt8(1);\r\n\t\t} else if (lengthBytes === 2) {\r\n\t\t\tlength = buffer.readUInt16BE(1);\r\n\t\t} else if (lengthBytes === 3) {\r\n\t\t\tlength = buffer.readUIntBE(1, 3);\r\n\t\t} else {\r\n\t\t\tthrow new Error(`Invalid length bytes count: ${lengthBytes.toString()}`);\r\n\t\t}\r\n\r\n\t\tconst valueStart = 1 + lengthBytes;\r\n\r\n\t\t// Handle List items differently: length is number of items, not byte length\r\n\t\tif (itemType === SecsItemType.L) {\r\n\t\t\tconst items: AbstractSecs2Item[] = [];\r\n\t\t\tlet offset = valueStart;\r\n\t\t\tconst numItems = length;\r\n\r\n\t\t\tfor (let i = 0; i < numItems; i++) {\r\n\t\t\t\tif (offset >= buffer.length) {\r\n\t\t\t\t\tthrow new Error(\r\n\t\t\t\t\t\t`Insufficient buffer for List items. Expected ${numItems} items, got incomplete data.`,\r\n\t\t\t\t\t);\r\n\t\t\t\t}\r\n\t\t\t\tconst result = Secs2ItemParser.fromBuffer(buffer.subarray(offset));\r\n\t\t\t\titems.push(result.item);\r\n\t\t\t\toffset += result.consumed;\r\n\t\t\t}\r\n\r\n\t\t\tconst item = Secs2ItemFactory.createListItem(...items);\r\n\t\t\treturn { item, consumed: offset };\r\n\t\t}\r\n\r\n\t\t// For other types, length is byte length\r\n\t\tconst valueEnd = valueStart + length;\r\n\r\n\t\tif (buffer.length < valueEnd) {\r\n\t\t\tthrow new Error(\r\n\t\t\t\t`Insufficient buffer length. Expected ${valueEnd.toString()}, got ${buffer.length.toString()}`,\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\tconst valueBuffer = buffer.subarray(valueStart, valueEnd);\r\n\t\tconst consumed = valueEnd;\r\n\r\n\t\tlet item: AbstractSecs2Item;\r\n\r\n\t\tswitch (itemType) {\r\n\t\t\tcase SecsItemType.A:\r\n\t\t\t\titem = Secs2ItemFactory.createAsciiItem(valueBuffer.toString(\"ascii\"));\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.B:\r\n\t\t\t\titem = Secs2ItemFactory.createBinaryItem(valueBuffer);\r\n\t\t\t\tbreak;\r\n\t\t\tcase SecsItemType.BOOLEAN: {\r\n\t\t\t\t// Parse boolean array\r\n\t\t\t\tconst bools = [];\r\n\t\t\t\tfor (const byte of valueBuffer) {\r\n\t\t\t\t\tbools.push(byte !== 0);\r\n\t\t\t\t}\r\n\t\t\t\titem = Secs2ItemFactory.createBooleanItem(...bools);\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tcase SecsItemType.I1:\r\n\t\t\tcase SecsItemType.I2:\r\n\t\t\tcase SecsItemType.I4:\r\n\t\t\tcase SecsItemType.I8:\r\n\t\t\tcase SecsItemType.U1:\r\n\t\t\tcase SecsItemType.U2:\r\n\t\t\tcase SecsItemType.U4:\r\n\t\t\tcase SecsItemType.U8:\r\n\t\t\tcase SecsItemType.F4:\r\n\t\t\tcase SecsItemType.F8:\r\n\t\t\t\titem = Secs2ItemNumeric.fromTypeBuffer(itemType, valueBuffer);\r\n\t\t\t\tbreak;\r\n\t\t\tdefault:\r\n\t\t\t\tthrow new Error(\r\n\t\t\t\t\t`Unknown item type: 0x${(itemType as number).toString(16)}`,\r\n\t\t\t\t);\r\n\t\t}\r\n\r\n\t\treturn { item, consumed };\r\n\t}\r\n}\r\n"],"mappings":";;;;;AAKA,IAAa,kBAAb,MAAa,gBAAgB;CAC5B,OAAO,WAAW,QAGhB;AACD,MAAI,OAAO,WAAW,EACrB,OAAM,IAAI,MAAM,eAAe;EAGhC,MAAM,aAAa,OAAO,UAAU,EAAE;EACtC,MAAM,WAAY,aAAa;EAC/B,MAAM,cAAc,aAAa;EAEjC,IAAI,SAAS;AACb,MAAI,gBAAgB,EACnB,UAAS,OAAO,UAAU,EAAE;WAClB,gBAAgB,EAC1B,UAAS,OAAO,aAAa,EAAE;WACrB,gBAAgB,EAC1B,UAAS,OAAO,WAAW,GAAG,EAAE;MAEhC,OAAM,IAAI,MAAM,+BAA+B,YAAY,UAAU,GAAG;EAGzE,MAAM,aAAa,IAAI;AAGvB,MAAI,aAAa,aAAa,GAAG;GAChC,MAAMA,QAA6B,EAAE;GACrC,IAAI,SAAS;GACb,MAAM,WAAW;AAEjB,QAAK,IAAI,IAAI,GAA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