@kosdev-code/kos-dispense-sdk 0.1.0-dev.5880 → 0.1.0-next.1000
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/.kos.json +129 -0
- package/{dispense-registration-manager-ukk4OBeX.cjs → dispense-registration-manager-CfWgJqfq.cjs} +807 -445
- package/dispense-registration-manager-CfWgJqfq.cjs.map +1 -0
- package/{dispense-registration-manager-C4XZ_c3x.js → dispense-registration-manager-DtN0T_JG.js} +846 -484
- package/dispense-registration-manager-DtN0T_JG.js.map +1 -0
- package/{extension-utils-CMVLCSA8.cjs → extension-utils-BWYG2dYG.cjs} +52 -194
- package/extension-utils-BWYG2dYG.cjs.map +1 -0
- package/{extension-utils-FxS68Xu9.js → extension-utils-BoXtjU5_.js} +58 -200
- package/extension-utils-BoXtjU5_.js.map +1 -0
- package/extensions/control-pour-extension.d.ts +8 -9
- package/extensions/control-pour-extension.d.ts.map +1 -1
- package/extensions/index.d.ts.map +1 -1
- package/index.cjs +31 -11
- package/index.cjs.map +1 -1
- package/index.d.ts.map +1 -1
- package/index.js +118 -98
- package/index.js.map +1 -1
- package/models/constants/constants.d.ts +14 -178
- package/models/constants/constants.d.ts.map +1 -1
- package/models/constants/index.d.ts.map +1 -1
- package/models/index.d.ts.map +1 -1
- package/models/models/assembly/assembly-model.d.ts +12 -5
- package/models/models/assembly/assembly-model.d.ts.map +1 -1
- package/models/models/assembly/assembly-registration.d.ts +12 -71
- package/models/models/assembly/assembly-registration.d.ts.map +1 -1
- package/models/models/assembly/board-utils.d.ts +1 -2
- package/models/models/assembly/board-utils.d.ts.map +1 -1
- package/models/models/assembly/holder-utils.d.ts +1 -2
- package/models/models/assembly/holder-utils.d.ts.map +1 -1
- package/models/models/assembly/index.d.ts.map +1 -1
- package/models/models/assembly/nozzle-utils.d.ts +1 -2
- package/models/models/assembly/nozzle-utils.d.ts.map +1 -1
- package/models/models/assembly/pump-utils.d.ts +2 -3
- package/models/models/assembly/pump-utils.d.ts.map +1 -1
- package/models/models/assembly/services/assembly-services.d.ts +0 -1
- package/models/models/assembly/services/assembly-services.d.ts.map +1 -1
- package/models/models/assembly/services/index.d.ts.map +1 -1
- package/models/models/assembly/types/index.d.ts +8 -3
- package/models/models/availability/availability-model.d.ts +13 -78
- package/models/models/availability/availability-model.d.ts.map +1 -1
- package/models/models/availability/index.d.ts.map +1 -1
- package/models/models/availability/types/index.d.ts +7 -13
- package/models/models/board/board-container-model.d.ts +10 -3
- package/models/models/board/board-container-model.d.ts.map +1 -1
- package/models/models/board/board-container-registration.d.ts +13 -77
- package/models/models/board/board-container-registration.d.ts.map +1 -1
- package/models/models/board/board-model.d.ts +1 -2
- package/models/models/board/board-model.d.ts.map +1 -1
- package/models/models/board/board-registration.d.ts +12 -74
- package/models/models/board/board-registration.d.ts.map +1 -1
- package/models/models/board/index.d.ts.map +1 -1
- package/models/models/board/types/index.d.ts +12 -2
- package/models/models/board/types/services.d.ts.map +1 -1
- package/models/models/board/utils/board-trouble-data-mapper.d.ts +1 -2
- package/models/models/board/utils/board-trouble-data-mapper.d.ts.map +1 -1
- package/models/models/board/utils/board-trouble-resolver.d.ts +0 -1
- package/models/models/board/utils/board-trouble-resolver.d.ts.map +1 -1
- package/models/models/cui-kit-state/cui-kit-state-model.d.ts +133 -0
- package/models/models/cui-kit-state/cui-kit-state-model.d.ts.map +1 -0
- package/models/models/cui-kit-state/index.d.ts +4 -0
- package/models/models/cui-kit-state/index.d.ts.map +1 -0
- package/models/models/cui-kit-state/types/index.d.ts +82 -0
- package/models/models/device-assembly/device-assembly-model.d.ts +6 -3
- package/models/models/device-assembly/device-assembly-model.d.ts.map +1 -1
- package/models/models/device-assembly/device-assembly-registration.d.ts +14 -79
- package/models/models/device-assembly/device-assembly-registration.d.ts.map +1 -1
- package/models/models/device-assembly/index.d.ts.map +1 -1
- package/models/models/device-assembly/types/index.d.ts +4 -0
- package/models/models/generic-pour/generic-pour-model.d.ts +19 -4
- package/models/models/generic-pour/generic-pour-model.d.ts.map +1 -1
- package/models/models/generic-pour/generic-pour-registration.d.ts +13 -75
- package/models/models/generic-pour/generic-pour-registration.d.ts.map +1 -1
- package/models/models/generic-pour/index.d.ts.map +1 -1
- package/models/models/generic-pour/services/generic-pour-services.d.ts.map +1 -1
- package/models/models/generic-pour/services/index.d.ts.map +1 -1
- package/models/models/generic-pour/types/index.d.ts +4 -0
- package/models/models/holder/holder-model.d.ts +16 -75
- package/models/models/holder/holder-model.d.ts.map +1 -1
- package/models/models/holder/index.d.ts.map +1 -1
- package/models/models/holder/services/assignment-services.d.ts.map +1 -1
- package/models/models/holder/services/holder-services.d.ts.map +1 -1
- package/models/models/holder/services/index.d.ts.map +1 -1
- package/models/models/holder/types/index.d.ts +11 -7
- package/models/models/holder/utils/holder-utils.d.ts +0 -1
- package/models/models/holder/utils/holder-utils.d.ts.map +1 -1
- package/models/models/holder-container/holder-container-model.d.ts +12 -70
- package/models/models/holder-container/holder-container-model.d.ts.map +1 -1
- package/models/models/holder-container/index.d.ts.map +1 -1
- package/models/models/holder-container/types/index.d.ts +16 -5
- package/models/models/index.d.ts +1 -0
- package/models/models/index.d.ts.map +1 -1
- package/models/models/ingredient/index.d.ts.map +1 -1
- package/models/models/ingredient/ingredient-model.d.ts +12 -76
- package/models/models/ingredient/ingredient-model.d.ts.map +1 -1
- package/models/models/ingredient/services/index.d.ts.map +1 -1
- package/models/models/ingredient/services/ingredient-services.d.ts.map +1 -1
- package/models/models/ingredient/types/index.d.ts +7 -13
- package/models/models/ingredient-container/index.d.ts.map +1 -1
- package/models/models/ingredient-container/ingredient-container-model.d.ts +12 -70
- package/models/models/ingredient-container/ingredient-container-model.d.ts.map +1 -1
- package/models/models/ingredient-container/types/index.d.ts +7 -3
- package/models/models/nozzle/index.d.ts.map +1 -1
- package/models/models/nozzle/nozzle-model.d.ts +20 -81
- package/models/models/nozzle/nozzle-model.d.ts.map +1 -1
- package/models/models/nozzle/services/index.d.ts.map +1 -1
- package/models/models/nozzle/services/nozzle-services.d.ts +11 -65
- package/models/models/nozzle/services/nozzle-services.d.ts.map +1 -1
- package/models/models/nozzle/types/index.d.ts +7 -3
- package/models/models/pump/index.d.ts.map +1 -1
- package/models/models/pump/pump-model.d.ts +12 -81
- package/models/models/pump/pump-model.d.ts.map +1 -1
- package/models/models/pump/services/index.d.ts.map +1 -1
- package/models/models/pump/services/pump-services.d.ts +3 -5
- package/models/models/pump/services/pump-services.d.ts.map +1 -1
- package/models/models/pump/types/index.d.ts +7 -3
- package/models/models/pump/utils/pump-trouble-resolver.d.ts +0 -1
- package/models/models/pump/utils/pump-trouble-resolver.d.ts.map +1 -1
- package/models/models/pump-container/index.d.ts.map +1 -1
- package/models/models/pump-container/pump-container-model.d.ts +16 -70
- package/models/models/pump-container/pump-container-model.d.ts.map +1 -1
- package/models/models/pump-container/types/index.d.ts +7 -3
- package/models/models/types/assembly.d.ts.map +1 -1
- package/models/models/types/index.d.ts.map +1 -1
- package/models/models/types/intent.d.ts +11 -79
- package/models/models/types/intent.d.ts.map +1 -1
- package/models/models/types/pouring.d.ts.map +1 -1
- package/models/utils/dispense-registration-manager.d.ts +34 -10
- package/models/utils/dispense-registration-manager.d.ts.map +1 -1
- package/models/utils/extension-utils.d.ts +66 -173
- package/models/utils/extension-utils.d.ts.map +1 -1
- package/models/utils/openapi-index.d.ts +1 -1
- package/models/utils/openapi-index.d.ts.map +1 -1
- package/models/utils/pour-context.d.ts +8 -0
- package/models/utils/pour-context.d.ts.map +1 -0
- package/models/utils/registration.d.ts +0 -1
- package/models/utils/registration.d.ts.map +1 -1
- package/models/utils/service.d.ts +34 -35
- package/models/utils/service.d.ts.map +1 -1
- package/models/utils/services/dispense/1.6.5/service.d.ts +34 -35
- package/models/utils/services/dispense/1.6.5/service.d.ts.map +1 -1
- package/models/utils/services/dispense/1.8.1/service.d.ts +34 -35
- package/models/utils/services/dispense/1.8.1/service.d.ts.map +1 -1
- package/models/utils/services/dispense/daily/openapi.d.ts +1941 -1812
- package/models/utils/services/dispense/daily/service.d.ts +127 -37
- package/models/utils/services/dispense/daily/service.d.ts.map +1 -1
- package/models/utils/services-index.d.ts +1 -1
- package/models/utils/services-index.d.ts.map +1 -1
- package/models.cjs +4 -5
- package/models.cjs.map +1 -1
- package/models.d.ts +1 -0
- package/models.js +29 -30
- package/models.js.map +1 -1
- package/package.json +11 -12
- package/{pump-provider-BAQXIUuP.cjs → pump-provider-B4WR3LiY.cjs} +480 -544
- package/pump-provider-B4WR3LiY.cjs.map +1 -0
- package/{pump-provider-9rUgev7q.js → pump-provider-CPUsLke5.js} +541 -605
- package/pump-provider-CPUsLke5.js.map +1 -0
- package/ui/contexts/assembly/assembly-provider.d.ts +9 -2
- package/ui/contexts/assembly/assembly-provider.d.ts.map +1 -1
- package/ui/contexts/assembly/index.d.ts.map +1 -1
- package/ui/contexts/availability/availability-provider.d.ts +9 -2
- package/ui/contexts/availability/availability-provider.d.ts.map +1 -1
- package/ui/contexts/availability/index.d.ts.map +1 -1
- package/ui/contexts/board/board-provider.d.ts +9 -2
- package/ui/contexts/board/board-provider.d.ts.map +1 -1
- package/ui/contexts/board/index.d.ts.map +1 -1
- package/ui/contexts/board-container/board-container-provider.d.ts +9 -2
- package/ui/contexts/board-container/board-container-provider.d.ts.map +1 -1
- package/ui/contexts/board-container/index.d.ts.map +1 -1
- package/ui/contexts/cui-kit/cui-kit.d.ts +17 -3
- package/ui/contexts/cui-kit/cui-kit.d.ts.map +1 -1
- package/ui/contexts/cui-kit/index.d.ts.map +1 -1
- package/ui/contexts/device-assembly/device-assembly-provider.d.ts +9 -2
- package/ui/contexts/device-assembly/device-assembly-provider.d.ts.map +1 -1
- package/ui/contexts/device-assembly/index.d.ts.map +1 -1
- package/ui/contexts/holder/holder-provider.d.ts +9 -2
- package/ui/contexts/holder/holder-provider.d.ts.map +1 -1
- package/ui/contexts/holder/index.d.ts.map +1 -1
- package/ui/contexts/holder-container/holder-container-provider.d.ts +9 -2
- package/ui/contexts/holder-container/holder-container-provider.d.ts.map +1 -1
- package/ui/contexts/holder-container/index.d.ts.map +1 -1
- package/ui/contexts/index.d.ts.map +1 -1
- package/ui/contexts/ingredient/index.d.ts.map +1 -1
- package/ui/contexts/ingredient/ingredient-provider.d.ts +9 -2
- package/ui/contexts/ingredient/ingredient-provider.d.ts.map +1 -1
- package/ui/contexts/ingredient-container/index.d.ts.map +1 -1
- package/ui/contexts/ingredient-container/ingredient-container-provider.d.ts +9 -2
- package/ui/contexts/ingredient-container/ingredient-container-provider.d.ts.map +1 -1
- package/ui/contexts/nozzle/index.d.ts.map +1 -1
- package/ui/contexts/nozzle/nozzle-provider.d.ts +9 -2
- package/ui/contexts/nozzle/nozzle-provider.d.ts.map +1 -1
- package/ui/contexts/pump/index.d.ts.map +1 -1
- package/ui/contexts/pump/pump-provider.d.ts +9 -2
- package/ui/contexts/pump/pump-provider.d.ts.map +1 -1
- package/ui/hooks/assembly/index.d.ts.map +1 -1
- package/ui/hooks/assembly/use-assembly.d.ts +5 -2
- package/ui/hooks/assembly/use-assembly.d.ts.map +1 -1
- package/ui/hooks/assembly/with-assembly.d.ts +4 -1
- package/ui/hooks/assembly/with-assembly.d.ts.map +1 -1
- package/ui/hooks/availability/index.d.ts.map +1 -1
- package/ui/hooks/availability/use-availability.d.ts +5 -2
- package/ui/hooks/availability/use-availability.d.ts.map +1 -1
- package/ui/hooks/availability/with-availability.d.ts +0 -1
- package/ui/hooks/availability/with-availability.d.ts.map +1 -1
- package/ui/hooks/board/index.d.ts.map +1 -1
- package/ui/hooks/board/use-board.d.ts +5 -2
- package/ui/hooks/board/use-board.d.ts.map +1 -1
- package/ui/hooks/board/with-board.d.ts +4 -1
- package/ui/hooks/board/with-board.d.ts.map +1 -1
- package/ui/hooks/board-container/index.d.ts.map +1 -1
- package/ui/hooks/board-container/use-board-container.d.ts +5 -2
- package/ui/hooks/board-container/use-board-container.d.ts.map +1 -1
- package/ui/hooks/board-container/with-board-container.d.ts +4 -1
- package/ui/hooks/board-container/with-board-container.d.ts.map +1 -1
- package/ui/hooks/cui-kit/dispense-topics.d.ts +0 -1
- package/ui/hooks/cui-kit/dispense-topics.d.ts.map +1 -1
- package/ui/hooks/cui-kit/index.d.ts.map +1 -1
- package/ui/hooks/cui-kit/use-ambient-attract-timers.d.ts +0 -1
- package/ui/hooks/cui-kit/use-ambient-attract-timers.d.ts.map +1 -1
- package/ui/hooks/cui-kit/use-beverages.d.ts +1 -2
- package/ui/hooks/cui-kit/use-beverages.d.ts.map +1 -1
- package/ui/hooks/cui-kit/use-brands.d.ts +1 -2
- package/ui/hooks/cui-kit/use-brands.d.ts.map +1 -1
- package/ui/hooks/cui-kit/use-cui-kit.d.ts +51 -7
- package/ui/hooks/cui-kit/use-cui-kit.d.ts.map +1 -1
- package/ui/hooks/cui-kit/use-default-cui-kit-lifecycle.d.ts +16 -44
- package/ui/hooks/cui-kit/use-default-cui-kit-lifecycle.d.ts.map +1 -1
- package/ui/hooks/cui-kit/use-dispense-lifecycle.d.ts +0 -1
- package/ui/hooks/cui-kit/use-dispense-lifecycle.d.ts.map +1 -1
- package/ui/hooks/cui-kit/use-dispense-timers.d.ts +0 -1
- package/ui/hooks/cui-kit/use-dispense-timers.d.ts.map +1 -1
- package/ui/hooks/cui-kit/use-flavors.d.ts +1 -2
- package/ui/hooks/cui-kit/use-flavors.d.ts.map +1 -1
- package/ui/hooks/device-assembly/index.d.ts.map +1 -1
- package/ui/hooks/device-assembly/use-device-assembly.d.ts +5 -2
- package/ui/hooks/device-assembly/use-device-assembly.d.ts.map +1 -1
- package/ui/hooks/device-assembly/with-device-assembly.d.ts +4 -1
- package/ui/hooks/device-assembly/with-device-assembly.d.ts.map +1 -1
- package/ui/hooks/generic-pour/index.d.ts.map +1 -1
- package/ui/hooks/generic-pour/use-generic-pour.d.ts +6 -3
- package/ui/hooks/generic-pour/use-generic-pour.d.ts.map +1 -1
- package/ui/hooks/generic-pour/with-generic-pour.d.ts +5 -2
- package/ui/hooks/generic-pour/with-generic-pour.d.ts.map +1 -1
- package/ui/hooks/holder/index.d.ts.map +1 -1
- package/ui/hooks/holder/use-holder.d.ts +5 -2
- package/ui/hooks/holder/use-holder.d.ts.map +1 -1
- package/ui/hooks/holder/with-holder.d.ts +4 -1
- package/ui/hooks/holder/with-holder.d.ts.map +1 -1
- package/ui/hooks/holder-container/index.d.ts.map +1 -1
- package/ui/hooks/holder-container/use-holder-container.d.ts +7 -4
- package/ui/hooks/holder-container/use-holder-container.d.ts.map +1 -1
- package/ui/hooks/holder-container/with-holder-container.d.ts +4 -1
- package/ui/hooks/holder-container/with-holder-container.d.ts.map +1 -1
- package/ui/hooks/index.d.ts.map +1 -1
- package/ui/hooks/ingredient/index.d.ts.map +1 -1
- package/ui/hooks/ingredient/use-ingredient-pour.d.ts +16 -22
- package/ui/hooks/ingredient/use-ingredient-pour.d.ts.map +1 -1
- package/ui/hooks/ingredient/use-ingredient.d.ts +5 -2
- package/ui/hooks/ingredient/use-ingredient.d.ts.map +1 -1
- package/ui/hooks/ingredient/with-ingredient.d.ts +4 -1
- package/ui/hooks/ingredient/with-ingredient.d.ts.map +1 -1
- package/ui/hooks/ingredient-container/index.d.ts.map +1 -1
- package/ui/hooks/ingredient-container/use-ingredient-container.d.ts +5 -2
- package/ui/hooks/ingredient-container/use-ingredient-container.d.ts.map +1 -1
- package/ui/hooks/ingredient-container/with-ingredient-container.d.ts +4 -1
- package/ui/hooks/ingredient-container/with-ingredient-container.d.ts.map +1 -1
- package/ui/hooks/nozzle/index.d.ts.map +1 -1
- package/ui/hooks/nozzle/use-dispense-kit.d.ts +0 -1
- package/ui/hooks/nozzle/use-dispense-kit.d.ts.map +1 -1
- package/ui/hooks/nozzle/use-nozzle.d.ts +5 -2
- package/ui/hooks/nozzle/use-nozzle.d.ts.map +1 -1
- package/ui/hooks/nozzle/with-nozzle.d.ts +4 -1
- package/ui/hooks/nozzle/with-nozzle.d.ts.map +1 -1
- package/ui/hooks/nozzle-pour/index.d.ts.map +1 -1
- package/ui/hooks/nozzle-pour/use-nozzle-pour.d.ts +16 -22
- package/ui/hooks/nozzle-pour/use-nozzle-pour.d.ts.map +1 -1
- package/ui/hooks/pour/index.d.ts.map +1 -1
- package/ui/hooks/pour/use-pour.d.ts +11 -23
- package/ui/hooks/pour/use-pour.d.ts.map +1 -1
- package/ui/hooks/pump/index.d.ts.map +1 -1
- package/ui/hooks/pump/use-pump.d.ts +1 -2
- package/ui/hooks/pump/use-pump.d.ts.map +1 -1
- package/ui/hooks/pump/with-pump.d.ts +0 -1
- package/ui/hooks/pump/with-pump.d.ts.map +1 -1
- package/ui/hooks/utils/pour-strategy/hold-to-pour-intent-strategy.d.ts +5 -2
- package/ui/hooks/utils/pour-strategy/hold-to-pour-intent-strategy.d.ts.map +1 -1
- package/ui/hooks/utils/pour-strategy/hold-to-pour-strategy.d.ts +4 -1
- package/ui/hooks/utils/pour-strategy/hold-to-pour-strategy.d.ts.map +1 -1
- package/ui/hooks/utils/pour-strategy/index.d.ts.map +1 -1
- package/ui/hooks/utils/pour-strategy/pour-strategy.d.ts +11 -2
- package/ui/hooks/utils/pour-strategy/pour-strategy.d.ts.map +1 -1
- package/ui/hooks/utils/pour-strategy/tap-or-hold-to-pour-intent-strategy.d.ts +5 -2
- package/ui/hooks/utils/pour-strategy/tap-or-hold-to-pour-intent-strategy.d.ts.map +1 -1
- package/ui/hooks/utils/pour-strategy/tap-to-pour-intent-strategy.d.ts +5 -2
- package/ui/hooks/utils/pour-strategy/tap-to-pour-intent-strategy.d.ts.map +1 -1
- package/ui/hooks/utils/pour-strategy/tap-to-pour-strategy.d.ts +4 -1
- package/ui/hooks/utils/pour-strategy/tap-to-pour-strategy.d.ts.map +1 -1
- package/ui/index.d.ts.map +1 -1
- package/ui/utils/pour-context.d.ts +1 -7
- package/ui/utils/pour-context.d.ts.map +1 -1
- package/ui.cjs +3 -7
- package/ui.cjs.map +1 -1
- package/ui.d.ts +1 -0
- package/ui.js +64 -68
- package/ui.js.map +1 -1
- package/dispense-registration-manager-C4XZ_c3x.js.map +0 -1
- package/dispense-registration-manager-ukk4OBeX.cjs.map +0 -1
- package/extension-utils-CMVLCSA8.cjs.map +0 -1
- package/extension-utils-FxS68Xu9.js.map +0 -1
- package/kos-models.json +0 -180
- package/pump-provider-9rUgev7q.js.map +0 -1
- package/pump-provider-BAQXIUuP.cjs.map +0 -1
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
-
var __publicField = (obj, key, value) => {
|
|
5
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
6
|
-
return value;
|
|
7
|
-
};
|
|
8
2
|
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
9
3
|
const kosUiSdk = require("@kosdev-code/kos-ui-sdk");
|
|
10
|
-
const dispenseRegistrationManager = require("./dispense-registration-manager-ukk4OBeX.cjs");
|
|
11
4
|
const React = require("react");
|
|
5
|
+
const dispenseRegistrationManager = require("./dispense-registration-manager-CfWgJqfq.cjs");
|
|
12
6
|
const useAssembly = () => {
|
|
13
7
|
const modelId = dispenseRegistrationManager.Assembly.type;
|
|
14
8
|
const result = kosUiSdk.useKosModel({
|
|
@@ -108,8 +102,7 @@ const useBeverages = ({
|
|
|
108
102
|
const [beverages, setBeverages] = React.useState([]);
|
|
109
103
|
const [selectedBeverage, setSelectedBeverage] = React.useState(null);
|
|
110
104
|
const companions = React.useMemo(() => {
|
|
111
|
-
if (!companionType)
|
|
112
|
-
return [];
|
|
105
|
+
if (!companionType) return [];
|
|
113
106
|
return beverages.map(
|
|
114
107
|
(brand) => kosUiSdk.getKosCompanionModel(brand, companionType)
|
|
115
108
|
);
|
|
@@ -117,30 +110,29 @@ const useBeverages = ({
|
|
|
117
110
|
const selectBeverage = React.useCallback(
|
|
118
111
|
async (beverage, context, forceUpdate) => {
|
|
119
112
|
setSelectedBeverage(beverage);
|
|
120
|
-
await
|
|
121
|
-
onBeverageSelected
|
|
113
|
+
await nozzle?.setSelectedPourable({ beverage, context }, forceUpdate);
|
|
114
|
+
onBeverageSelected?.(beverage);
|
|
122
115
|
},
|
|
123
116
|
[nozzle, onBeverageSelected]
|
|
124
117
|
);
|
|
125
118
|
const clearBeverage = React.useCallback(async () => {
|
|
126
119
|
setSelectedBeverage(null);
|
|
127
|
-
await
|
|
128
|
-
onClearBeverage
|
|
120
|
+
await nozzle?.setSelectedPourable({ beverage: void 0 });
|
|
121
|
+
onClearBeverage?.();
|
|
129
122
|
}, [nozzle, onClearBeverage]);
|
|
130
123
|
React.useEffect(() => {
|
|
131
124
|
const disposer = kosUiSdk.kosAutoEffect(() => {
|
|
132
|
-
if (!nozzle)
|
|
133
|
-
return;
|
|
125
|
+
if (!nozzle) return;
|
|
134
126
|
const selectedBrand = nozzle.selectedBrand;
|
|
135
127
|
if (!selectedBrand) {
|
|
136
128
|
const allBeverages = nozzle.getGroupAvailabilityItems("beverages").filter((beverage) => beverage.visible);
|
|
137
129
|
setBeverages(allBeverages ?? []);
|
|
138
|
-
onBeverageListUpdated
|
|
130
|
+
onBeverageListUpdated?.(allBeverages);
|
|
139
131
|
return;
|
|
140
132
|
}
|
|
141
133
|
const beverages2 = nozzle.getAvailabilityByParent(selectedBrand.id).filter((b) => b.visible);
|
|
142
134
|
setBeverages(beverages2 ?? []);
|
|
143
|
-
onBeverageListUpdated
|
|
135
|
+
onBeverageListUpdated?.(beverages2);
|
|
144
136
|
});
|
|
145
137
|
return () => {
|
|
146
138
|
disposer();
|
|
@@ -154,6 +146,7 @@ const useBeverages = ({
|
|
|
154
146
|
clearBeverage
|
|
155
147
|
};
|
|
156
148
|
};
|
|
149
|
+
const log$4 = kosUiSdk.KosLog.createLogger({ group: kosUiSdk.LogGroup.ui, name: "use-brands" });
|
|
157
150
|
const useBrands = ({
|
|
158
151
|
onBrandSelected,
|
|
159
152
|
onBrandCleared,
|
|
@@ -163,32 +156,28 @@ const useBrands = ({
|
|
|
163
156
|
const [selectedBrand, setSelectedBrand] = React.useState(null);
|
|
164
157
|
const [brands, setBrands] = React.useState([]);
|
|
165
158
|
const companions = React.useMemo(() => {
|
|
166
|
-
if (!companionType)
|
|
167
|
-
return [];
|
|
159
|
+
if (!companionType) return [];
|
|
168
160
|
return brands.map((brand) => kosUiSdk.getKosCompanionModel(brand, companionType));
|
|
169
161
|
}, [brands, companionType]);
|
|
170
162
|
const selectBrand = React.useCallback(
|
|
171
163
|
async (brand, context, forceUpdate) => {
|
|
172
164
|
setSelectedBrand(brand);
|
|
173
165
|
if (forceUpdate) {
|
|
174
|
-
|
|
175
|
-
`forceUpdate is not currently supported when setting brand`
|
|
176
|
-
);
|
|
166
|
+
log$4.warn(`forceUpdate is not currently supported when setting brand`);
|
|
177
167
|
}
|
|
178
|
-
nozzle
|
|
179
|
-
onBrandSelected
|
|
168
|
+
nozzle?.setSelectedBrand(brand, context);
|
|
169
|
+
onBrandSelected?.(brand);
|
|
180
170
|
},
|
|
181
171
|
[nozzle, onBrandSelected]
|
|
182
172
|
);
|
|
183
173
|
const clearBrand = React.useCallback(() => {
|
|
184
174
|
setSelectedBrand(null);
|
|
185
|
-
nozzle
|
|
186
|
-
onBrandCleared
|
|
175
|
+
nozzle?.setSelectedBrand(void 0);
|
|
176
|
+
onBrandCleared?.();
|
|
187
177
|
}, [nozzle, onBrandCleared]);
|
|
188
178
|
React.useEffect(() => {
|
|
189
179
|
const disposer = kosUiSdk.kosAutoEffect(() => {
|
|
190
|
-
if (!nozzle)
|
|
191
|
-
return;
|
|
180
|
+
if (!nozzle) return;
|
|
192
181
|
setBrands(nozzle.visibleBrands);
|
|
193
182
|
});
|
|
194
183
|
return () => {
|
|
@@ -203,336 +192,232 @@ const useBrands = ({
|
|
|
203
192
|
clearBrand
|
|
204
193
|
};
|
|
205
194
|
};
|
|
206
|
-
class PourContext {
|
|
207
|
-
constructor() {
|
|
208
|
-
__publicField(this, "_data", /* @__PURE__ */ new Map());
|
|
209
|
-
}
|
|
210
|
-
get(key) {
|
|
211
|
-
return this._data.get(key);
|
|
212
|
-
}
|
|
213
|
-
set(key, value) {
|
|
214
|
-
this._data.set(key, value);
|
|
215
|
-
}
|
|
216
|
-
remove(key) {
|
|
217
|
-
this._data.delete(key);
|
|
218
|
-
}
|
|
219
|
-
has(key) {
|
|
220
|
-
return this._data.has(key);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
195
|
const logger$7 = kosUiSdk.KosLog.createLogger({
|
|
224
|
-
|
|
225
|
-
|
|
196
|
+
group: kosUiSdk.LogGroup.ui,
|
|
197
|
+
name: "HoldToPourIntentStrategy"
|
|
198
|
+
});
|
|
199
|
+
const HoldToPourIntentStrategy = {
|
|
200
|
+
name: "HoldToPourIntentStrategy",
|
|
201
|
+
requiresHold: true,
|
|
202
|
+
async initiate(model, intent) {
|
|
203
|
+
if (!model?.canPour) {
|
|
204
|
+
logger$7.debug(`${model?.id} cannot pour. Returning early.`);
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
if (intent) {
|
|
208
|
+
logger$7.debug(`performing intent: ${intent}`);
|
|
209
|
+
await model?.performIntent(intent);
|
|
210
|
+
} else {
|
|
211
|
+
logger$7.debug("no intent provided. Returning early.");
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
async initiateEnded(nozzle) {
|
|
215
|
+
await nozzle?.cancelPour();
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
const logger$6 = kosUiSdk.KosLog.createLogger({
|
|
219
|
+
group: kosUiSdk.LogGroup.ui,
|
|
220
|
+
name: "HoldToPourStrategy"
|
|
226
221
|
});
|
|
227
222
|
const HoldToPourStrategy = {
|
|
228
223
|
name: "HoldToPourStrategy",
|
|
224
|
+
requiresHold: true,
|
|
229
225
|
async initiate(nozzle) {
|
|
230
|
-
if (!
|
|
231
|
-
logger$
|
|
226
|
+
if (!nozzle?.canPour) {
|
|
227
|
+
logger$6.debug(`Nozzle ${nozzle?.id} cannot pour. Returning early.`);
|
|
232
228
|
return;
|
|
233
229
|
}
|
|
234
|
-
await
|
|
230
|
+
await nozzle?.pour();
|
|
235
231
|
},
|
|
236
232
|
async initiateEnded(nozzle) {
|
|
237
|
-
await
|
|
233
|
+
await nozzle?.cancelPour();
|
|
238
234
|
}
|
|
239
235
|
};
|
|
240
|
-
const logger$
|
|
241
|
-
|
|
242
|
-
|
|
236
|
+
const logger$5 = kosUiSdk.KosLog.createLogger({
|
|
237
|
+
group: kosUiSdk.LogGroup.ui,
|
|
238
|
+
name: "TapOrHoldIntentStrategy"
|
|
243
239
|
});
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
240
|
+
class TapOrHoldIntentStrategy {
|
|
241
|
+
intent;
|
|
242
|
+
name = "TapOrHoldIntentStrategy";
|
|
243
|
+
isHold = false;
|
|
244
|
+
disposer = null;
|
|
245
|
+
constructor(intent) {
|
|
246
|
+
this.intent = intent;
|
|
247
|
+
}
|
|
248
|
+
async initiate(model, intent = this.intent) {
|
|
249
|
+
this.isHold = false;
|
|
250
|
+
this.disposer = setTimeout(() => {
|
|
251
|
+
this.isHold = true;
|
|
252
|
+
}, 250);
|
|
253
|
+
if (model?.isPouring && !this.isHold) {
|
|
254
|
+
logger$5.debug(`additional tap detected. cancelling pour`);
|
|
255
|
+
await model.cancelPour();
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
if (!model?.canPour) {
|
|
259
|
+
logger$5.debug(`${model?.id} cannot pour. Returning early.`);
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
if (intent) {
|
|
263
|
+
logger$5.debug(`performing intent: ${intent}`);
|
|
264
|
+
await model?.performIntent(intent);
|
|
264
265
|
} else {
|
|
265
|
-
logger$
|
|
266
|
-
`[${strategy == null ? void 0 : strategy.name}] - Did not pass onBeforePour gate for nozzle ${nozzle == null ? void 0 : nozzle.id}. Cancelling pour.`
|
|
267
|
-
);
|
|
268
|
-
onBeforePourRejected == null ? void 0 : onBeforePourRejected();
|
|
266
|
+
logger$5.debug("no intent provided. Returning early.");
|
|
269
267
|
}
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
}
|
|
308
|
-
return {
|
|
309
|
-
handlers: handlers.dom,
|
|
310
|
-
cancel: forceCancelPour,
|
|
311
|
-
updatePourContext: handleUpdateContext,
|
|
312
|
-
removeFromPourContext: handleRemoveFromContext,
|
|
313
|
-
status: nozzle
|
|
314
|
-
};
|
|
268
|
+
}
|
|
269
|
+
async initiateEnded(nozzle) {
|
|
270
|
+
if (this.disposer) clearTimeout(this.disposer);
|
|
271
|
+
this.disposer = null;
|
|
272
|
+
if (!this.isHold) {
|
|
273
|
+
logger$5.debug("Tap detected. don't cancel and return.");
|
|
274
|
+
return true;
|
|
275
|
+
}
|
|
276
|
+
await nozzle?.cancelPour();
|
|
277
|
+
return false;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
const logger$4 = kosUiSdk.KosLog.createLogger({
|
|
281
|
+
group: kosUiSdk.LogGroup.ui,
|
|
282
|
+
name: "TapToPourIntentStrategy"
|
|
283
|
+
});
|
|
284
|
+
const TapToPourIntentStrategy = {
|
|
285
|
+
name: "TapToPourIntentStrategy",
|
|
286
|
+
async initiate(model, intent) {
|
|
287
|
+
if (model?.isPouring) {
|
|
288
|
+
logger$4.debug(`Nozzle ${model?.id} is already pouring. cancelling pour`);
|
|
289
|
+
await model.cancelPour();
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
if (!model?.canPour) {
|
|
293
|
+
logger$4.debug(`Nozzle ${model?.id} cannot pour. Returning early.`);
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
if (intent) {
|
|
297
|
+
logger$4.debug(`performing intent: ${intent}`);
|
|
298
|
+
await model?.performIntent(intent);
|
|
299
|
+
} else {
|
|
300
|
+
logger$4.debug("no intent provided. Returning early.");
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
async initiateEnded(_nozzle) {
|
|
304
|
+
return true;
|
|
305
|
+
}
|
|
315
306
|
};
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
if (!companionType)
|
|
328
|
-
return [];
|
|
329
|
-
return flavors.map(
|
|
330
|
-
(flavor) => kosUiSdk.getKosCompanionModel(flavor, companionType)
|
|
331
|
-
);
|
|
332
|
-
}, [flavors, companionType]);
|
|
333
|
-
const [selectedFlavors, setSelectedFlavors] = React.useState([]);
|
|
334
|
-
const selectFlavor = React.useCallback(
|
|
335
|
-
async (flavor, context, forceUpdate) => {
|
|
336
|
-
setSelectedFlavors(
|
|
337
|
-
(previous) => (previous == null ? void 0 : previous.includes(flavor)) ? [...previous.filter((p) => p !== flavor)] : [...previous ?? [], flavor]
|
|
338
|
-
);
|
|
339
|
-
if (nozzle == null ? void 0 : nozzle.selectedPourable) {
|
|
340
|
-
const { beverage } = nozzle.selectedPourable;
|
|
341
|
-
await nozzle.setSelectedPourable(
|
|
342
|
-
{
|
|
343
|
-
beverage,
|
|
344
|
-
additional: selectedFlavors ?? [],
|
|
345
|
-
context
|
|
346
|
-
},
|
|
347
|
-
forceUpdate
|
|
348
|
-
);
|
|
349
|
-
}
|
|
350
|
-
onFlavorSelected == null ? void 0 : onFlavorSelected(flavor, selectedFlavors ?? []);
|
|
351
|
-
},
|
|
352
|
-
[nozzle, onFlavorSelected, selectedFlavors]
|
|
353
|
-
);
|
|
354
|
-
const clear = React.useCallback(async () => {
|
|
355
|
-
setSelectedFlavors([]);
|
|
356
|
-
if (nozzle == null ? void 0 : nozzle.selectedPourable) {
|
|
357
|
-
const { beverage } = nozzle.selectedPourable;
|
|
358
|
-
nozzle.setSelectedPourable({ beverage });
|
|
359
|
-
onFlavorCleared == null ? void 0 : onFlavorCleared();
|
|
307
|
+
const logger$3 = kosUiSdk.KosLog.createLogger({
|
|
308
|
+
group: kosUiSdk.LogGroup.ui,
|
|
309
|
+
name: "HoldToPourStrategy"
|
|
310
|
+
});
|
|
311
|
+
const TapToPourStrategy = {
|
|
312
|
+
name: "TapToPourStrategy",
|
|
313
|
+
async initiate(nozzle) {
|
|
314
|
+
if (nozzle?.isPouring) {
|
|
315
|
+
logger$3.debug(`Nozzle ${nozzle?.id} is already pouring. cancelling pour`);
|
|
316
|
+
await nozzle.cancelPour();
|
|
317
|
+
return;
|
|
360
318
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
319
|
+
if (!nozzle?.canPour) {
|
|
320
|
+
logger$3.debug(`Nozzle ${nozzle?.id} cannot pour. Returning early.`);
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
await nozzle?.pour();
|
|
324
|
+
},
|
|
325
|
+
async initiateEnded(_nozzle) {
|
|
326
|
+
return true;
|
|
327
|
+
}
|
|
369
328
|
};
|
|
370
329
|
const DISPENSE_GROUP_BRAND = "brands";
|
|
371
330
|
const DISPENSE_GROUP_BEVERAGE = "beverages";
|
|
372
331
|
const DISPENSE_GROUP_FLAVOR = "flavors";
|
|
373
|
-
const log$
|
|
332
|
+
const log$3 = kosUiSdk.KosLog.createLogger({ group: kosUiSdk.LogGroup.ui, name: "use-cui-kit" });
|
|
374
333
|
const useCuiKit = ({
|
|
375
|
-
initialGroup
|
|
334
|
+
initialGroup,
|
|
335
|
+
steps,
|
|
376
336
|
options = {}
|
|
377
337
|
}) => {
|
|
378
|
-
var _a, _b, _c;
|
|
379
|
-
const [currentGroup, setCurrentGroup] = React.useState(initialGroup);
|
|
380
338
|
const { model: nozzle } = useNozzleContext();
|
|
381
339
|
const timersRef = React.useRef([]);
|
|
382
|
-
const
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
(
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
const topic = `/kos/dispense/${nozzle == null ? void 0 : nozzle.path}/flavor/cleared/`;
|
|
428
|
-
kosUiSdk.EventBus.publish(topic, {});
|
|
429
|
-
}, [nozzle == null ? void 0 : nozzle.path]);
|
|
430
|
-
const onPour = React.useCallback(() => {
|
|
431
|
-
const topic = `/kos/dispense/${nozzle == null ? void 0 : nozzle.path}/pour/`;
|
|
432
|
-
kosUiSdk.EventBus.publish(topic, {});
|
|
433
|
-
}, [nozzle == null ? void 0 : nozzle.path]);
|
|
434
|
-
const handleBeforePour = React.useCallback(
|
|
435
|
-
async (context) => {
|
|
436
|
-
const topic = `/kos/dispense/${nozzle == null ? void 0 : nozzle.path}/pre/pour/`;
|
|
437
|
-
kosUiSdk.EventBus.publish(topic, {});
|
|
438
|
-
return await (onBeforePour == null ? void 0 : onBeforePour(context)) || true;
|
|
340
|
+
const kit = React.useMemo(() => {
|
|
341
|
+
if (!nozzle) return void 0;
|
|
342
|
+
try {
|
|
343
|
+
return dispenseRegistrationManager.CuiKitState.instance(dispenseRegistrationManager.cuiKitId(nozzle.path)).options({
|
|
344
|
+
nozzlePath: nozzle.path,
|
|
345
|
+
initialGroup: steps ? initialGroup : initialGroup ?? DISPENSE_GROUP_BRAND,
|
|
346
|
+
steps,
|
|
347
|
+
companionTypes: options.companionTypes,
|
|
348
|
+
pour: { strategy: options.pour?.strategy ?? HoldToPourStrategy },
|
|
349
|
+
onPourComplete: options.onPourComplete
|
|
350
|
+
}).build();
|
|
351
|
+
} catch (error) {
|
|
352
|
+
throw new Error(
|
|
353
|
+
`The CUI Kit models are not registered: call KosModelRegistry.cuiKit.models() in the app's registration chain (${error.message})`
|
|
354
|
+
);
|
|
355
|
+
}
|
|
356
|
+
}, [nozzle]);
|
|
357
|
+
const [ready, setReady] = React.useState(false);
|
|
358
|
+
const [, setVersion] = React.useState(0);
|
|
359
|
+
React.useEffect(() => {
|
|
360
|
+
if (!kit) return void 0;
|
|
361
|
+
let dispose;
|
|
362
|
+
let cancelled = false;
|
|
363
|
+
let attached = false;
|
|
364
|
+
kosUiSdk.whenReady(kit).then(() => {
|
|
365
|
+
if (cancelled) return;
|
|
366
|
+
attached = true;
|
|
367
|
+
if (kit.attach()) {
|
|
368
|
+
kit.reset();
|
|
369
|
+
}
|
|
370
|
+
setReady(true);
|
|
371
|
+
dispose = kosUiSdk.kosAutoEffect(() => {
|
|
372
|
+
readKitState(kit);
|
|
373
|
+
setVersion((version) => version + 1);
|
|
374
|
+
});
|
|
375
|
+
});
|
|
376
|
+
return () => {
|
|
377
|
+
cancelled = true;
|
|
378
|
+
dispose?.();
|
|
379
|
+
if (attached) kit.detach();
|
|
380
|
+
};
|
|
381
|
+
}, [kit]);
|
|
382
|
+
const updateOnBeforePour = React.useCallback(
|
|
383
|
+
(callback) => {
|
|
384
|
+
kit?.setBeforePour(callback);
|
|
439
385
|
},
|
|
440
|
-
[
|
|
386
|
+
[kit]
|
|
441
387
|
);
|
|
442
|
-
const
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
}, [nozzle == null ? void 0 : nozzle.path]);
|
|
446
|
-
const onPourCancel = React.useCallback(() => {
|
|
447
|
-
const topic = `/kos/dispense/${nozzle == null ? void 0 : nozzle.path}/pour/cancel/`;
|
|
448
|
-
kosUiSdk.EventBus.publish(topic, {});
|
|
449
|
-
}, [nozzle == null ? void 0 : nozzle.path]);
|
|
450
|
-
const { brands, selectBrand, selectedBrand, clearBrand, brandCompanions } = useBrands({
|
|
451
|
-
companionType: (_a = options.companionTypes) == null ? void 0 : _a.brand,
|
|
452
|
-
onBrandSelected,
|
|
453
|
-
onBrandCleared
|
|
454
|
-
});
|
|
455
|
-
const {
|
|
456
|
-
beverages,
|
|
457
|
-
selectBeverage,
|
|
458
|
-
selectedBeverage,
|
|
459
|
-
clearBeverage,
|
|
460
|
-
beverageCompanions
|
|
461
|
-
} = useBeverages({
|
|
462
|
-
companionType: (_b = options.companionTypes) == null ? void 0 : _b.beverage,
|
|
463
|
-
onBeverageSelected,
|
|
464
|
-
onClearBeverage: onBeverageCleared,
|
|
465
|
-
onBeverageListUpdated
|
|
388
|
+
const gesture = kosUiSdk.usePressGesture({
|
|
389
|
+
onPressed: () => void kit?.pressPour(),
|
|
390
|
+
onRelease: () => kit?.releasePour()
|
|
466
391
|
});
|
|
467
|
-
const {
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
});
|
|
478
|
-
const [onBeforePour, setOnBeforePour] = React.useState();
|
|
479
|
-
const updateOnBeforePour = React.useCallback((callback) => {
|
|
480
|
-
setOnBeforePour(() => callback);
|
|
481
|
-
}, []);
|
|
482
|
-
const pour = useNozzlePour({
|
|
483
|
-
onPour,
|
|
484
|
-
onPourCancel,
|
|
485
|
-
onBeforePour: handleBeforePour,
|
|
486
|
-
onBeforePourRejected: handleBeforePourRejected
|
|
487
|
-
});
|
|
488
|
-
updatePourContext.current = pour.updatePourContext;
|
|
489
|
-
removeFromPourContext.current = pour.removeFromPourContext;
|
|
490
|
-
const back = React.useCallback(() => {
|
|
491
|
-
log$2.debug(`Navigating back from group: ${currentGroup}`);
|
|
492
|
-
switch (currentGroup) {
|
|
493
|
-
case DISPENSE_GROUP_BRAND:
|
|
494
|
-
clearBeverage();
|
|
495
|
-
clearBrand();
|
|
496
|
-
break;
|
|
497
|
-
case DISPENSE_GROUP_BEVERAGE:
|
|
498
|
-
case DISPENSE_GROUP_FLAVOR:
|
|
499
|
-
setCurrentGroup(initialGroup);
|
|
500
|
-
clearBeverage();
|
|
501
|
-
clearBrand();
|
|
502
|
-
break;
|
|
503
|
-
}
|
|
504
|
-
}, [clearBeverage, clearBrand, currentGroup, initialGroup]);
|
|
505
|
-
const home = React.useCallback(() => {
|
|
506
|
-
const topic = `/kos/dispense/${nozzle == null ? void 0 : nozzle.path}/home/`;
|
|
507
|
-
kosUiSdk.EventBus.publish(topic, {});
|
|
508
|
-
setCurrentGroup(initialGroup);
|
|
509
|
-
if (initialGroup === DISPENSE_GROUP_BRAND) {
|
|
510
|
-
clearBeverage();
|
|
511
|
-
clearBrand();
|
|
512
|
-
}
|
|
513
|
-
if (initialGroup === DISPENSE_GROUP_BEVERAGE) {
|
|
514
|
-
clearBeverage();
|
|
515
|
-
}
|
|
516
|
-
}, [clearBeverage, clearBrand, initialGroup]);
|
|
392
|
+
const pour = {
|
|
393
|
+
handlers: gesture.dom,
|
|
394
|
+
cancel: () => void kit?.cancelPour(),
|
|
395
|
+
start: async (pourOptions) => await kit?.startPour(pourOptions) ?? false,
|
|
396
|
+
press: async (pourOptions) => await kit?.pressPour(pourOptions) ?? false,
|
|
397
|
+
release: (pourOptions) => kit?.releasePour(pourOptions),
|
|
398
|
+
updatePourContext: (key, value) => kit?.pourContext.set(key, value),
|
|
399
|
+
removeFromPourContext: (key) => kit?.pourContext.remove(key),
|
|
400
|
+
status: nozzle
|
|
401
|
+
};
|
|
517
402
|
const pauseTimers = React.useCallback(() => {
|
|
518
403
|
if (timersRef.current.length === 0) {
|
|
519
|
-
log$
|
|
404
|
+
log$3.debug("No timers to pause.");
|
|
520
405
|
return;
|
|
521
406
|
}
|
|
522
|
-
log$
|
|
407
|
+
log$3.debug(`Pausing ${timersRef.current.length} timers.`);
|
|
523
408
|
timersRef.current.forEach((timer) => {
|
|
524
|
-
log$
|
|
409
|
+
log$3.debug(`Pausing timer with id ${timer.id}.`);
|
|
525
410
|
timer.pause();
|
|
526
411
|
});
|
|
527
412
|
}, []);
|
|
528
413
|
const restartTimers = React.useCallback(() => {
|
|
529
414
|
if (timersRef.current.length === 0) {
|
|
530
|
-
log$
|
|
415
|
+
log$3.debug("No timers to restart.");
|
|
531
416
|
return;
|
|
532
417
|
}
|
|
533
|
-
log$
|
|
418
|
+
log$3.debug(`Restarting ${timersRef.current.length} timers.`);
|
|
534
419
|
timersRef.current.forEach((timer) => {
|
|
535
|
-
log$
|
|
420
|
+
log$3.debug(`Restarting timer with id ${timer.id}.`);
|
|
536
421
|
timer.restart();
|
|
537
422
|
});
|
|
538
423
|
}, []);
|
|
@@ -541,11 +426,12 @@ const useCuiKit = ({
|
|
|
541
426
|
return;
|
|
542
427
|
}
|
|
543
428
|
if (timersRef.current.some((t) => t.id === timer.id)) {
|
|
544
|
-
log$
|
|
429
|
+
log$3.debug(`Timer with id ${timer.id} already exists.`);
|
|
545
430
|
return;
|
|
546
431
|
}
|
|
547
432
|
timersRef.current.push(timer);
|
|
548
433
|
}, []);
|
|
434
|
+
const active = ready ? kit : void 0;
|
|
549
435
|
return {
|
|
550
436
|
timers: {
|
|
551
437
|
add: addTimer,
|
|
@@ -553,43 +439,70 @@ const useCuiKit = ({
|
|
|
553
439
|
restart: restartTimers
|
|
554
440
|
},
|
|
555
441
|
nav: {
|
|
556
|
-
currentGroup,
|
|
557
|
-
back,
|
|
558
|
-
home
|
|
442
|
+
currentGroup: active?.currentGroup ?? (steps ? steps.brands ? DISPENSE_GROUP_BRAND : DISPENSE_GROUP_BEVERAGE : initialGroup ?? DISPENSE_GROUP_BRAND),
|
|
443
|
+
back: () => active?.back(),
|
|
444
|
+
home: () => active?.home(),
|
|
445
|
+
steps: active?.enabledSteps,
|
|
446
|
+
canBack: active?.canBack ?? false,
|
|
447
|
+
toPour: (pourOptions) => active?.toPour(pourOptions)
|
|
559
448
|
},
|
|
560
449
|
pour,
|
|
561
450
|
updateOnBeforePour,
|
|
562
451
|
selections: {
|
|
563
|
-
[DISPENSE_GROUP_BRAND]: selectedBrand,
|
|
564
|
-
[DISPENSE_GROUP_BEVERAGE]: selectedBeverage,
|
|
565
|
-
[DISPENSE_GROUP_FLAVOR]: selectedFlavors
|
|
452
|
+
[DISPENSE_GROUP_BRAND]: active?.selectedBrand ?? null,
|
|
453
|
+
[DISPENSE_GROUP_BEVERAGE]: active?.selectedBeverage ?? null,
|
|
454
|
+
[DISPENSE_GROUP_FLAVOR]: active?.selectedFlavors ?? []
|
|
566
455
|
},
|
|
567
456
|
[DISPENSE_GROUP_BRAND]: {
|
|
568
|
-
models: brands,
|
|
569
|
-
companions: brandCompanions,
|
|
570
|
-
clear: clearBrand,
|
|
457
|
+
models: active?.brands ?? [],
|
|
458
|
+
companions: active?.brandCompanions ?? [],
|
|
459
|
+
clear: () => active?.clearBrand(),
|
|
571
460
|
handlers: {
|
|
572
|
-
onSelected:
|
|
461
|
+
onSelected: async (model, context, forceUpdate) => {
|
|
462
|
+
if (forceUpdate) {
|
|
463
|
+
log$3.warn(
|
|
464
|
+
`forceUpdate is not currently supported when setting brand`
|
|
465
|
+
);
|
|
466
|
+
}
|
|
467
|
+
active?.selectBrand(model, context);
|
|
468
|
+
}
|
|
573
469
|
}
|
|
574
470
|
},
|
|
575
471
|
[DISPENSE_GROUP_BEVERAGE]: {
|
|
576
|
-
models: beverages,
|
|
577
|
-
companions: beverageCompanions,
|
|
578
|
-
clear: clearBeverage,
|
|
472
|
+
models: active?.beverages ?? [],
|
|
473
|
+
companions: active?.beverageCompanions ?? [],
|
|
474
|
+
clear: () => void active?.clearBeverage(),
|
|
579
475
|
handlers: {
|
|
580
|
-
onSelected: selectBeverage
|
|
476
|
+
onSelected: async (model, context, forceUpdate) => active?.selectBeverage(model, context, forceUpdate)
|
|
581
477
|
}
|
|
582
478
|
},
|
|
583
479
|
[DISPENSE_GROUP_FLAVOR]: {
|
|
584
|
-
models: flavors,
|
|
585
|
-
companions: flavorCompanions,
|
|
586
|
-
clear: clearFlavors,
|
|
480
|
+
models: active?.flavors ?? [],
|
|
481
|
+
companions: active?.flavorCompanions ?? [],
|
|
482
|
+
clear: () => void active?.clearFlavors(),
|
|
587
483
|
handlers: {
|
|
588
|
-
onSelected: selectFlavor
|
|
484
|
+
onSelected: async (model, context, forceUpdate) => active?.selectFlavor(model, context, forceUpdate)
|
|
589
485
|
}
|
|
590
486
|
}
|
|
591
487
|
};
|
|
592
488
|
};
|
|
489
|
+
const readKitState = (kit) => [
|
|
490
|
+
kit.currentGroup,
|
|
491
|
+
kit.canBack,
|
|
492
|
+
kit.selectedBrand,
|
|
493
|
+
kit.selectedBeverage,
|
|
494
|
+
...kit.selectedFlavors,
|
|
495
|
+
...kit.brands,
|
|
496
|
+
...kit.beverages,
|
|
497
|
+
...kit.flavors,
|
|
498
|
+
...kit.brandCompanions,
|
|
499
|
+
...kit.beverageCompanions,
|
|
500
|
+
...kit.flavorCompanions
|
|
501
|
+
];
|
|
502
|
+
const log$2 = kosUiSdk.KosLog.createLogger({
|
|
503
|
+
group: kosUiSdk.LogGroup.ui,
|
|
504
|
+
name: "use-ambient-attract-timers"
|
|
505
|
+
});
|
|
593
506
|
const useAmbientAttractTimers = (props) => {
|
|
594
507
|
const { model: nozzle } = useNozzleContext();
|
|
595
508
|
const [attractTimer, setAttractTimer] = React.useState(null);
|
|
@@ -603,66 +516,66 @@ const useAmbientAttractTimers = (props) => {
|
|
|
603
516
|
} = props;
|
|
604
517
|
const handleAmbientTimer = React.useCallback(() => {
|
|
605
518
|
if (onAmbientTimer) {
|
|
606
|
-
|
|
607
|
-
onAmbientTimer
|
|
519
|
+
log$2.info("Ambient timer expired. Calling callback");
|
|
520
|
+
onAmbientTimer?.();
|
|
608
521
|
}
|
|
609
522
|
}, [onAmbientTimer]);
|
|
610
523
|
const handleAttractTimer = React.useCallback(() => {
|
|
611
524
|
if (onAttractTimer) {
|
|
612
|
-
|
|
613
|
-
onAttractTimer
|
|
525
|
+
log$2.info("Attract timer expired. Calling callback");
|
|
526
|
+
onAttractTimer?.();
|
|
614
527
|
}
|
|
615
528
|
}, [onAttractTimer]);
|
|
616
529
|
const handleResetAttractTimer = React.useCallback(() => {
|
|
617
530
|
if (attractTimer) {
|
|
618
531
|
attractTimer.restart();
|
|
619
|
-
onResetAttractTimer
|
|
532
|
+
onResetAttractTimer?.();
|
|
620
533
|
}
|
|
621
534
|
}, [attractTimer, onResetAttractTimer]);
|
|
622
535
|
const handlePauseAttractTimer = React.useCallback(() => {
|
|
623
536
|
if (attractTimer) {
|
|
624
537
|
attractTimer.reset();
|
|
625
|
-
onResetAttractTimer
|
|
538
|
+
onResetAttractTimer?.();
|
|
626
539
|
}
|
|
627
540
|
}, [attractTimer, onResetAttractTimer]);
|
|
628
541
|
const handleResume = React.useCallback(() => {
|
|
629
542
|
if (attractTimer) {
|
|
630
543
|
attractTimer.pause();
|
|
631
|
-
onResumeAttractTimer
|
|
544
|
+
onResumeAttractTimer?.();
|
|
632
545
|
}
|
|
633
546
|
}, [attractTimer, onResumeAttractTimer]);
|
|
634
547
|
React.useEffect(() => {
|
|
635
548
|
if (nozzle && defaultAttractTime) {
|
|
636
|
-
|
|
549
|
+
log$2.info("Nozzle is available. Creating timers");
|
|
637
550
|
const timer = kosUiSdk.TimerManager.createTimer(
|
|
638
551
|
"attract-timer-" + nozzle.path,
|
|
639
552
|
defaultAttractTime
|
|
640
553
|
);
|
|
641
554
|
if (defaultAttractTime) {
|
|
642
|
-
timer
|
|
555
|
+
timer?.addTimeoutAction({
|
|
643
556
|
name: "attract-timer",
|
|
644
557
|
remainingTime: 0,
|
|
645
558
|
action: handleAttractTimer
|
|
646
559
|
});
|
|
647
560
|
}
|
|
648
561
|
if (defaultAmbientTime) {
|
|
649
|
-
timer
|
|
562
|
+
timer?.addTimeoutAction({
|
|
650
563
|
name: "ambient-timer",
|
|
651
564
|
remainingTime: defaultAmbientTime,
|
|
652
565
|
action: handleAmbientTimer
|
|
653
566
|
});
|
|
654
567
|
}
|
|
655
568
|
if (defaultAttractTime) {
|
|
656
|
-
timer
|
|
569
|
+
timer?.start();
|
|
657
570
|
}
|
|
658
571
|
setAttractTimer(timer ?? null);
|
|
659
572
|
return () => {
|
|
660
|
-
timer
|
|
573
|
+
timer?.reset();
|
|
661
574
|
setAttractTimer(null);
|
|
662
575
|
};
|
|
663
576
|
}
|
|
664
577
|
return () => {
|
|
665
|
-
|
|
578
|
+
log$2.info("Nozzle is not available. No timers to clear");
|
|
666
579
|
};
|
|
667
580
|
}, [
|
|
668
581
|
defaultAmbientTime,
|
|
@@ -743,7 +656,7 @@ const useDispenseLifecycle = ({
|
|
|
743
656
|
}) => {
|
|
744
657
|
const { model: nozzle } = useNozzleContext();
|
|
745
658
|
React.useEffect(() => {
|
|
746
|
-
const topics = buildDispenseTopics(nozzle
|
|
659
|
+
const topics = buildDispenseTopics(nozzle?.path, {
|
|
747
660
|
onBrandSelected,
|
|
748
661
|
onBrandCleared,
|
|
749
662
|
onBeverageListUpdated,
|
|
@@ -766,10 +679,10 @@ const useDispenseLifecycle = ({
|
|
|
766
679
|
({ topic, callback }) => subscribe(topic, callback)
|
|
767
680
|
);
|
|
768
681
|
return () => {
|
|
769
|
-
disposers.forEach((disposer) => disposer
|
|
682
|
+
disposers.forEach((disposer) => disposer?.());
|
|
770
683
|
};
|
|
771
684
|
}, [
|
|
772
|
-
nozzle
|
|
685
|
+
nozzle?.path,
|
|
773
686
|
onAmbientTimer,
|
|
774
687
|
onAttractTimer,
|
|
775
688
|
onBeverageCleared,
|
|
@@ -789,7 +702,10 @@ const useDispenseLifecycle = ({
|
|
|
789
702
|
onReturnToHome
|
|
790
703
|
]);
|
|
791
704
|
};
|
|
792
|
-
const log$1 = kosUiSdk.KosLog.createLogger({
|
|
705
|
+
const log$1 = kosUiSdk.KosLog.createLogger({
|
|
706
|
+
group: kosUiSdk.LogGroup.ui,
|
|
707
|
+
name: "useCuiKitTimers"
|
|
708
|
+
});
|
|
793
709
|
const useCuiKitTimers = (props) => {
|
|
794
710
|
const { model: nozzle } = useNozzleContext();
|
|
795
711
|
const [idleTimer, setIdleTimer] = React.useState(null);
|
|
@@ -803,9 +719,9 @@ const useCuiKitTimers = (props) => {
|
|
|
803
719
|
const hasAreYouThereFiredRef = React.useRef(false);
|
|
804
720
|
const handleAreYouThereTimer = React.useCallback(() => {
|
|
805
721
|
if (!hasAreYouThereFiredRef.current && onAreYouThereTimer) {
|
|
806
|
-
|
|
722
|
+
log$1.info("Are you there timer expired. Calling callback");
|
|
807
723
|
hasAreYouThereFiredRef.current = true;
|
|
808
|
-
onAreYouThereTimer
|
|
724
|
+
onAreYouThereTimer?.();
|
|
809
725
|
}
|
|
810
726
|
}, [onAreYouThereTimer]);
|
|
811
727
|
const handleIdleTimer = React.useCallback(() => {
|
|
@@ -815,7 +731,7 @@ const useCuiKitTimers = (props) => {
|
|
|
815
731
|
);
|
|
816
732
|
if (onIdleTimer) {
|
|
817
733
|
log$1.debug("Idle timer expired. Calling callback");
|
|
818
|
-
onIdleTimer
|
|
734
|
+
onIdleTimer?.();
|
|
819
735
|
} else {
|
|
820
736
|
log$1.debug("No onIdleTimer callback provided!");
|
|
821
737
|
}
|
|
@@ -825,7 +741,7 @@ const useCuiKitTimers = (props) => {
|
|
|
825
741
|
if (idleTimer) {
|
|
826
742
|
idleTimer.restart();
|
|
827
743
|
hasAreYouThereFiredRef.current = false;
|
|
828
|
-
onResetIdleTimer
|
|
744
|
+
onResetIdleTimer?.();
|
|
829
745
|
}
|
|
830
746
|
}, [idleTimer, onResetIdleTimer, props.prefix]);
|
|
831
747
|
const handlePauseIdleTimer = React.useCallback(() => {
|
|
@@ -833,12 +749,12 @@ const useCuiKitTimers = (props) => {
|
|
|
833
749
|
if (idleTimer) {
|
|
834
750
|
idleTimer.reset();
|
|
835
751
|
hasAreYouThereFiredRef.current = false;
|
|
836
|
-
onResetIdleTimer
|
|
752
|
+
onResetIdleTimer?.();
|
|
837
753
|
}
|
|
838
754
|
}, [idleTimer, onResetIdleTimer, props.prefix]);
|
|
839
755
|
React.useEffect(() => {
|
|
840
756
|
log$1.debug(
|
|
841
|
-
`useCuiKitTimers effect triggered - nozzle: ${!!nozzle}, path: ${nozzle
|
|
757
|
+
`useCuiKitTimers effect triggered - nozzle: ${!!nozzle}, path: ${nozzle?.path}, callbacks: handleIdle=${!!handleIdleTimer}, handleAreYouThere=${!!handleAreYouThereTimer}`
|
|
842
758
|
);
|
|
843
759
|
if (nozzle) {
|
|
844
760
|
log$1.info("Nozzle is available. Creating timers");
|
|
@@ -850,19 +766,19 @@ const useCuiKitTimers = (props) => {
|
|
|
850
766
|
`Adding idle timer action for ${props.prefix ?? ""}idle-timer-${nozzle.path} with callback:`,
|
|
851
767
|
!!handleIdleTimer
|
|
852
768
|
);
|
|
853
|
-
timer
|
|
769
|
+
timer?.addTimeoutAction({
|
|
854
770
|
name: "idle-timer",
|
|
855
771
|
remainingTime: 0,
|
|
856
772
|
action: handleIdleTimer
|
|
857
773
|
});
|
|
858
|
-
timer
|
|
774
|
+
timer?.addTimeoutAction({
|
|
859
775
|
name: "are-you-there-timer",
|
|
860
776
|
remainingTime: defaultAreYouThereTime,
|
|
861
777
|
action: handleAreYouThereTimer
|
|
862
778
|
});
|
|
863
779
|
setIdleTimer(timer ?? null);
|
|
864
780
|
return () => {
|
|
865
|
-
timer
|
|
781
|
+
timer?.reset();
|
|
866
782
|
setIdleTimer(null);
|
|
867
783
|
};
|
|
868
784
|
}
|
|
@@ -883,7 +799,10 @@ const useCuiKitTimers = (props) => {
|
|
|
883
799
|
pause: handlePauseIdleTimer
|
|
884
800
|
};
|
|
885
801
|
};
|
|
886
|
-
const log = kosUiSdk.KosLog.createLogger({
|
|
802
|
+
const log = kosUiSdk.KosLog.createLogger({
|
|
803
|
+
group: kosUiSdk.LogGroup.ui,
|
|
804
|
+
name: "useDefaultCuiKitLifecycle"
|
|
805
|
+
});
|
|
887
806
|
const useDefaultCuiKitLifecycle = ({
|
|
888
807
|
kit,
|
|
889
808
|
inactivity,
|
|
@@ -892,26 +811,25 @@ const useDefaultCuiKitLifecycle = ({
|
|
|
892
811
|
onBeforeAreYouThereTimer,
|
|
893
812
|
areYouThereRejectionPolicy = "pause"
|
|
894
813
|
}) => {
|
|
895
|
-
var _a, _b, _c, _d;
|
|
896
814
|
const [showAmbientScreen, setShowAmbientScreen] = React.useState(false);
|
|
897
815
|
const [showAttractScreen, setShowAttractScreen] = React.useState(false);
|
|
898
816
|
const { model: nozzle } = useNozzleContext();
|
|
899
817
|
const [hasPoured, setHasPoured] = React.useState(false);
|
|
900
|
-
const idleTimeout =
|
|
901
|
-
const areYouThereTimeout =
|
|
902
|
-
const idlePourTimeout =
|
|
903
|
-
const areYouTherePourTimeout =
|
|
904
|
-
const ambientTimeout = screens
|
|
905
|
-
const attractTimeout = screens
|
|
818
|
+
const idleTimeout = inactivity?.idleTimeout ?? 15;
|
|
819
|
+
const areYouThereTimeout = inactivity?.areYouThereTimeoutOffset ?? 10;
|
|
820
|
+
const idlePourTimeout = pour?.idleTimeout ?? inactivity?.idleTimeout ?? 10;
|
|
821
|
+
const areYouTherePourTimeout = pour?.areYouThereTimeoutOffset ?? inactivity?.areYouThereTimeoutOffset ?? 5;
|
|
822
|
+
const ambientTimeout = screens?.ambientTimeoutOffset;
|
|
823
|
+
const attractTimeout = screens?.attractTimeout;
|
|
906
824
|
const handleIdleTimeout = React.useCallback(() => {
|
|
907
825
|
log.info("handleIdleTimeout called - navigating home and publishing event");
|
|
908
826
|
setShowAreYouThere(false);
|
|
909
|
-
kit
|
|
827
|
+
kit?.nav.home();
|
|
910
828
|
if (nozzle) {
|
|
911
829
|
const topic = `/kos/dispense/${nozzle.path}/idle/timeout/`;
|
|
912
830
|
kosUiSdk.EventBus.publish(topic, {});
|
|
913
831
|
}
|
|
914
|
-
}, [
|
|
832
|
+
}, [kit?.nav?.home, nozzle]);
|
|
915
833
|
const handleResetIdleTimer = React.useCallback(() => {
|
|
916
834
|
log.info("handleResetIdleTimer called - resetting idle timer");
|
|
917
835
|
setShowAreYouThere(false);
|
|
@@ -940,13 +858,13 @@ const useDefaultCuiKitLifecycle = ({
|
|
|
940
858
|
if (attractTimeout) {
|
|
941
859
|
setShowAttractScreen(false);
|
|
942
860
|
setShowAmbientScreen(false);
|
|
943
|
-
kit
|
|
861
|
+
kit?.nav.home();
|
|
944
862
|
if (nozzle) {
|
|
945
863
|
const topic = `/kos/dispense/${nozzle.path}/attract/resume/`;
|
|
946
864
|
kosUiSdk.EventBus.publish(topic, {});
|
|
947
865
|
}
|
|
948
866
|
}
|
|
949
|
-
}, [kit
|
|
867
|
+
}, [kit?.nav, attractTimeout, nozzle]);
|
|
950
868
|
const {
|
|
951
869
|
pause: ambientPause,
|
|
952
870
|
restart: ambientRestart,
|
|
@@ -958,7 +876,7 @@ const useDefaultCuiKitLifecycle = ({
|
|
|
958
876
|
onAttractTimer: handleAttractTimer,
|
|
959
877
|
onResumeAttractTimer: handleAttractResume
|
|
960
878
|
});
|
|
961
|
-
|
|
879
|
+
kit?.timers?.add(attractTimer);
|
|
962
880
|
const [showAreYouThere, setShowAreYouThere] = React.useState(false);
|
|
963
881
|
log.info(
|
|
964
882
|
"Creating idle timer with timeout:",
|
|
@@ -1054,8 +972,8 @@ const useDefaultCuiKitLifecycle = ({
|
|
|
1054
972
|
});
|
|
1055
973
|
}
|
|
1056
974
|
}, [pourIdleTimer, areYouTherePourTimeout, handleAreYouThereTimer]);
|
|
1057
|
-
|
|
1058
|
-
|
|
975
|
+
kit?.timers?.add(idleTimer);
|
|
976
|
+
kit?.timers?.add(pourIdleTimer);
|
|
1059
977
|
const handlePour = React.useCallback(() => {
|
|
1060
978
|
setHasPoured(false);
|
|
1061
979
|
pausePourTimer();
|
|
@@ -1118,15 +1036,13 @@ const useDefaultCuiKitLifecycle = ({
|
|
|
1118
1036
|
onPourCancel: handlePourCancel,
|
|
1119
1037
|
onBeforePourRejected: handleBeforePourRejected,
|
|
1120
1038
|
onInit: handleInit
|
|
1121
|
-
//
|
|
1122
|
-
//
|
|
1123
|
-
// component's own timer hooks call those handlers directly. Including them would
|
|
1124
|
-
// create circular event loops.
|
|
1039
|
+
// The timer handlers are left out because this hook's own timers call them directly;
|
|
1040
|
+
// subscribing to their events as well would create an event loop.
|
|
1125
1041
|
});
|
|
1126
1042
|
const areYouThereCountdown = hasPoured ? areYouTherePourTimeout : areYouThereTimeout;
|
|
1127
1043
|
React.useEffect(() => {
|
|
1128
1044
|
if (nozzle && attractTimer) {
|
|
1129
|
-
const topic = `/kos/dispense/${nozzle
|
|
1045
|
+
const topic = `/kos/dispense/${nozzle?.path}/init/`;
|
|
1130
1046
|
kosUiSdk.EventBus.publish(topic, {});
|
|
1131
1047
|
}
|
|
1132
1048
|
}, [nozzle, attractTimer]);
|
|
@@ -1142,6 +1058,59 @@ const useDefaultCuiKitLifecycle = ({
|
|
|
1142
1058
|
restartScreenTimer: ambientRestart
|
|
1143
1059
|
};
|
|
1144
1060
|
};
|
|
1061
|
+
const useFlavors = ({
|
|
1062
|
+
onFlavorSelected,
|
|
1063
|
+
onFlavorCleared,
|
|
1064
|
+
companionType
|
|
1065
|
+
}) => {
|
|
1066
|
+
const { model: nozzle } = useNozzleContext();
|
|
1067
|
+
const flavors = React.useMemo(
|
|
1068
|
+
() => nozzle?.getGroupAvailabilityItems("flavors").filter((f) => f.visible) ?? [],
|
|
1069
|
+
[nozzle]
|
|
1070
|
+
);
|
|
1071
|
+
const companions = React.useMemo(() => {
|
|
1072
|
+
if (!companionType) return [];
|
|
1073
|
+
return flavors.map(
|
|
1074
|
+
(flavor) => kosUiSdk.getKosCompanionModel(flavor, companionType)
|
|
1075
|
+
);
|
|
1076
|
+
}, [flavors, companionType]);
|
|
1077
|
+
const [selectedFlavors, setSelectedFlavors] = React.useState([]);
|
|
1078
|
+
const selectFlavor = React.useCallback(
|
|
1079
|
+
async (flavor, context, forceUpdate) => {
|
|
1080
|
+
setSelectedFlavors(
|
|
1081
|
+
(previous) => previous?.includes(flavor) ? [...previous.filter((p) => p !== flavor)] : [...previous ?? [], flavor]
|
|
1082
|
+
);
|
|
1083
|
+
if (nozzle?.selectedPourable) {
|
|
1084
|
+
const { beverage } = nozzle.selectedPourable;
|
|
1085
|
+
await nozzle.setSelectedPourable(
|
|
1086
|
+
{
|
|
1087
|
+
beverage,
|
|
1088
|
+
additional: selectedFlavors ?? [],
|
|
1089
|
+
context
|
|
1090
|
+
},
|
|
1091
|
+
forceUpdate
|
|
1092
|
+
);
|
|
1093
|
+
}
|
|
1094
|
+
onFlavorSelected?.(flavor, selectedFlavors ?? []);
|
|
1095
|
+
},
|
|
1096
|
+
[nozzle, onFlavorSelected, selectedFlavors]
|
|
1097
|
+
);
|
|
1098
|
+
const clear = React.useCallback(async () => {
|
|
1099
|
+
setSelectedFlavors([]);
|
|
1100
|
+
if (nozzle?.selectedPourable) {
|
|
1101
|
+
const { beverage } = nozzle.selectedPourable;
|
|
1102
|
+
nozzle.setSelectedPourable({ beverage });
|
|
1103
|
+
onFlavorCleared?.();
|
|
1104
|
+
}
|
|
1105
|
+
}, [nozzle, onFlavorCleared]);
|
|
1106
|
+
return {
|
|
1107
|
+
flavors,
|
|
1108
|
+
flavorCompanions: companions,
|
|
1109
|
+
selectFlavor,
|
|
1110
|
+
selectedFlavors,
|
|
1111
|
+
clearFlavors: clear
|
|
1112
|
+
};
|
|
1113
|
+
};
|
|
1145
1114
|
const useDeviceAssembly = () => {
|
|
1146
1115
|
const modelId = dispenseRegistrationManager.DeviceAssembly.type;
|
|
1147
1116
|
const result = kosUiSdk.useKosModel({
|
|
@@ -1196,31 +1165,9 @@ const useIngredient = () => {
|
|
|
1196
1165
|
});
|
|
1197
1166
|
return result;
|
|
1198
1167
|
};
|
|
1199
|
-
const logger$
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
});
|
|
1203
|
-
const HoldToPourIntentStrategy = {
|
|
1204
|
-
name: "HoldToPourIntentStrategy",
|
|
1205
|
-
async initiate(model, intent) {
|
|
1206
|
-
if (!(model == null ? void 0 : model.canPour)) {
|
|
1207
|
-
logger$5.debug(`${model == null ? void 0 : model.id} cannot pour. Returning early.`);
|
|
1208
|
-
return;
|
|
1209
|
-
}
|
|
1210
|
-
if (intent) {
|
|
1211
|
-
logger$5.debug(`performing intent: ${intent}`);
|
|
1212
|
-
await (model == null ? void 0 : model.performIntent(intent));
|
|
1213
|
-
} else {
|
|
1214
|
-
logger$5.debug("no intent provided. Returning early.");
|
|
1215
|
-
}
|
|
1216
|
-
},
|
|
1217
|
-
async initiateEnded(nozzle) {
|
|
1218
|
-
await (nozzle == null ? void 0 : nozzle.cancelPour());
|
|
1219
|
-
}
|
|
1220
|
-
};
|
|
1221
|
-
const logger$4 = kosUiSdk.KosLog.createLogger({
|
|
1222
|
-
name: "useNozzlePour",
|
|
1223
|
-
group: "kos-hooks"
|
|
1168
|
+
const logger$2 = kosUiSdk.KosLog.createLogger({
|
|
1169
|
+
group: kosUiSdk.LogGroup.ui,
|
|
1170
|
+
name: "useNozzlePour"
|
|
1224
1171
|
});
|
|
1225
1172
|
const useIngredientPour = ({
|
|
1226
1173
|
onPour,
|
|
@@ -1229,24 +1176,23 @@ const useIngredientPour = ({
|
|
|
1229
1176
|
strategy = HoldToPourIntentStrategy
|
|
1230
1177
|
}) => {
|
|
1231
1178
|
const handlePour = React.useCallback(() => {
|
|
1232
|
-
logger$
|
|
1233
|
-
`[${strategy
|
|
1179
|
+
logger$2.debug(
|
|
1180
|
+
`[${strategy?.name}] - Pour initiated for model ${intentContainer?.id}.`
|
|
1234
1181
|
);
|
|
1235
|
-
strategy
|
|
1236
|
-
onPour
|
|
1182
|
+
strategy?.initiate(intentContainer);
|
|
1183
|
+
onPour?.();
|
|
1237
1184
|
}, [onPour, intentContainer, strategy]);
|
|
1238
1185
|
const handleCancelPour = React.useCallback(() => {
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
`[${strategy == null ? void 0 : strategy.name}] - Pour initiate ended called for nozzle ${intentContainer == null ? void 0 : intentContainer.id}.`
|
|
1186
|
+
logger$2.debug(
|
|
1187
|
+
`[${strategy?.name}] - Pour initiate ended called for nozzle ${intentContainer?.id}.`
|
|
1242
1188
|
);
|
|
1243
|
-
|
|
1244
|
-
onPourCancel
|
|
1189
|
+
strategy?.initiateEnded?.(intentContainer);
|
|
1190
|
+
onPourCancel?.();
|
|
1245
1191
|
}, [onPourCancel, intentContainer, strategy]);
|
|
1246
1192
|
const forceCancelPour = React.useCallback(() => {
|
|
1247
|
-
logger$
|
|
1248
|
-
intentContainer
|
|
1249
|
-
onPourCancel
|
|
1193
|
+
logger$2.debug(`Force cancelling pour for nozzle ${intentContainer?.id}.`);
|
|
1194
|
+
intentContainer?.cancelPour();
|
|
1195
|
+
onPourCancel?.();
|
|
1250
1196
|
}, [onPourCancel, intentContainer]);
|
|
1251
1197
|
const handlers = kosUiSdk.usePressGesture({
|
|
1252
1198
|
onPressed: handlePour,
|
|
@@ -1285,10 +1231,82 @@ function withNozzle(path, WrappedComponent) {
|
|
|
1285
1231
|
return /* @__PURE__ */ jsxRuntime.jsx(KosModelLoader, { ...status, children: /* @__PURE__ */ jsxRuntime.jsx(WrappedComponent, { ...props, nozzle: model }) });
|
|
1286
1232
|
};
|
|
1287
1233
|
}
|
|
1288
|
-
const logger$
|
|
1289
|
-
|
|
1290
|
-
|
|
1234
|
+
const logger$1 = kosUiSdk.KosLog.createLogger({
|
|
1235
|
+
group: kosUiSdk.LogGroup.ui,
|
|
1236
|
+
name: "useNozzlePour"
|
|
1291
1237
|
});
|
|
1238
|
+
const useNozzlePour = ({
|
|
1239
|
+
onPour,
|
|
1240
|
+
onPourCancel,
|
|
1241
|
+
onBeforePour,
|
|
1242
|
+
onBeforePourRejected,
|
|
1243
|
+
pourContext,
|
|
1244
|
+
strategy = HoldToPourStrategy
|
|
1245
|
+
}) => {
|
|
1246
|
+
const { model: nozzle } = useNozzleContext();
|
|
1247
|
+
const [context, _setContext] = React.useState(
|
|
1248
|
+
pourContext || new dispenseRegistrationManager.PourContext()
|
|
1249
|
+
);
|
|
1250
|
+
const handlePour = React.useCallback(async () => {
|
|
1251
|
+
const canPour = onBeforePour ? await onBeforePour?.(context) : true;
|
|
1252
|
+
if (canPour) {
|
|
1253
|
+
logger$1.debug(
|
|
1254
|
+
`[${strategy?.name}] - Pour initiated for nozzle ${nozzle?.id}.`
|
|
1255
|
+
);
|
|
1256
|
+
strategy?.initiate(nozzle);
|
|
1257
|
+
onPour?.();
|
|
1258
|
+
} else {
|
|
1259
|
+
logger$1.debug(
|
|
1260
|
+
`[${strategy?.name}] - Did not pass onBeforePour gate for nozzle ${nozzle?.id}. Cancelling pour.`
|
|
1261
|
+
);
|
|
1262
|
+
onBeforePourRejected?.();
|
|
1263
|
+
}
|
|
1264
|
+
}, [
|
|
1265
|
+
onPour,
|
|
1266
|
+
nozzle,
|
|
1267
|
+
strategy,
|
|
1268
|
+
onBeforePour,
|
|
1269
|
+
onPourCancel,
|
|
1270
|
+
context,
|
|
1271
|
+
onBeforePourRejected
|
|
1272
|
+
]);
|
|
1273
|
+
const handleCancelPour = React.useCallback(() => {
|
|
1274
|
+
logger$1.debug(
|
|
1275
|
+
`[${strategy?.name}] - Pour initiate ended called for nozzle ${nozzle?.id}.`
|
|
1276
|
+
);
|
|
1277
|
+
strategy?.initiateEnded?.(nozzle);
|
|
1278
|
+
onPourCancel?.();
|
|
1279
|
+
}, [onPourCancel, nozzle, strategy]);
|
|
1280
|
+
const forceCancelPour = React.useCallback(() => {
|
|
1281
|
+
logger$1.debug(`Force cancelling pour for nozzle ${nozzle?.id}.`);
|
|
1282
|
+
nozzle?.cancelPour();
|
|
1283
|
+
onPourCancel?.();
|
|
1284
|
+
}, [onPourCancel, nozzle]);
|
|
1285
|
+
const handleUpdateContext = React.useCallback(
|
|
1286
|
+
(key, value) => {
|
|
1287
|
+
context.set(key, value);
|
|
1288
|
+
},
|
|
1289
|
+
[context]
|
|
1290
|
+
);
|
|
1291
|
+
const handleRemoveFromContext = React.useCallback(
|
|
1292
|
+
(key) => {
|
|
1293
|
+
context.remove(key);
|
|
1294
|
+
},
|
|
1295
|
+
[context]
|
|
1296
|
+
);
|
|
1297
|
+
const handlers = kosUiSdk.usePressGesture({
|
|
1298
|
+
onPressed: handlePour,
|
|
1299
|
+
onRelease: handleCancelPour
|
|
1300
|
+
});
|
|
1301
|
+
return {
|
|
1302
|
+
handlers: handlers.dom,
|
|
1303
|
+
cancel: forceCancelPour,
|
|
1304
|
+
updatePourContext: handleUpdateContext,
|
|
1305
|
+
removeFromPourContext: handleRemoveFromContext,
|
|
1306
|
+
status: nozzle
|
|
1307
|
+
};
|
|
1308
|
+
};
|
|
1309
|
+
const logger = kosUiSdk.KosLog.createLogger({ group: kosUiSdk.LogGroup.ui, name: "usePour" });
|
|
1292
1310
|
const usePourTarget = ({
|
|
1293
1311
|
onBeforePour,
|
|
1294
1312
|
onPour,
|
|
@@ -1299,43 +1317,42 @@ const usePourTarget = ({
|
|
|
1299
1317
|
strategy = HoldToPourStrategy
|
|
1300
1318
|
}) => {
|
|
1301
1319
|
const [context, _setContext] = React.useState(
|
|
1302
|
-
pourContext || new PourContext()
|
|
1320
|
+
pourContext || new dispenseRegistrationManager.PourContext()
|
|
1303
1321
|
);
|
|
1304
1322
|
const handlePour = React.useCallback(async () => {
|
|
1305
|
-
logger
|
|
1306
|
-
`[${strategy
|
|
1323
|
+
logger.debug(
|
|
1324
|
+
`[${strategy?.name}] - calling before pour for pour target ${pourTarget?.id}.`
|
|
1307
1325
|
);
|
|
1308
|
-
const canPour = onBeforePour ? await
|
|
1326
|
+
const canPour = onBeforePour ? await onBeforePour?.(context) : true;
|
|
1309
1327
|
if (canPour) {
|
|
1310
|
-
logger
|
|
1311
|
-
`[${strategy
|
|
1328
|
+
logger.debug(
|
|
1329
|
+
`[${strategy?.name}] - Pour initiated for pour target ${pourTarget?.id}.`
|
|
1312
1330
|
);
|
|
1313
|
-
await
|
|
1314
|
-
onPour
|
|
1315
|
-
if (!
|
|
1316
|
-
onPourAbort
|
|
1331
|
+
await strategy?.initiate(pourTarget);
|
|
1332
|
+
onPour?.();
|
|
1333
|
+
if (!pourTarget?.isPouring) {
|
|
1334
|
+
onPourAbort?.();
|
|
1317
1335
|
}
|
|
1318
1336
|
} else {
|
|
1319
|
-
logger
|
|
1320
|
-
`[${strategy
|
|
1337
|
+
logger.debug(
|
|
1338
|
+
`[${strategy?.name}] - Pour cancelled for pour target ${pourTarget?.id}.`
|
|
1321
1339
|
);
|
|
1322
|
-
onPourCancel
|
|
1340
|
+
onPourCancel?.();
|
|
1323
1341
|
}
|
|
1324
1342
|
}, [onPour, onBeforePour, onPourAbort, pourTarget, strategy, context]);
|
|
1325
1343
|
const handleCancelPour = React.useCallback(async () => {
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
`[${strategy == null ? void 0 : strategy.name}] - Pour initiate ended called for pour target ${pourTarget == null ? void 0 : pourTarget.id}.`
|
|
1344
|
+
logger.debug(
|
|
1345
|
+
`[${strategy?.name}] - Pour initiate ended called for pour target ${pourTarget?.id}.`
|
|
1329
1346
|
);
|
|
1330
|
-
const ignore = await
|
|
1347
|
+
const ignore = await strategy?.initiateEnded?.(pourTarget);
|
|
1331
1348
|
if (!ignore) {
|
|
1332
|
-
onPourCancel
|
|
1349
|
+
onPourCancel?.();
|
|
1333
1350
|
}
|
|
1334
1351
|
}, [onPourCancel, pourTarget, strategy]);
|
|
1335
1352
|
const forceCancelPour = React.useCallback(async () => {
|
|
1336
|
-
logger
|
|
1337
|
-
await
|
|
1338
|
-
onPourCancel
|
|
1353
|
+
logger.debug(`Force cancelling pour for pour target ${pourTarget?.id}.`);
|
|
1354
|
+
await pourTarget?.cancelPour();
|
|
1355
|
+
onPourCancel?.();
|
|
1339
1356
|
}, [onPourCancel, pourTarget]);
|
|
1340
1357
|
const handleUpdateContext = React.useCallback(
|
|
1341
1358
|
(key, value) => {
|
|
@@ -1361,99 +1378,6 @@ const usePourTarget = ({
|
|
|
1361
1378
|
status: pourTarget
|
|
1362
1379
|
};
|
|
1363
1380
|
};
|
|
1364
|
-
const logger$2 = kosUiSdk.KosLog.createLogger({
|
|
1365
|
-
name: "TapOrHoldIntentStrategy",
|
|
1366
|
-
group: "kos-hooks"
|
|
1367
|
-
});
|
|
1368
|
-
class TapOrHoldIntentStrategy {
|
|
1369
|
-
constructor(intent) {
|
|
1370
|
-
__publicField(this, "intent");
|
|
1371
|
-
__publicField(this, "name", "TapOrHoldIntentStrategy");
|
|
1372
|
-
__publicField(this, "isHold", false);
|
|
1373
|
-
__publicField(this, "disposer", null);
|
|
1374
|
-
this.intent = intent;
|
|
1375
|
-
}
|
|
1376
|
-
async initiate(model, intent) {
|
|
1377
|
-
this.disposer = setTimeout(() => {
|
|
1378
|
-
this.isHold = true;
|
|
1379
|
-
}, 250);
|
|
1380
|
-
if ((model == null ? void 0 : model.isPouring) && !this.isHold) {
|
|
1381
|
-
logger$2.debug(`additional tap detected. cancelling pour`);
|
|
1382
|
-
await model.cancelPour();
|
|
1383
|
-
return;
|
|
1384
|
-
}
|
|
1385
|
-
if (!(model == null ? void 0 : model.canPour)) {
|
|
1386
|
-
logger$2.debug(`${model == null ? void 0 : model.id} cannot pour. Returning early.`);
|
|
1387
|
-
return;
|
|
1388
|
-
}
|
|
1389
|
-
if (intent) {
|
|
1390
|
-
logger$2.debug(`performing intent: ${intent}`);
|
|
1391
|
-
await (model == null ? void 0 : model.performIntent(intent));
|
|
1392
|
-
} else {
|
|
1393
|
-
logger$2.debug("no intent provided. Returning early.");
|
|
1394
|
-
}
|
|
1395
|
-
}
|
|
1396
|
-
async initiateEnded(nozzle) {
|
|
1397
|
-
if (this.disposer)
|
|
1398
|
-
clearTimeout(this.disposer);
|
|
1399
|
-
this.disposer = null;
|
|
1400
|
-
if (!this.isHold) {
|
|
1401
|
-
logger$2.debug("Tap detected. don't cancel and return.");
|
|
1402
|
-
return true;
|
|
1403
|
-
}
|
|
1404
|
-
await (nozzle == null ? void 0 : nozzle.cancelPour());
|
|
1405
|
-
return false;
|
|
1406
|
-
}
|
|
1407
|
-
}
|
|
1408
|
-
const logger$1 = kosUiSdk.KosLog.createLogger({
|
|
1409
|
-
name: "TapToPourIntentStrategy",
|
|
1410
|
-
group: "kos-hooks"
|
|
1411
|
-
});
|
|
1412
|
-
const TapToPourIntentStrategy = {
|
|
1413
|
-
name: "TapToPourIntentStrategy",
|
|
1414
|
-
async initiate(model, intent) {
|
|
1415
|
-
if (model == null ? void 0 : model.isPouring) {
|
|
1416
|
-
logger$1.debug(`Nozzle ${model == null ? void 0 : model.id} is already pouring. cancelling pour`);
|
|
1417
|
-
await model.cancelPour();
|
|
1418
|
-
return;
|
|
1419
|
-
}
|
|
1420
|
-
if (!(model == null ? void 0 : model.canPour)) {
|
|
1421
|
-
logger$1.debug(`Nozzle ${model == null ? void 0 : model.id} cannot pour. Returning early.`);
|
|
1422
|
-
return;
|
|
1423
|
-
}
|
|
1424
|
-
if (intent) {
|
|
1425
|
-
logger$1.debug(`performing intent: ${intent}`);
|
|
1426
|
-
await (model == null ? void 0 : model.performIntent(intent));
|
|
1427
|
-
} else {
|
|
1428
|
-
logger$1.debug("no intent provided. Returning early.");
|
|
1429
|
-
}
|
|
1430
|
-
},
|
|
1431
|
-
async initiateEnded(_nozzle) {
|
|
1432
|
-
return true;
|
|
1433
|
-
}
|
|
1434
|
-
};
|
|
1435
|
-
const logger = kosUiSdk.KosLog.createLogger({
|
|
1436
|
-
name: "HoldToPourStrategy",
|
|
1437
|
-
group: "kos-hooks"
|
|
1438
|
-
});
|
|
1439
|
-
const TapToPourStrategy = {
|
|
1440
|
-
name: "TapToPourStrategy",
|
|
1441
|
-
async initiate(nozzle) {
|
|
1442
|
-
if (nozzle == null ? void 0 : nozzle.isPouring) {
|
|
1443
|
-
logger.debug(`Nozzle ${nozzle == null ? void 0 : nozzle.id} is already pouring. cancelling pour`);
|
|
1444
|
-
await nozzle.cancelPour();
|
|
1445
|
-
return;
|
|
1446
|
-
}
|
|
1447
|
-
if (!(nozzle == null ? void 0 : nozzle.canPour)) {
|
|
1448
|
-
logger.debug(`Nozzle ${nozzle == null ? void 0 : nozzle.id} cannot pour. Returning early.`);
|
|
1449
|
-
return;
|
|
1450
|
-
}
|
|
1451
|
-
await (nozzle == null ? void 0 : nozzle.pour());
|
|
1452
|
-
},
|
|
1453
|
-
async initiateEnded(_nozzle) {
|
|
1454
|
-
return true;
|
|
1455
|
-
}
|
|
1456
|
-
};
|
|
1457
1381
|
const useGenericPour = (id, servicePathFactory, itemId, data) => {
|
|
1458
1382
|
const modelId = id;
|
|
1459
1383
|
const result = kosUiSdk.useKosModel({
|
|
@@ -1591,7 +1515,19 @@ function createDispenseKitContext() {
|
|
|
1591
1515
|
}
|
|
1592
1516
|
return ctx;
|
|
1593
1517
|
};
|
|
1594
|
-
|
|
1518
|
+
const useCuiPour = (options = {}) => {
|
|
1519
|
+
const kit = React.useContext(CuiKitContext);
|
|
1520
|
+
const gesture = kosUiSdk.usePressGesture({
|
|
1521
|
+
onPressed: () => void kit?.pour.press(options),
|
|
1522
|
+
onRelease: () => kit?.pour.release(options)
|
|
1523
|
+
});
|
|
1524
|
+
return {
|
|
1525
|
+
handlers: gesture.dom,
|
|
1526
|
+
start: async () => await kit?.pour.start(options) ?? false,
|
|
1527
|
+
cancel: () => kit?.pour.cancel()
|
|
1528
|
+
};
|
|
1529
|
+
};
|
|
1530
|
+
return [useCuiKitContext, CuiKitContext.Provider, useCuiPour];
|
|
1595
1531
|
}
|
|
1596
1532
|
function CuiKitWrapper({
|
|
1597
1533
|
children,
|
|
@@ -1608,8 +1544,8 @@ function DispenseView({
|
|
|
1608
1544
|
props
|
|
1609
1545
|
}) {
|
|
1610
1546
|
const { nozzlePaths } = useDeviceAssemblyContext();
|
|
1611
|
-
const totalNozzles =
|
|
1612
|
-
const nozzles =
|
|
1547
|
+
const totalNozzles = nozzlePaths?.length || 0;
|
|
1548
|
+
const nozzles = nozzlePaths?.map((path, index) => /* @__PURE__ */ jsxRuntime.jsx(NozzleProvider, { path, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1613
1549
|
CuiKitWrapper,
|
|
1614
1550
|
{
|
|
1615
1551
|
provider,
|
|
@@ -1623,7 +1559,7 @@ function DispenseView({
|
|
|
1623
1559
|
},
|
|
1624
1560
|
children
|
|
1625
1561
|
}
|
|
1626
|
-
) }, path))
|
|
1562
|
+
) }, path)) || [];
|
|
1627
1563
|
return nozzles;
|
|
1628
1564
|
}
|
|
1629
1565
|
function CuiKit({
|
|
@@ -1640,10 +1576,11 @@ function CuiKit({
|
|
|
1640
1576
|
) }) : null;
|
|
1641
1577
|
}
|
|
1642
1578
|
function initializeCuiKit(props) {
|
|
1643
|
-
const [useCuiKitContext, DispenseKitProvider] = createDispenseKitContext();
|
|
1579
|
+
const [useCuiKitContext, DispenseKitProvider, useCuiPour] = createDispenseKitContext();
|
|
1644
1580
|
return [
|
|
1645
1581
|
useCuiKitContext,
|
|
1646
|
-
CuiKit({ provider: DispenseKitProvider, props })
|
|
1582
|
+
CuiKit({ provider: DispenseKitProvider, props }),
|
|
1583
|
+
useCuiPour
|
|
1647
1584
|
];
|
|
1648
1585
|
}
|
|
1649
1586
|
const Holder = React.createContext(void 0);
|
|
@@ -1772,7 +1709,6 @@ exports.HolderProvider = HolderProvider;
|
|
|
1772
1709
|
exports.IngredientContainerProvider = IngredientContainerProvider;
|
|
1773
1710
|
exports.IngredientProvider = IngredientProvider;
|
|
1774
1711
|
exports.NozzleProvider = NozzleProvider;
|
|
1775
|
-
exports.PourContext = PourContext;
|
|
1776
1712
|
exports.PumpProvider = PumpProvider;
|
|
1777
1713
|
exports.TapOrHoldIntentStrategy = TapOrHoldIntentStrategy;
|
|
1778
1714
|
exports.TapToPourIntentStrategy = TapToPourIntentStrategy;
|
|
@@ -1821,4 +1757,4 @@ exports.withHolderContainer = withHolderContainer;
|
|
|
1821
1757
|
exports.withIngredient = withIngredient;
|
|
1822
1758
|
exports.withIngredientContainer = withIngredientContainer;
|
|
1823
1759
|
exports.withNozzle = withNozzle;
|
|
1824
|
-
//# sourceMappingURL=pump-provider-
|
|
1760
|
+
//# sourceMappingURL=pump-provider-B4WR3LiY.cjs.map
|