@tallyui/core 3.17.0 → 3.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,48 @@
1
+ // src/types/display-signalling.ts
2
+ var DISPLAY_PAIR_CAPABILITY = "customer_display.pair";
3
+ var DisplaySignallingError = class extends Error {
4
+ code;
5
+ constructor(code, message = code) {
6
+ super(message);
7
+ this.name = "DisplaySignallingError";
8
+ this.code = code;
9
+ }
10
+ };
11
+
12
+ // src/customer-display/rate-limit-source.ts
13
+ var IPV4 = /^(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}$/;
14
+ var HEXTET = /^[0-9a-f]{1,4}$/;
15
+ function expandIpv6(address) {
16
+ let text = address.toLowerCase();
17
+ const last = text.slice(text.lastIndexOf(":") + 1);
18
+ if (IPV4.test(last)) {
19
+ const [a, b, c, d] = last.split(".").map(Number);
20
+ text = `${text.slice(0, text.length - last.length)}${(a << 8 | b).toString(16)}:${(c << 8 | d).toString(16)}`;
21
+ }
22
+ const halves = text.split("::");
23
+ if (halves.length > 2) return void 0;
24
+ const head = halves[0] ? halves[0].split(":") : [];
25
+ const tail = halves.length === 2 && halves[1] ? halves[1].split(":") : [];
26
+ const missing = 8 - head.length - tail.length;
27
+ if (halves.length === 2 ? missing < 1 : missing !== 0) return void 0;
28
+ const groups = [...head, ...Array(missing).fill("0"), ...tail];
29
+ if (!groups.every((group) => HEXTET.test(group))) return void 0;
30
+ return groups.map((group) => group.padStart(4, "0"));
31
+ }
32
+ function rateLimitSource(address) {
33
+ const input = address.trim();
34
+ if (IPV4.test(input)) return input;
35
+ const zone = input.indexOf("%");
36
+ const hextets = expandIpv6(zone >= 0 ? input.slice(0, zone) : input);
37
+ if (!hextets) return input;
38
+ if (hextets.slice(0, 5).every((group) => group === "0000") && hextets[5] === "ffff") {
39
+ const high = parseInt(hextets[6], 16);
40
+ const low = parseInt(hextets[7], 16);
41
+ return [high >> 8, high & 255, low >> 8, low & 255].join(".");
42
+ }
43
+ return `${hextets.slice(0, 4).join(":")}::/64`;
44
+ }
45
+
1
46
  // src/commands.ts
2
47
  var COMMANDS_PATH = "/tally/v1/commands";
3
48
  var PROTOCOL_HEADER = "X-Tally-Protocol";
@@ -176,6 +221,9 @@ function parseCommandResult(value) {
176
221
  }
177
222
 
178
223
  export {
224
+ DISPLAY_PAIR_CAPABILITY,
225
+ DisplaySignallingError,
226
+ rateLimitSource,
179
227
  COMMANDS_PATH,
180
228
  PROTOCOL_HEADER,
181
229
  PROTOCOL_VERSION,