@ancon/wildcat-utils 1.40.19 → 1.40.21
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/hangfire/createHangfirePoller.d.ts +1 -0
- package/hangfire/createHangfirePoller.js +1 -1
- package/hangfire/createHangfirePoller.mjs +32 -31
- package/index.js +1 -1
- package/index.mjs +239 -231
- package/outlet/getListOutletOpeningHoursTable.js +1 -1
- package/outlet/getListOutletOpeningHoursTable.mjs +3 -2
- package/outlet/getOutletCurrentClosingTimeText.js +1 -1
- package/outlet/getOutletCurrentClosingTimeText.mjs +3 -2
- package/outlet/getOutletTodayOpeningTimes.js +1 -1
- package/outlet/getOutletTodayOpeningTimes.mjs +3 -2
- package/outlet/index.js +1 -1
- package/outlet/index.mjs +51 -50
- package/package.json +26 -1
- package/printing/createStarCloudScanHook.d.ts +21 -0
- package/printing/createStarCloudScanHook.js +1 -0
- package/printing/createStarCloudScanHook.mjs +122 -0
- package/printing/getPrinterType.d.ts +1 -1
- package/printing/getPrinterType.js +1 -1
- package/printing/getPrinterType.mjs +10 -10
- package/printing/index.d.ts +2 -1
- package/printing/index.js +1 -1
- package/printing/index.mjs +20 -13
- package/printing/types.d.ts +11 -0
- package/printing/types.js +1 -0
- package/printing/types.mjs +4 -0
- package/shared/hooks/index.d.ts +3 -0
- package/shared/hooks/index.js +1 -0
- package/shared/hooks/index.mjs +7 -0
- package/shared/hooks/useMountedRef.d.ts +5 -0
- package/shared/hooks/useMountedRef.js +1 -0
- package/shared/hooks/useMountedRef.mjs +10 -0
- package/shared/hooks/usePrevious.d.ts +7 -0
- package/shared/hooks/usePrevious.js +1 -0
- package/shared/hooks/usePrevious.mjs +10 -0
- package/shared/index.d.ts +2 -1
- package/shared/index.js +1 -1
- package/shared/index.mjs +9 -4
package/outlet/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./getListOutletOpeningHoursTable.js"),t=require("./getOutletTagInformation.js"),r=require("./getOutletAvailabilityInfo.js"),u=require("./getOutletOfflineOrderFormats.js"),i=require("./getOutletAvailableOrderFormats.js"),o=require("./getOutletFormattedDistance.js"),l=require("./isOutletAcceptingPreOrders.js"),n=require("./getOutletDeliveryFee.js"),s=require("./getOutletTodayOpeningTimes.js"),O=require("./getOutletOrderFormats.js"),g=require("./serviceDateTimesFromOpeningHours.js"),a=require("./getPickerIntervalsForDay.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./getListOutletOpeningHoursTable.js"),t=require("./getOutletTagInformation.js"),r=require("./getOutletAvailabilityInfo.js"),u=require("./getOutletOfflineOrderFormats.js"),i=require("./getOutletAvailableOrderFormats.js"),o=require("./getOutletFormattedDistance.js"),l=require("./isOutletAcceptingPreOrders.js"),n=require("./getOutletDeliveryFee.js"),s=require("./getOutletTodayOpeningTimes.js"),O=require("./getOutletOrderFormats.js"),g=require("./serviceDateTimesFromOpeningHours.js"),a=require("./getPickerIntervalsForDay.js"),q=require("./getServiceIntervalRange.js"),c=require("./getServiceIntervalsForOrderFormat.js"),d=require("./getOutletFormattedAddress.js"),m=require("./getPartitionedOutletsList.js"),T=require("./getOutletPickerTimesForWeek.js"),_=require("./getOutletPickerTimesForDay.js"),F=require("./getOutletOrderPrepTime.js"),v=require("./getStructuredOutletAddress.js"),y=require("./getOutletNextOpeningTimeText.js"),f=require("./getOutletCurrentClosingTimeText.js"),p=require("./getOutletNextReadyToOrderTime.js"),I=require("./getOutletNextOpeningTagInformation.js"),P=require("./getOutletCurrentAvailabilityInfo.js");require("moment");require("@ancon/wildcat-types");require("../shared/isWithinFlag.js");require("../shared/generateId.js");require("react");require("./constants.js");require("./getOutletCurrentActiveOperatingHour.js");require("./getMomentFromDateAndTimeString.js");require("./searchNextOpeningMoment.js");require("../_baseIsEqual-a66350f1.js");require("../isObjectLike-0cc89d64.js");require("../toString-c005c116.js");require("../noop-7ea3b37b.js");require("../shared/constants.js");require("../time/toMinutes.js");require("../time/getNextTenthMinute.js");require("./types.js");require("./getSettingsForOrderFormat.js");require("./getServiceIntervalStart.js");require("./getNextTenthMinute.js");require("./generatePickerTimesForDay.js");require("./getServiceIntervalEnd.js");require("./hoursAndMinutesToMinutes.js");exports.getListOutletOpeningHoursTable=e;exports.getOutletTagInformation=t.default;exports.getOutletAvailabilityInfo=r.default;exports.getOutletOfflineOrderFormats=u;exports.getOutletAvailableOrderFormats=i;exports.getOutletFormattedDistance=o;exports.isOutletAcceptingPreOrders=l;exports.getOutletDeliveryFee=n;exports.getOutletTodayOpeningTimes=s;exports.getOutletOrderFormats=O;exports.serviceDateTimesFromOpeningHours=g;exports.getPickerIntervalsForDay=a;exports.getServiceIntervalRange=q;exports.getServiceIntervalsForOrderFormat=c;exports.getOutletFormattedAddress=d;exports.getPartitionedOutletsList=m;exports.getOutletPickerTimesForWeek=T;exports.getOutletPickerTimesForDay=_;exports.getOutletOrderPreparationTime=F;exports.getStructuredOutletAddress=v;exports.getOutletNextOpeningTimeText=y;exports.getOutletCurrentClosingTimeText=f;exports.getOutletNextReadyToOrderTime=p;exports.getOutletNextOpeningTagInformation=I;exports.getOutletCurrentAvailabilityInfo=P;
|
package/outlet/index.mjs
CHANGED
|
@@ -1,32 +1,33 @@
|
|
|
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
|
|
8
|
-
import { default as
|
|
9
|
-
import { default as
|
|
10
|
-
import { default as
|
|
11
|
-
import { default as
|
|
12
|
-
import { default as
|
|
13
|
-
import { default as
|
|
14
|
-
import { default as
|
|
15
|
-
import { default as
|
|
16
|
-
import { default as
|
|
17
|
-
import { default as
|
|
18
|
-
import { default as
|
|
19
|
-
import { default as
|
|
20
|
-
import { default as
|
|
21
|
-
import { default as
|
|
22
|
-
import { default as
|
|
23
|
-
import { default as
|
|
24
|
-
import { default as
|
|
25
|
-
import { default as
|
|
1
|
+
import { default as D } from "./getListOutletOpeningHoursTable.mjs";
|
|
2
|
+
import { default as k } from "./getOutletTagInformation.mjs";
|
|
3
|
+
import { default as N } from "./getOutletAvailabilityInfo.mjs";
|
|
4
|
+
import { default as H } from "./getOutletOfflineOrderFormats.mjs";
|
|
5
|
+
import { default as R } from "./getOutletAvailableOrderFormats.mjs";
|
|
6
|
+
import { default as h } from "./getOutletFormattedDistance.mjs";
|
|
7
|
+
import { default as q } from "./isOutletAcceptingPreOrders.mjs";
|
|
8
|
+
import { default as z } from "./getOutletDeliveryFee.mjs";
|
|
9
|
+
import { default as E } from "./getOutletTodayOpeningTimes.mjs";
|
|
10
|
+
import { default as J } from "./getOutletOrderFormats.mjs";
|
|
11
|
+
import { default as M } from "./serviceDateTimesFromOpeningHours.mjs";
|
|
12
|
+
import { default as U } from "./getPickerIntervalsForDay.mjs";
|
|
13
|
+
import { default as X } from "./getServiceIntervalRange.mjs";
|
|
14
|
+
import { default as Z } from "./getServiceIntervalsForOrderFormat.mjs";
|
|
15
|
+
import { default as $ } from "./getOutletFormattedAddress.mjs";
|
|
16
|
+
import { default as et } from "./getPartitionedOutletsList.mjs";
|
|
17
|
+
import { default as ot } from "./getOutletPickerTimesForWeek.mjs";
|
|
18
|
+
import { default as mt } from "./getOutletPickerTimesForDay.mjs";
|
|
19
|
+
import { default as lt } from "./getOutletOrderPrepTime.mjs";
|
|
20
|
+
import { default as pt } from "./getStructuredOutletAddress.mjs";
|
|
21
|
+
import { default as st } from "./getOutletNextOpeningTimeText.mjs";
|
|
22
|
+
import { default as Ot } from "./getOutletCurrentClosingTimeText.mjs";
|
|
23
|
+
import { default as xt } from "./getOutletNextReadyToOrderTime.mjs";
|
|
24
|
+
import { default as Tt } from "./getOutletNextOpeningTagInformation.mjs";
|
|
25
|
+
import { default as ct } from "./getOutletCurrentAvailabilityInfo.mjs";
|
|
26
26
|
import "moment";
|
|
27
27
|
import "@ancon/wildcat-types";
|
|
28
28
|
import "../shared/isWithinFlag.mjs";
|
|
29
29
|
import "../shared/generateId.mjs";
|
|
30
|
+
import "react";
|
|
30
31
|
import "./constants.mjs";
|
|
31
32
|
import "./getOutletCurrentActiveOperatingHour.mjs";
|
|
32
33
|
import "./getMomentFromDateAndTimeString.mjs";
|
|
@@ -46,29 +47,29 @@ import "./generatePickerTimesForDay.mjs";
|
|
|
46
47
|
import "./getServiceIntervalEnd.mjs";
|
|
47
48
|
import "./hoursAndMinutesToMinutes.mjs";
|
|
48
49
|
export {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
50
|
+
D as getListOutletOpeningHoursTable,
|
|
51
|
+
N as getOutletAvailabilityInfo,
|
|
52
|
+
R as getOutletAvailableOrderFormats,
|
|
53
|
+
ct as getOutletCurrentAvailabilityInfo,
|
|
54
|
+
Ot as getOutletCurrentClosingTimeText,
|
|
55
|
+
z as getOutletDeliveryFee,
|
|
56
|
+
$ as getOutletFormattedAddress,
|
|
57
|
+
h as getOutletFormattedDistance,
|
|
58
|
+
Tt as getOutletNextOpeningTagInformation,
|
|
59
|
+
st as getOutletNextOpeningTimeText,
|
|
60
|
+
xt as getOutletNextReadyToOrderTime,
|
|
61
|
+
H as getOutletOfflineOrderFormats,
|
|
62
|
+
J as getOutletOrderFormats,
|
|
63
|
+
lt as getOutletOrderPreparationTime,
|
|
64
|
+
mt as getOutletPickerTimesForDay,
|
|
65
|
+
ot as getOutletPickerTimesForWeek,
|
|
66
|
+
k as getOutletTagInformation,
|
|
67
|
+
E as getOutletTodayOpeningTimes,
|
|
68
|
+
et as getPartitionedOutletsList,
|
|
69
|
+
U as getPickerIntervalsForDay,
|
|
70
|
+
X as getServiceIntervalRange,
|
|
71
|
+
Z as getServiceIntervalsForOrderFormat,
|
|
72
|
+
pt as getStructuredOutletAddress,
|
|
73
|
+
q as isOutletAcceptingPreOrders,
|
|
74
|
+
M as serviceDateTimesFromOpeningHours
|
|
74
75
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ancon/wildcat-utils",
|
|
3
|
-
"version": "1.40.
|
|
3
|
+
"version": "1.40.21",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -631,6 +631,11 @@
|
|
|
631
631
|
"require": "./preOrder/isPreOrderSharable.js",
|
|
632
632
|
"types": "./preOrder/isPreOrderSharable.d.ts"
|
|
633
633
|
},
|
|
634
|
+
"./printing/createStarCloudScanHook": {
|
|
635
|
+
"import": "./printing/createStarCloudScanHook.mjs",
|
|
636
|
+
"require": "./printing/createStarCloudScanHook.js",
|
|
637
|
+
"types": "./printing/createStarCloudScanHook.d.ts"
|
|
638
|
+
},
|
|
634
639
|
"./printing/getPrinterType": {
|
|
635
640
|
"import": "./printing/getPrinterType.mjs",
|
|
636
641
|
"require": "./printing/getPrinterType.js",
|
|
@@ -666,6 +671,11 @@
|
|
|
666
671
|
"require": "./printing/isValidStarCloudPrinter.js",
|
|
667
672
|
"types": "./printing/isValidStarCloudPrinter.d.ts"
|
|
668
673
|
},
|
|
674
|
+
"./printing/types": {
|
|
675
|
+
"import": "./printing/types.mjs",
|
|
676
|
+
"require": "./printing/types.js",
|
|
677
|
+
"types": "./printing/types.d.ts"
|
|
678
|
+
},
|
|
669
679
|
"./product/calculateAddonGroupCost": {
|
|
670
680
|
"import": "./product/calculateAddonGroupCost.mjs",
|
|
671
681
|
"require": "./product/calculateAddonGroupCost.js",
|
|
@@ -706,6 +716,21 @@
|
|
|
706
716
|
"require": "./shared/generateId.js",
|
|
707
717
|
"types": "./shared/generateId.d.ts"
|
|
708
718
|
},
|
|
719
|
+
"./shared/hooks": {
|
|
720
|
+
"import": "./shared/hooks/index.mjs",
|
|
721
|
+
"require": "./shared/hooks/index.js",
|
|
722
|
+
"types": "./shared/hooks/index.d.ts"
|
|
723
|
+
},
|
|
724
|
+
"./shared/hooks/useMountedRef": {
|
|
725
|
+
"import": "./shared/hooks/useMountedRef.mjs",
|
|
726
|
+
"require": "./shared/hooks/useMountedRef.js",
|
|
727
|
+
"types": "./shared/hooks/useMountedRef.d.ts"
|
|
728
|
+
},
|
|
729
|
+
"./shared/hooks/usePrevious": {
|
|
730
|
+
"import": "./shared/hooks/usePrevious.mjs",
|
|
731
|
+
"require": "./shared/hooks/usePrevious.js",
|
|
732
|
+
"types": "./shared/hooks/usePrevious.d.ts"
|
|
733
|
+
},
|
|
709
734
|
"./shared": {
|
|
710
735
|
"import": "./shared/index.mjs",
|
|
711
736
|
"require": "./shared/index.js",
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ClientSettingsPrinter, DiscoveredStarPrinter } from '@ancon/wildcat-types';
|
|
2
|
+
import { StarCloudScanStatus } from './types';
|
|
3
|
+
declare type ReduxSelectorsArg<RootState = unknown> = {
|
|
4
|
+
selectedClientPrinterSelector: (state: RootState) => ClientSettingsPrinter | null;
|
|
5
|
+
};
|
|
6
|
+
declare type ReduxHooksArg<RootState = unknown> = {
|
|
7
|
+
useAppStore: () => {
|
|
8
|
+
getState: () => RootState;
|
|
9
|
+
};
|
|
10
|
+
useStarPrinterDiscover: () => (timeout: number) => Promise<DiscoveredStarPrinter[]>;
|
|
11
|
+
};
|
|
12
|
+
declare function createUseStarCloudScanHook<RootState = unknown>(initialStatus: StarCloudScanStatus, hooks: ReduxHooksArg<RootState>, selectors: ReduxSelectorsArg<RootState>, initialReading?: string, shouldSanitizeRawOutput?: boolean): () => {
|
|
13
|
+
startScan: () => Promise<void>;
|
|
14
|
+
changeDeviceStatus: (nextStatus: StarCloudScanStatus) => void;
|
|
15
|
+
scanStatus: StarCloudScanStatus;
|
|
16
|
+
reading: string | undefined;
|
|
17
|
+
connectionError: string | undefined;
|
|
18
|
+
isLoading: boolean;
|
|
19
|
+
isError: boolean;
|
|
20
|
+
};
|
|
21
|
+
export default createUseStarCloudScanHook;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const o=require("react"),k=require("dayjs"),j=require("@ancon/wildcat-printing"),G=require("../shared/hooks/usePrevious.js"),I=require("../shared/hooks/useMountedRef.js"),e=require("./types.js"),R=["TSP654"],V=1;function z(b,q,L,N,O=!1){const{useAppStore:T,useStarPrinterDiscover:_}=q,{selectedClientPrinterSelector:F}=L;function M(){const t=I(),g=T(),p=_(),l=o.useRef(void 0),[s,x]=o.useState(b),[a,P]=o.useState(),[S,f]=o.useState(),D=G(S),[A,v]=o.useState(),[U,w]=o.useState(N),r=o.useCallback(c=>{t!=null&&t.current&&x(c)},[t]),h=o.useCallback(async c=>{var u;(u=l.current)==null||u.stop(),r(e.StarCloudScanStatus.ScanningComplete);const i=String.fromCharCode(...c).trim();w(O?i.replace(/[\D]/gi,""):i)},[r]),m=o.useCallback(async({macAddress:c,ipAddress:i})=>{function u(n){r(e.StarCloudScanStatus.CommunicationError),t!=null&&t.current&&v(n==null?void 0:n.message)}const d={inputDevice:{onConnected:()=>{const n=((a==null?void 0:a.inputDeviceCount)||0)+1;r(n>0?e.StarCloudScanStatus.ReadyToScan:e.StarCloudScanStatus.PrinterDetected),P({inputDeviceCount:n,lastConnectedOn:new Date})},onDisconnected:()=>{const n=((a==null?void 0:a.inputDeviceCount)||0)-1>=0?((a==null?void 0:a.inputDeviceCount)||0)-1:0;r(n>0?e.StarCloudScanStatus.ReadyToScan:e.StarCloudScanStatus.PrinterDetected),P({inputDeviceCount:n})},onCommunicationError:u,onDataReceived:n=>f({data:n,lastReceivedOn:new Date})}};if(l.current=j.monitor(i||c,d),t!=null&&t.current)try{await l.current.start()}catch(n){r(e.StarCloudScanStatus.CommunicationError),t!=null&&t.current&&v(n==null?void 0:n.message)}},[a,r,t]),y=o.useCallback(async()=>{t!=null&&t.current&&(r(e.StarCloudScanStatus.WaitingForPrinter),v(void 0),f(void 0),P(void 0),w(void 0));const c=F(g.getState()),{macAddress:i,serialNumber:u}=c;try{const n=(await p(2e3)).find(C=>i&&C.macAddress.toLowerCase()===i.toLowerCase()||u&&C.serialNumber===u);if(t!=null&&t.current){if(n){if(R.some(C=>{var E;return(E=n.model)==null?void 0:E.toLowerCase().includes(C.toLowerCase())})){r(e.StarCloudScanStatus.UnsupportedPrinter);return}m(n)}r(n?e.StarCloudScanStatus.PrinterDetected:e.StarCloudScanStatus.PrinterNotDetected)}}catch{t!=null&&t.current&&r(e.StarCloudScanStatus.PrinterNotDetected)}},[t,g,r,p,m]),W=s===e.StarCloudScanStatus.WaitingForPrinter||s===e.StarCloudScanStatus.PrinterDetected||s===e.StarCloudScanStatus.ReadyToScan||s===e.StarCloudScanStatus.ScanningComplete,H=s===e.StarCloudScanStatus.PrinterNotDetected||s===e.StarCloudScanStatus.ScanFailed||s===e.StarCloudScanStatus.CommunicationError||s===e.StarCloudScanStatus.UnsupportedPrinter;return o.useEffect(()=>{if(!D&&(S==null?void 0:S.data)&&a&&(a!=null&&a.lastConnectedOn)){const{lastConnectedOn:i}=a,{lastReceivedOn:u,data:d}=S;k(u).diff(k(i),"second",!0)>V?h(d):f(void 0)}},[S,D,a,h]),o.useEffect(()=>(s===e.StarCloudScanStatus.WaitingForPrinter&&y(),()=>{var c;(c=l.current)==null||c.stop()}),[]),{startScan:y,changeDeviceStatus:r,scanStatus:s,reading:U,connectionError:A,isLoading:W,isError:H}}return M}module.exports=z;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { useRef as V, useState as l, useCallback as f, useEffect as N } from "react";
|
|
2
|
+
import O from "dayjs";
|
|
3
|
+
import { monitor as q } from "@ancon/wildcat-printing";
|
|
4
|
+
import z from "../shared/hooks/usePrevious.mjs";
|
|
5
|
+
import B from "../shared/hooks/useMountedRef.mjs";
|
|
6
|
+
import { StarCloudScanStatus as e } from "./types.mjs";
|
|
7
|
+
const J = ["TSP654"], K = 1;
|
|
8
|
+
function tt(T, k, F, M, b = !1) {
|
|
9
|
+
const { useAppStore: x, useStarPrinterDiscover: A } = k, { selectedClientPrinterSelector: U } = F;
|
|
10
|
+
function W() {
|
|
11
|
+
const t = B(), v = x(), D = A(), C = V(void 0), [i, H] = l(T), [r, m] = l(), [d, P] = l(), g = z(d), [j, p] = l(), [G, w] = l(M), o = f(
|
|
12
|
+
(c) => {
|
|
13
|
+
t != null && t.current && H(c);
|
|
14
|
+
},
|
|
15
|
+
[t]
|
|
16
|
+
), y = f(
|
|
17
|
+
async (c) => {
|
|
18
|
+
var a;
|
|
19
|
+
(a = C.current) == null || a.stop(), o(e.ScanningComplete);
|
|
20
|
+
const s = String.fromCharCode(...c).trim();
|
|
21
|
+
w(
|
|
22
|
+
b ? s.replace(/[\D]/gi, "") : s
|
|
23
|
+
);
|
|
24
|
+
},
|
|
25
|
+
[o]
|
|
26
|
+
), E = f(
|
|
27
|
+
async ({ macAddress: c, ipAddress: s }) => {
|
|
28
|
+
function a(n) {
|
|
29
|
+
o(e.CommunicationError), t != null && t.current && p(n == null ? void 0 : n.message);
|
|
30
|
+
}
|
|
31
|
+
const u = {
|
|
32
|
+
inputDevice: {
|
|
33
|
+
onConnected: () => {
|
|
34
|
+
const n = ((r == null ? void 0 : r.inputDeviceCount) || 0) + 1;
|
|
35
|
+
o(
|
|
36
|
+
n > 0 ? e.ReadyToScan : e.PrinterDetected
|
|
37
|
+
), m({
|
|
38
|
+
inputDeviceCount: n,
|
|
39
|
+
lastConnectedOn: /* @__PURE__ */ new Date()
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
onDisconnected: () => {
|
|
43
|
+
const n = ((r == null ? void 0 : r.inputDeviceCount) || 0) - 1 >= 0 ? ((r == null ? void 0 : r.inputDeviceCount) || 0) - 1 : 0;
|
|
44
|
+
o(
|
|
45
|
+
n > 0 ? e.ReadyToScan : e.PrinterDetected
|
|
46
|
+
), m({
|
|
47
|
+
inputDeviceCount: n
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
onCommunicationError: a,
|
|
51
|
+
onDataReceived: (n) => P({ data: n, lastReceivedOn: /* @__PURE__ */ new Date() })
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
if (C.current = q(s || c, u), t != null && t.current)
|
|
55
|
+
try {
|
|
56
|
+
await C.current.start();
|
|
57
|
+
} catch (n) {
|
|
58
|
+
o(e.CommunicationError), t != null && t.current && p(n == null ? void 0 : n.message);
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
[r, o, t]
|
|
62
|
+
), h = f(async () => {
|
|
63
|
+
t != null && t.current && (o(e.WaitingForPrinter), p(void 0), P(void 0), m(void 0), w(void 0));
|
|
64
|
+
const c = U(v.getState()), { macAddress: s, serialNumber: a } = c;
|
|
65
|
+
try {
|
|
66
|
+
const n = (await D(2e3)).find(
|
|
67
|
+
(S) => s && S.macAddress.toLowerCase() === s.toLowerCase() || a && S.serialNumber === a
|
|
68
|
+
);
|
|
69
|
+
if (t != null && t.current) {
|
|
70
|
+
if (n) {
|
|
71
|
+
if (J.some(
|
|
72
|
+
(S) => {
|
|
73
|
+
var L;
|
|
74
|
+
return (L = n.model) == null ? void 0 : L.toLowerCase().includes(S.toLowerCase());
|
|
75
|
+
}
|
|
76
|
+
)) {
|
|
77
|
+
o(e.UnsupportedPrinter);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
E(n);
|
|
81
|
+
}
|
|
82
|
+
o(
|
|
83
|
+
n ? e.PrinterDetected : e.PrinterNotDetected
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
} catch {
|
|
87
|
+
t != null && t.current && o(e.PrinterNotDetected);
|
|
88
|
+
}
|
|
89
|
+
}, [
|
|
90
|
+
t,
|
|
91
|
+
v,
|
|
92
|
+
o,
|
|
93
|
+
D,
|
|
94
|
+
E
|
|
95
|
+
]), I = i === e.WaitingForPrinter || i === e.PrinterDetected || i === e.ReadyToScan || i === e.ScanningComplete, R = i === e.PrinterNotDetected || i === e.ScanFailed || i === e.CommunicationError || i === e.UnsupportedPrinter;
|
|
96
|
+
return N(() => {
|
|
97
|
+
if (!g && (d == null ? void 0 : d.data) && r && (r != null && r.lastConnectedOn)) {
|
|
98
|
+
const { lastConnectedOn: s } = r, { lastReceivedOn: a, data: u } = d;
|
|
99
|
+
O(a).diff(
|
|
100
|
+
O(s),
|
|
101
|
+
"second",
|
|
102
|
+
!0
|
|
103
|
+
) > K ? y(u) : P(void 0);
|
|
104
|
+
}
|
|
105
|
+
}, [d, g, r, y]), N(() => (i === e.WaitingForPrinter && h(), () => {
|
|
106
|
+
var c;
|
|
107
|
+
(c = C.current) == null || c.stop();
|
|
108
|
+
}), []), {
|
|
109
|
+
startScan: h,
|
|
110
|
+
changeDeviceStatus: o,
|
|
111
|
+
scanStatus: i,
|
|
112
|
+
reading: G,
|
|
113
|
+
connectionError: j,
|
|
114
|
+
isLoading: I,
|
|
115
|
+
isError: R
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
return W;
|
|
119
|
+
}
|
|
120
|
+
export {
|
|
121
|
+
tt as default
|
|
122
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const e=require("@ancon/wildcat-types");var c=(t=>(t[t.Esc=0]="Esc",t[t.Star=1]="Star",t))(c||{});function r(t){const n=t;switch(n==null?void 0:n.connectionType){case e.PrinterConnectionType.StarCloudPrint:return c.Star;case e.PrinterConnectionType.HostAddress:default:return c.Esc}}module.exports=r;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
function
|
|
4
|
-
const
|
|
5
|
-
switch (
|
|
6
|
-
case
|
|
7
|
-
return
|
|
8
|
-
case
|
|
1
|
+
import { PrinterConnectionType as n } from "@ancon/wildcat-types";
|
|
2
|
+
var c = /* @__PURE__ */ ((t) => (t[t.Esc = 0] = "Esc", t[t.Star = 1] = "Star", t))(c || {});
|
|
3
|
+
function s(t) {
|
|
4
|
+
const r = t;
|
|
5
|
+
switch (r == null ? void 0 : r.connectionType) {
|
|
6
|
+
case n.StarCloudPrint:
|
|
7
|
+
return c.Star;
|
|
8
|
+
case n.HostAddress:
|
|
9
9
|
default:
|
|
10
|
-
return
|
|
10
|
+
return c.Esc;
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
export {
|
|
14
|
-
|
|
14
|
+
s as default
|
|
15
15
|
};
|
package/printing/index.d.ts
CHANGED
|
@@ -4,4 +4,5 @@ import isValidNetworkPrinter from './isValidNetworkPrinter';
|
|
|
4
4
|
import isValidStarCloudPrinter from './isValidStarCloudPrinter';
|
|
5
5
|
import isTerminalPrinter from './isTerminalPrinter';
|
|
6
6
|
import isCloudPrintModeEnabled from './isCloudPrintModeEnabled';
|
|
7
|
-
|
|
7
|
+
import createUseStarCloudScanHook from './createStarCloudScanHook';
|
|
8
|
+
export { getPrinterType, isValidPrinter, isValidNetworkPrinter, isValidStarCloudPrinter, isTerminalPrinter, isCloudPrintModeEnabled, createUseStarCloudScanHook, };
|
package/printing/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./getPrinterType.js"),
|
|
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;
|
package/printing/index.mjs
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
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 "
|
|
1
|
+
import { default as p } from "./getPrinterType.mjs";
|
|
2
|
+
import { default as s } from "./isValidPrinter.mjs";
|
|
3
|
+
import { default as n } from "./isValidNetworkPrinter.mjs";
|
|
4
|
+
import { default as P } from "./isValidStarCloudPrinter.mjs";
|
|
5
|
+
import { default as S } from "./isTerminalPrinter.mjs";
|
|
6
|
+
import { default as c } from "./isCloudPrintModeEnabled.mjs";
|
|
7
|
+
import { default as T } from "./createStarCloudScanHook.mjs";
|
|
8
8
|
import "@ancon/wildcat-types";
|
|
9
|
+
import "react";
|
|
10
|
+
import "dayjs";
|
|
11
|
+
import "@ancon/wildcat-printing";
|
|
12
|
+
import "../shared/hooks/usePrevious.mjs";
|
|
13
|
+
import "../shared/hooks/useMountedRef.mjs";
|
|
14
|
+
import "./types.mjs";
|
|
9
15
|
export {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
T as createUseStarCloudScanHook,
|
|
17
|
+
p as getPrinterType,
|
|
18
|
+
c as isCloudPrintModeEnabled,
|
|
19
|
+
S as isTerminalPrinter,
|
|
20
|
+
n as isValidNetworkPrinter,
|
|
21
|
+
s as isValidPrinter,
|
|
22
|
+
P as isValidStarCloudPrinter
|
|
16
23
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var i=(e=>(e[e.WaitingForPrinter=0]="WaitingForPrinter",e[e.PrinterDetected=1]="PrinterDetected",e[e.PrinterNotDetected=2]="PrinterNotDetected",e[e.ReadyToScan=3]="ReadyToScan",e[e.ScanningComplete=4]="ScanningComplete",e[e.ScanFailed=5]="ScanFailed",e[e.ScanSuccess=6]="ScanSuccess",e[e.CommunicationError=7]="CommunicationError",e[e.UnsupportedPrinter=8]="UnsupportedPrinter",e))(i||{});exports.StarCloudScanStatus=i;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var i = /* @__PURE__ */ ((e) => (e[e.WaitingForPrinter = 0] = "WaitingForPrinter", e[e.PrinterDetected = 1] = "PrinterDetected", e[e.PrinterNotDetected = 2] = "PrinterNotDetected", e[e.ReadyToScan = 3] = "ReadyToScan", e[e.ScanningComplete = 4] = "ScanningComplete", e[e.ScanFailed = 5] = "ScanFailed", e[e.ScanSuccess = 6] = "ScanSuccess", e[e.CommunicationError = 7] = "CommunicationError", e[e.UnsupportedPrinter = 8] = "UnsupportedPrinter", e))(i || {});
|
|
2
|
+
export {
|
|
3
|
+
i as StarCloudScanStatus
|
|
4
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./usePrevious.js"),o=require("./useMountedRef.js");require("react");exports.usePrevious=e;exports.useMountedRef=o;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const r=require("react");function t(){const e=r.useRef(!1);return r.useEffect(()=>(e.current=!0,()=>{e.current=!1}),[]),e}module.exports=t;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook for saving some previous value
|
|
3
|
+
* @param {*} value - Any value
|
|
4
|
+
* @param {boolean} [setInitialValue] - Whether or not to set the ref's inital value
|
|
5
|
+
* @returns {*} - Previous value
|
|
6
|
+
*/
|
|
7
|
+
export default function usePrevious(value?: any, setInitialValue?: boolean): any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const t=require("react");function c(e,s=!1){const r=t.useRef(s?e:void 0);return t.useEffect(()=>{r.current=e},[e]),r.current}module.exports=c;
|
package/shared/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import isWithinFlag from './isWithinFlag';
|
|
2
2
|
import generateId from './generateId';
|
|
3
3
|
import wait from './wait';
|
|
4
|
-
|
|
4
|
+
import { useMountedRef, usePrevious } from './hooks';
|
|
5
|
+
export { isWithinFlag, generateId, wait, useMountedRef, usePrevious };
|
package/shared/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./isWithinFlag.js"),r=require("./generateId.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./isWithinFlag.js"),r=require("./generateId.js"),s=require("./wait.js"),i=require("./hooks/usePrevious.js"),t=require("./hooks/useMountedRef.js");require("react");exports.isWithinFlag=e;exports.generateId=r;exports.wait=s;exports.usePrevious=i;exports.useMountedRef=t;
|
package/shared/index.mjs
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { default as
|
|
1
|
+
import { default as o } from "./isWithinFlag.mjs";
|
|
2
2
|
import { default as f } from "./generateId.mjs";
|
|
3
|
-
import { default as
|
|
3
|
+
import { default as u } from "./wait.mjs";
|
|
4
|
+
import { default as i } from "./hooks/usePrevious.mjs";
|
|
5
|
+
import { default as m } from "./hooks/useMountedRef.mjs";
|
|
6
|
+
import "react";
|
|
4
7
|
export {
|
|
5
8
|
f as generateId,
|
|
6
|
-
|
|
7
|
-
|
|
9
|
+
o as isWithinFlag,
|
|
10
|
+
m as useMountedRef,
|
|
11
|
+
i as usePrevious,
|
|
12
|
+
u as wait
|
|
8
13
|
};
|