@ancon/wildcat-utils 1.54.0-check-optimizations.5 → 1.54.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.
- package/api/generateBackoffWithFullJitter.d.ts +15 -0
- package/api/generateBackoffWithFullJitter.js +1 -0
- package/api/generateBackoffWithFullJitter.mjs +7 -0
- package/api/generateBackoffWithVariableJitter.d.ts +3 -1
- package/api/generateBackoffWithVariableJitter.js +1 -1
- package/api/generateBackoffWithVariableJitter.mjs +12 -9
- package/api/getRateLimitRetryDelay.d.ts +18 -0
- package/api/getRateLimitRetryDelay.js +1 -0
- package/api/getRateLimitRetryDelay.mjs +14 -0
- package/api/index.d.ts +3 -1
- package/api/index.js +1 -1
- package/api/index.mjs +20 -14
- package/check/getOrganizedCheckItemModifications.d.ts +2 -2
- package/check/getOrganizedCheckItemModifications.js +1 -1
- package/check/getOrganizedCheckItemModifications.mjs +68 -74
- package/check/getUniqueCheckItemModificationId.d.ts +2 -2
- package/check/getUniqueCheckItemModificationId.js +1 -1
- package/check/getUniqueCheckItemModificationId.mjs +5 -5
- package/error/getRateLimit.d.ts +31 -0
- package/error/getRateLimit.js +1 -0
- package/error/getRateLimit.mjs +60 -0
- package/error/index.d.ts +4 -2
- package/error/index.js +1 -1
- package/error/index.mjs +34 -28
- package/error/isRateLimitError.d.ts +7 -0
- package/error/isRateLimitError.js +1 -0
- package/error/isRateLimitError.mjs +8 -0
- package/index.js +1 -1
- package/index.mjs +375 -362
- package/multilingual/createLocalizedCheckDetails.d.ts +2 -2
- package/multilingual/createLocalizedCheckDetails.js +1 -1
- package/multilingual/createLocalizedCheckDetails.mjs +27 -31
- package/package.json +26 -1
- package/printing/StarScanConnection.d.ts +64 -0
- package/printing/StarScanConnection.js +1 -0
- package/printing/StarScanConnection.mjs +93 -0
- package/printing/createStarCloudScanHook.d.ts +10 -0
- package/printing/createStarCloudScanHook.js +1 -1
- package/printing/createStarCloudScanHook.mjs +131 -93
- package/printing/index.js +1 -1
- package/printing/index.mjs +15 -14
|
@@ -1,138 +1,176 @@
|
|
|
1
|
-
import { useRef as
|
|
2
|
-
import
|
|
3
|
-
import { monitor as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { StarCloudScanStatus as
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { useRef as k, useState as D, useCallback as h, useEffect as L } from "react";
|
|
2
|
+
import W from "dayjs";
|
|
3
|
+
import { monitor as nn } from "@ancon/wildcat-printing";
|
|
4
|
+
import en from "../shared/hooks/usePrevious.mjs";
|
|
5
|
+
import tn from "../shared/hooks/useMountedRef.mjs";
|
|
6
|
+
import { StarCloudScanStatus as e } from "./types.mjs";
|
|
7
|
+
import rn, { StarScanReleaseReason as B } from "./StarScanConnection.mjs";
|
|
8
|
+
const on = ["TSP654"], cn = 1, sn = [
|
|
9
|
+
e.WaitingForPrinter,
|
|
10
|
+
e.PrinterDetected,
|
|
11
|
+
e.ReadyToScan
|
|
12
|
+
];
|
|
13
|
+
function an() {
|
|
14
|
+
return !1;
|
|
15
|
+
}
|
|
16
|
+
function mn(H, R, j, G, f) {
|
|
17
|
+
const {
|
|
18
|
+
useAppStore: q,
|
|
19
|
+
useStarPrinterDiscover: J,
|
|
20
|
+
useIsAppInBackground: K = an,
|
|
21
|
+
logger: Q
|
|
22
|
+
} = R, { selectedClientPrinterSelector: V } = j;
|
|
23
|
+
function X() {
|
|
24
|
+
const n = tn(), T = q(), F = J(), b = K(), p = k(null);
|
|
25
|
+
p.current || (p.current = new rn(Q));
|
|
26
|
+
const c = p.current, [s, Y] = D(H), [r, m] = D(), [C, y] = D(), w = en(C), [Z, A] = D(), [_, x] = D(G), o = h(
|
|
27
|
+
(i) => {
|
|
28
|
+
n != null && n.current && Y(i);
|
|
14
29
|
},
|
|
15
30
|
[n]
|
|
16
|
-
),
|
|
17
|
-
if ((
|
|
18
|
-
const
|
|
19
|
-
return
|
|
31
|
+
), $ = (i) => {
|
|
32
|
+
if ((f == null ? void 0 : f.sanitizeEnabled) ?? !1) {
|
|
33
|
+
const a = (f == null ? void 0 : f.sanitizeRegex) ?? /[\D]/gi;
|
|
34
|
+
return i.replace(a, "");
|
|
20
35
|
}
|
|
21
|
-
return
|
|
22
|
-
},
|
|
23
|
-
async (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
p(i);
|
|
36
|
+
return i;
|
|
37
|
+
}, I = h(
|
|
38
|
+
async (i) => {
|
|
39
|
+
c.release(B.CardRead), o(e.ScanningComplete);
|
|
40
|
+
const u = String.fromCharCode(...i).trim(), a = $(u);
|
|
41
|
+
x(a);
|
|
28
42
|
},
|
|
29
|
-
[o]
|
|
30
|
-
),
|
|
31
|
-
async ({ macAddress:
|
|
32
|
-
|
|
33
|
-
|
|
43
|
+
[o, c]
|
|
44
|
+
), M = h(
|
|
45
|
+
async ({ macAddress: i, ipAddress: u }) => {
|
|
46
|
+
let a;
|
|
47
|
+
function d(t) {
|
|
48
|
+
return (...E) => {
|
|
49
|
+
a && c.isAttached(a) && t(...E);
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function P(t) {
|
|
53
|
+
o(e.CommunicationError), n != null && n.current && A(t == null ? void 0 : t.message);
|
|
34
54
|
}
|
|
35
|
-
const
|
|
36
|
-
onStarted: (
|
|
37
|
-
if (
|
|
38
|
-
const { inputDevicesCount:
|
|
39
|
-
o(
|
|
40
|
-
inputDeviceCount:
|
|
55
|
+
const g = {
|
|
56
|
+
onStarted: d((t) => {
|
|
57
|
+
if (t && t.inputDevicesCount > 0) {
|
|
58
|
+
const { inputDevicesCount: E } = t;
|
|
59
|
+
o(e.ReadyToScan), m({
|
|
60
|
+
inputDeviceCount: E,
|
|
41
61
|
lastConnectedOn: /* @__PURE__ */ new Date()
|
|
42
62
|
});
|
|
43
63
|
}
|
|
44
|
-
},
|
|
45
|
-
onStopped: (
|
|
46
|
-
|
|
47
|
-
},
|
|
64
|
+
}),
|
|
65
|
+
onStopped: d((t) => {
|
|
66
|
+
t && P(t), m(void 0);
|
|
67
|
+
}),
|
|
48
68
|
inputDevice: {
|
|
49
|
-
onConnected: () => {
|
|
50
|
-
const
|
|
69
|
+
onConnected: d(() => {
|
|
70
|
+
const t = ((r == null ? void 0 : r.inputDeviceCount) || 0) + 1;
|
|
51
71
|
o(
|
|
52
|
-
|
|
53
|
-
),
|
|
54
|
-
inputDeviceCount:
|
|
72
|
+
t > 0 ? e.ReadyToScan : e.PrinterDetected
|
|
73
|
+
), m({
|
|
74
|
+
inputDeviceCount: t,
|
|
55
75
|
lastConnectedOn: /* @__PURE__ */ new Date()
|
|
56
76
|
});
|
|
57
|
-
},
|
|
58
|
-
onDisconnected: () => {
|
|
59
|
-
const
|
|
77
|
+
}),
|
|
78
|
+
onDisconnected: d(() => {
|
|
79
|
+
const t = ((r == null ? void 0 : r.inputDeviceCount) || 0) - 1 >= 0 ? ((r == null ? void 0 : r.inputDeviceCount) || 0) - 1 : 0;
|
|
60
80
|
o(
|
|
61
|
-
|
|
62
|
-
),
|
|
63
|
-
inputDeviceCount:
|
|
81
|
+
t > 0 ? e.ReadyToScan : e.PrinterDetected
|
|
82
|
+
), m({
|
|
83
|
+
inputDeviceCount: t
|
|
64
84
|
});
|
|
65
|
-
},
|
|
66
|
-
onCommunicationError:
|
|
67
|
-
onDataReceived: (
|
|
85
|
+
}),
|
|
86
|
+
onCommunicationError: d(P),
|
|
87
|
+
onDataReceived: d(
|
|
88
|
+
(t) => y({ data: t, lastReceivedOn: /* @__PURE__ */ new Date() })
|
|
89
|
+
)
|
|
68
90
|
}
|
|
69
|
-
};
|
|
70
|
-
if (
|
|
91
|
+
}, l = u || i, S = nn(l, g);
|
|
92
|
+
if (a = S, c.attach(S, l), n != null && n.current)
|
|
71
93
|
try {
|
|
72
|
-
await
|
|
73
|
-
} catch (
|
|
74
|
-
|
|
94
|
+
await S.start();
|
|
95
|
+
} catch (t) {
|
|
96
|
+
if (!c.isAttached(S))
|
|
97
|
+
return;
|
|
98
|
+
o(e.CommunicationError), n != null && n.current && A(t == null ? void 0 : t.message);
|
|
75
99
|
}
|
|
76
100
|
},
|
|
77
|
-
[r, o, n]
|
|
78
|
-
),
|
|
79
|
-
|
|
80
|
-
|
|
101
|
+
[r, o, n, c]
|
|
102
|
+
), v = h(async () => {
|
|
103
|
+
const i = c.beginScan();
|
|
104
|
+
n != null && n.current && (o(e.WaitingForPrinter), A(void 0), y(void 0), m(void 0), x(void 0));
|
|
105
|
+
const u = V(T.getState()), { macAddress: a, serialNumber: d } = u;
|
|
81
106
|
try {
|
|
82
|
-
const
|
|
83
|
-
(
|
|
107
|
+
const g = (await F(2e3)).find(
|
|
108
|
+
(l) => a && l.macAddress.toLowerCase() === a.toLowerCase() || d && l.serialNumber === d
|
|
84
109
|
);
|
|
110
|
+
if (!c.mayConnect(i))
|
|
111
|
+
return;
|
|
85
112
|
if (n != null && n.current) {
|
|
86
|
-
if (
|
|
87
|
-
if (
|
|
88
|
-
(
|
|
89
|
-
var
|
|
90
|
-
return (
|
|
113
|
+
if (g) {
|
|
114
|
+
if (on.some(
|
|
115
|
+
(l) => {
|
|
116
|
+
var S;
|
|
117
|
+
return (S = g.model) == null ? void 0 : S.toLowerCase().includes(l.toLowerCase());
|
|
91
118
|
}
|
|
92
119
|
)) {
|
|
93
|
-
o(
|
|
120
|
+
o(e.UnsupportedPrinter);
|
|
94
121
|
return;
|
|
95
122
|
}
|
|
96
|
-
|
|
123
|
+
M(g);
|
|
97
124
|
}
|
|
98
125
|
o(
|
|
99
|
-
|
|
126
|
+
g ? e.PrinterDetected : e.PrinterNotDetected
|
|
100
127
|
);
|
|
101
128
|
}
|
|
102
129
|
} catch {
|
|
103
|
-
|
|
130
|
+
if (!c.isLatest(i))
|
|
131
|
+
return;
|
|
132
|
+
n != null && n.current && o(e.PrinterNotDetected);
|
|
104
133
|
}
|
|
105
134
|
}, [
|
|
106
135
|
n,
|
|
107
|
-
|
|
136
|
+
T,
|
|
108
137
|
o,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
138
|
+
F,
|
|
139
|
+
M,
|
|
140
|
+
c
|
|
141
|
+
]), N = k(s);
|
|
142
|
+
N.current = s;
|
|
143
|
+
const U = k(v);
|
|
144
|
+
U.current = v, L(() => {
|
|
145
|
+
c.setBackground(
|
|
146
|
+
b,
|
|
147
|
+
sn.includes(N.current)
|
|
148
|
+
) && (n != null && n.current) && U.current();
|
|
149
|
+
}, [b, c, n]);
|
|
150
|
+
const z = s === e.WaitingForPrinter || s === e.PrinterDetected || s === e.ReadyToScan || s === e.ScanningComplete, O = s === e.PrinterNotDetected || s === e.ScanFailed || s === e.CommunicationError || s === e.UnsupportedPrinter;
|
|
151
|
+
return L(() => {
|
|
152
|
+
if (!w && (C == null ? void 0 : C.data) && r && (r != null && r.lastConnectedOn)) {
|
|
153
|
+
const { lastConnectedOn: u } = r, { lastReceivedOn: a, data: d } = C;
|
|
154
|
+
W(a).diff(
|
|
155
|
+
W(u),
|
|
117
156
|
"second",
|
|
118
157
|
!0
|
|
119
|
-
) >
|
|
158
|
+
) > cn ? I(d) : y(void 0);
|
|
120
159
|
}
|
|
121
|
-
}, [
|
|
122
|
-
|
|
123
|
-
(c = m.current) == null || c.stop();
|
|
160
|
+
}, [C, w, r, I]), L(() => (s === e.WaitingForPrinter && v(), () => {
|
|
161
|
+
c.release(B.Unmount);
|
|
124
162
|
}), []), {
|
|
125
|
-
startScan:
|
|
163
|
+
startScan: v,
|
|
126
164
|
changeDeviceStatus: o,
|
|
127
165
|
scanStatus: s,
|
|
128
|
-
reading:
|
|
129
|
-
connectionError:
|
|
130
|
-
isLoading:
|
|
131
|
-
isError:
|
|
166
|
+
reading: _,
|
|
167
|
+
connectionError: Z,
|
|
168
|
+
isLoading: z,
|
|
169
|
+
isError: O
|
|
132
170
|
};
|
|
133
171
|
}
|
|
134
|
-
return
|
|
172
|
+
return X;
|
|
135
173
|
}
|
|
136
174
|
export {
|
|
137
|
-
|
|
175
|
+
mn as default
|
|
138
176
|
};
|
package/printing/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./getPrinterType.js"),e=require("./isValidPrinter.js"),i=require("./isValidNetworkPrinter.js"),t=require("./isValidStarCloudPrinter.js"),n=require("./isTerminalPrinter.js"),o=require("./isCloudPrintModeEnabled.js"),u=require("./createStarCloudScanHook.js");require("@ancon/wildcat-types");require("react");require("dayjs");require("@ancon/wildcat-printing");require("../shared/hooks/usePrevious.js");require("../shared/hooks/useMountedRef.js");require("./types.js");exports.getPrinterType=r;exports.isValidPrinter=e;exports.isValidNetworkPrinter=i;exports.isValidStarCloudPrinter=t;exports.isTerminalPrinter=n;exports.isCloudPrintModeEnabled=o;exports.createUseStarCloudScanHook=u;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./getPrinterType.js"),e=require("./isValidPrinter.js"),i=require("./isValidNetworkPrinter.js"),t=require("./isValidStarCloudPrinter.js"),n=require("./isTerminalPrinter.js"),o=require("./isCloudPrintModeEnabled.js"),u=require("./createStarCloudScanHook.js");require("@ancon/wildcat-types");require("react");require("dayjs");require("@ancon/wildcat-printing");require("../shared/hooks/usePrevious.js");require("../shared/hooks/useMountedRef.js");require("./types.js");require("./StarScanConnection.js");exports.getPrinterType=r;exports.isValidPrinter=e;exports.isValidNetworkPrinter=i;exports.isValidStarCloudPrinter=t;exports.isTerminalPrinter=n;exports.isCloudPrintModeEnabled=o;exports.createUseStarCloudScanHook=u;
|
package/printing/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { default as
|
|
2
|
-
import { default as
|
|
3
|
-
import { default as
|
|
4
|
-
import { default as
|
|
5
|
-
import { default as
|
|
6
|
-
import { default as
|
|
7
|
-
import { default as
|
|
1
|
+
import { default as f } from "./getPrinterType.mjs";
|
|
2
|
+
import { default as u } from "./isValidPrinter.mjs";
|
|
3
|
+
import { default as x } from "./isValidNetworkPrinter.mjs";
|
|
4
|
+
import { default as C } from "./isValidStarCloudPrinter.mjs";
|
|
5
|
+
import { default as V } from "./isTerminalPrinter.mjs";
|
|
6
|
+
import { default as k } from "./isCloudPrintModeEnabled.mjs";
|
|
7
|
+
import { default as b } from "./createStarCloudScanHook.mjs";
|
|
8
8
|
import "@ancon/wildcat-types";
|
|
9
9
|
import "react";
|
|
10
10
|
import "dayjs";
|
|
@@ -12,12 +12,13 @@ import "@ancon/wildcat-printing";
|
|
|
12
12
|
import "../shared/hooks/usePrevious.mjs";
|
|
13
13
|
import "../shared/hooks/useMountedRef.mjs";
|
|
14
14
|
import "./types.mjs";
|
|
15
|
+
import "./StarScanConnection.mjs";
|
|
15
16
|
export {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
b as createUseStarCloudScanHook,
|
|
18
|
+
f as getPrinterType,
|
|
19
|
+
k as isCloudPrintModeEnabled,
|
|
20
|
+
V as isTerminalPrinter,
|
|
21
|
+
x as isValidNetworkPrinter,
|
|
22
|
+
u as isValidPrinter,
|
|
23
|
+
C as isValidStarCloudPrinter
|
|
23
24
|
};
|