@pisell/private-materials 6.12.168 → 6.12.169
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +10 -10
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +10 -10
- package/es/components/HDLKiosk/{contracts → app/contracts}/config.js +1 -1
- package/es/components/HDLKiosk/app/manifest.js +11 -11
- package/es/components/HDLKiosk/app/operations.js +92 -0
- package/es/components/HDLKiosk/app/workflow/barcode.js +7 -3
- package/es/components/HDLKiosk/app/workflow/index.js +16 -0
- package/es/components/HDLKiosk/app/workflow/predicates.js +1 -1
- package/es/components/HDLKiosk/app/workflow/quick.js +1 -1
- package/es/components/HDLKiosk/app/workflow/registry.js +4 -4
- package/es/components/HDLKiosk/app/workflow/scale.js +5 -1
- package/es/components/HDLKiosk/docs/00-/346/226/207/344/273/266/345/257/274/350/210/252.md +104 -167
- package/es/components/HDLKiosk/docs/01-/346/240/270/345/277/203/350/277/220/350/241/214/346/234/272/345/210/266.md +95 -89
- package/es/components/HDLKiosk/docs/04-/350/256/276/345/244/207/344/270/216/347/247/260/351/207/215.md +43 -26
- package/es/components/HDLKiosk/docs/05-/344/272/244/346/230/223/345/256/211/345/205/250.md +2 -0
- package/es/components/HDLKiosk/docs/08-/346/227/240/345/244/264Application/350/277/220/350/241/214/346/227/266/351/207/215/346/236/204/350/256/276/350/256/241.md +719 -0
- package/es/components/HDLKiosk/docs/09-Entry/350/256/276/345/244/207/344/272/213/344/273/266/351/207/215/346/236/204/344/277/256/345/244/215/346/212/245/345/221/212.md +187 -0
- package/es/components/HDLKiosk/docs/README.md +6 -2
- package/es/components/HDLKiosk/docs//345/256/236/346/226/275/350/277/233/345/272/246.md +8 -7
- package/es/components/HDLKiosk/docs//346/236/266/346/236/204/350/256/276/350/256/241.md +16 -18
- package/es/components/HDLKiosk/index.js +22 -28
- package/es/components/HDLKiosk/index.less +1 -1
- package/es/components/HDLKiosk/kernel/README.md +13 -12
- package/es/components/HDLKiosk/kernel/application/defineApplication.js +63 -24
- package/es/components/HDLKiosk/kernel/application/defineSlice.js +6 -6
- package/es/components/HDLKiosk/kernel/application/runtime.js +237 -0
- package/es/components/HDLKiosk/kernel/operations/coordinator.js +1 -1
- package/es/components/HDLKiosk/kernel/operations/registry.js +3 -3
- package/es/components/HDLKiosk/kernel/operations/sessionEpoch.js +1 -1
- package/es/components/HDLKiosk/kernel/operations/types.js +7 -3
- package/es/components/HDLKiosk/kernel/workflow/actor.js +16 -17
- package/es/components/HDLKiosk/kernel/workflow/compiler.js +14 -16
- package/es/components/HDLKiosk/runtime/createRuntime.js +238 -0
- package/es/components/HDLKiosk/{devices → runtime/devices}/dedupeStore.js +1 -1
- package/es/components/HDLKiosk/{devices → runtime/devices}/scaleIngress.js +1 -1
- package/es/components/HDLKiosk/{devices/scale/runtime.js → runtime/devices/scaleStore.js} +18 -24
- package/es/components/HDLKiosk/{devices → runtime/devices}/scannerIngress.js +1 -1
- package/es/components/HDLKiosk/runtime/devices/scannerSessionPort.js +60 -0
- package/es/components/HDLKiosk/runtime/devices/scannerSessionRouter.js +212 -0
- package/es/components/HDLKiosk/runtime/operations/barcode.js +18 -0
- package/es/components/HDLKiosk/runtime/operations/cart.js +44 -0
- package/es/components/HDLKiosk/{app → runtime}/operations/cartConsistency.js +1 -1
- package/es/components/HDLKiosk/{app → runtime}/operations/checkout.js +95 -110
- package/es/components/HDLKiosk/{app → runtime}/operations/checkoutRequirements.js +1 -1
- package/es/components/HDLKiosk/{app → runtime}/operations/checkoutSafety.js +1 -1
- package/es/components/HDLKiosk/{app → runtime}/operations/coordinator.js +2 -2
- package/es/components/HDLKiosk/runtime/operations/customization.js +70 -0
- package/es/components/HDLKiosk/{app → runtime}/operations/errors.js +1 -1
- package/es/components/HDLKiosk/runtime/operations/fulfillment.js +6 -0
- package/es/components/HDLKiosk/runtime/operations/identity.js +55 -0
- package/es/components/HDLKiosk/runtime/operations/registry.js +34 -0
- package/es/components/HDLKiosk/runtime/operations/session.js +29 -0
- package/es/components/HDLKiosk/runtime/operations/types.js +13 -0
- package/es/components/HDLKiosk/runtime/session/blockPolicy.js +14 -0
- package/es/components/HDLKiosk/runtime/{createWorkflowSession.js → session/createSession.js} +67 -17
- package/es/components/HDLKiosk/runtime/{domainTransitionRunner.js → session/transitionRunner.js} +10 -5
- package/es/components/HDLKiosk/runtime/{workflowContext.js → session/workflowContext.js} +2 -2
- package/es/components/HDLKiosk/runtime/{workflowLifecycle.js → session/workflowLifecycle.js} +2 -2
- package/es/components/HDLKiosk/runtime/triggers.js +28 -0
- package/es/components/HDLKiosk/slices/catalog/Screen/index.js +15 -8
- package/es/components/HDLKiosk/slices/catalog/Screen/index.less +74 -13
- package/es/components/HDLKiosk/slices/catalog/slice.js +2 -2
- package/es/components/HDLKiosk/slices/customization/Screen/index.js +34 -35
- package/es/components/HDLKiosk/slices/customization/Screen/index.less +5 -0
- package/es/components/HDLKiosk/slices/customization/slice.js +2 -3
- package/es/components/HDLKiosk/slices/fulfillment/slice.js +2 -2
- package/es/components/HDLKiosk/slices/fulfillment/view.js +1 -1
- package/es/components/HDLKiosk/slices/identity/slice.js +2 -2
- package/es/components/HDLKiosk/slices/identity/view.js +1 -1
- package/es/components/HDLKiosk/slices/payment/slice.js +3 -3
- package/es/components/HDLKiosk/slices/primaryProductPrompt/slice.js +1 -1
- package/es/components/HDLKiosk/{runtime → ui}/HDLKioskWorkflowView.js +43 -129
- package/es/components/HDLKiosk/ui/ScaleSimulatorConsole/index.js +387 -0
- package/es/components/HDLKiosk/ui/ScaleSimulatorConsole/index.less +621 -0
- package/es/components/HDLKiosk/{app → ui}/ScreenRenderer.js +1 -1
- package/es/components/HDLKiosk/ui/controllers/useHDLKioskActionDispatcher.js +66 -0
- package/es/components/HDLKiosk/{runtime → ui}/controllers/useHDLKioskCustomerController.js +1 -1
- package/es/components/HDLKiosk/ui/controllers/useHDLKioskDeviceController.js +25 -0
- package/es/components/HDLKiosk/ui/controllers/useHDLKioskExitController.js +53 -0
- package/es/components/HDLKiosk/{runtime → ui}/controllers/useHDLKioskScreenData.js +1 -1
- package/es/components/HDLKiosk/ui/controllers/useHDLKioskSessionController.js +39 -0
- package/es/components/HDLKiosk/{app → ui}/entry/Screen/index.js +8 -6
- package/es/components/HDLKiosk/{app → ui}/entry/model.js +2 -2
- package/es/components/HDLKiosk/ui/scale.js +20 -0
- package/es/components/HDLKiosk/{runtime/useHostSnapshot.js → ui/snapshots.js} +6 -8
- package/es/components/HDLKiosk/{app → ui}/views.js +1 -1
- package/es/components/HDLKiosk/{runtime → ui}/workflowEvent.js +1 -1
- package/es/components/HDLKiosk/utils.js +4 -4
- package/es/components/bigSale/components/BookingFloatingPanel/useBookingPanelController.js +1 -0
- package/es/components/bigSale/components/TimeBar/index.js +1 -0
- package/es/components/bigSale/dialog.js +1 -0
- package/es/components/bigSale/hooks/useBigSaleContext.js +1 -0
- package/es/components/bigSale/hooks/useSelectFloorMapResourceForBigSale.js +1 -0
- package/es/components/bigSale/index.js +1 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/HDLKioskPaymentRuntime.js +2 -1
- package/es/components/bigSale/templates/HDLKiosk/adapter/capabilities.js +1 -1
- package/es/components/bigSale/templates/HDLKiosk/adapter/projection.js +21 -11
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales.js +21 -3
- package/es/components/bigSale/templates/HDLKiosk/adapter/scaleTrigger.js +20 -5
- package/es/components/bigSale/templates/HDLKiosk/adapter/useBigSaleHDLKioskHost.js +3 -0
- package/es/components/bigSale/templates/HDLKiosk/index.js +3 -3
- package/es/components/bigSale/templates/Kiosk/index.js +1 -0
- package/es/components/sharedSecondaryBigSale/SharedSecondaryBigSaleReceiver.js +1 -0
- package/es/index.js +2 -0
- package/es/plus/pisellReservation/data/bookingToReservationTables.js +1 -1
- package/es/plus/pisellReservation/floorMap/floorPlanApi.js +1 -1
- package/es/plus/pisellReservation/floorMap/reservationMock.js +1 -1
- package/es/plus/pisellReservation/index.js +17 -0
- package/es/plus/saleDetail/Base.js +1 -0
- package/es/plus/saleDetail/components/Client/hooks/useClientSelectorProps.js +1 -0
- package/es/plus/saleDetail/components/DetailActions/index.js +1 -0
- package/es/plus/saleDetail/components/SummaryFinancialSections/index.js +1 -0
- package/es/plus/saleDetail/index.js +1 -0
- package/es/plus/saleDetail/tmpl/B/components/Dish/index.js +1 -0
- package/es/plus/saleDetail/tmpl/B/index.js +1 -0
- package/es/plus/salesSdk/index.js +52 -0
- package/es/plus/salesSdk/utils/addProductWithFlowDebounced.js +1 -1
- package/es/plus/salesSdk/utils/bookingDate.js +1 -1
- package/es/plus/salesSdk/utils/customerAuthGate.js +1 -1
- package/es/plus/salesSdk/utils/enrichCartLineHolderDisplay.js +1 -1
- package/es/pro/Login2.0/AuthModal.d.ts +1 -1
- package/es/pro/Login2.0/index.d.ts +2 -1
- package/es/pro/Login2.0/shared/types.d.ts +1 -1
- package/lib/components/HDLKiosk/{contracts → app/contracts}/config.js +1 -1
- package/lib/components/HDLKiosk/app/manifest.js +18 -19
- package/lib/components/HDLKiosk/app/operations.js +105 -0
- package/lib/components/HDLKiosk/app/workflow/barcode.js +7 -3
- package/lib/components/HDLKiosk/app/workflow/index.js +16 -0
- package/lib/components/HDLKiosk/app/workflow/predicates.js +1 -0
- package/lib/components/HDLKiosk/app/workflow/quick.js +1 -1
- package/lib/components/HDLKiosk/app/workflow/registry.js +3 -3
- package/lib/components/HDLKiosk/app/workflow/scale.js +5 -1
- package/lib/components/HDLKiosk/docs/00-/346/226/207/344/273/266/345/257/274/350/210/252.md +104 -167
- package/lib/components/HDLKiosk/docs/01-/346/240/270/345/277/203/350/277/220/350/241/214/346/234/272/345/210/266.md +95 -89
- package/lib/components/HDLKiosk/docs/04-/350/256/276/345/244/207/344/270/216/347/247/260/351/207/215.md +43 -26
- package/lib/components/HDLKiosk/docs/05-/344/272/244/346/230/223/345/256/211/345/205/250.md +2 -0
- package/lib/components/HDLKiosk/docs/08-/346/227/240/345/244/264Application/350/277/220/350/241/214/346/227/266/351/207/215/346/236/204/350/256/276/350/256/241.md +719 -0
- package/lib/components/HDLKiosk/docs/09-Entry/350/256/276/345/244/207/344/272/213/344/273/266/351/207/215/346/236/204/344/277/256/345/244/215/346/212/245/345/221/212.md +187 -0
- package/lib/components/HDLKiosk/docs/README.md +6 -2
- package/lib/components/HDLKiosk/docs//345/256/236/346/226/275/350/277/233/345/272/246.md +8 -7
- package/lib/components/HDLKiosk/docs//346/236/266/346/236/204/350/256/276/350/256/241.md +16 -18
- package/lib/components/HDLKiosk/index.js +25 -31
- package/lib/components/HDLKiosk/index.less +1 -1
- package/lib/components/HDLKiosk/kernel/README.md +13 -12
- package/lib/components/HDLKiosk/kernel/application/defineApplication.js +65 -25
- package/lib/components/HDLKiosk/kernel/application/defineSlice.js +6 -6
- package/lib/components/HDLKiosk/kernel/application/runtime.js +237 -0
- package/lib/components/HDLKiosk/kernel/operations/coordinator.js +1 -1
- package/lib/components/HDLKiosk/kernel/operations/registry.js +3 -3
- package/lib/components/HDLKiosk/kernel/operations/sessionEpoch.js +1 -1
- package/lib/components/HDLKiosk/kernel/operations/types.js +8 -3
- package/lib/components/HDLKiosk/kernel/workflow/actor.js +16 -17
- package/lib/components/HDLKiosk/kernel/workflow/compiler.js +14 -16
- package/lib/components/HDLKiosk/runtime/createRuntime.js +239 -0
- package/lib/components/HDLKiosk/{devices → runtime/devices}/dedupeStore.js +1 -1
- package/lib/components/HDLKiosk/{devices → runtime/devices}/scaleIngress.js +1 -1
- package/lib/components/HDLKiosk/{devices/scale/runtime.js → runtime/devices/scaleStore.js} +17 -27
- package/lib/components/HDLKiosk/{devices → runtime/devices}/scannerIngress.js +1 -1
- package/lib/components/HDLKiosk/runtime/devices/scannerSessionPort.js +60 -0
- package/lib/components/HDLKiosk/runtime/devices/scannerSessionRouter.js +212 -0
- package/lib/components/HDLKiosk/runtime/operations/barcode.js +17 -0
- package/lib/components/HDLKiosk/runtime/operations/cart.js +46 -0
- package/lib/components/HDLKiosk/{app → runtime}/operations/cartConsistency.js +1 -1
- package/lib/components/HDLKiosk/{app → runtime}/operations/checkout.js +97 -112
- package/lib/components/HDLKiosk/{app → runtime}/operations/checkoutRequirements.js +1 -1
- package/lib/components/HDLKiosk/{app → runtime}/operations/checkoutSafety.js +1 -1
- package/lib/components/HDLKiosk/{app → runtime}/operations/coordinator.js +2 -2
- package/lib/components/HDLKiosk/runtime/operations/customization.js +73 -0
- package/lib/components/HDLKiosk/{app → runtime}/operations/errors.js +1 -1
- package/lib/components/HDLKiosk/runtime/operations/fulfillment.js +5 -0
- package/lib/components/HDLKiosk/runtime/operations/identity.js +55 -0
- package/lib/components/HDLKiosk/runtime/operations/registry.js +34 -0
- package/lib/components/HDLKiosk/runtime/operations/session.js +30 -0
- package/lib/components/HDLKiosk/runtime/operations/types.js +14 -0
- package/lib/components/HDLKiosk/runtime/session/blockPolicy.js +14 -0
- package/lib/components/HDLKiosk/runtime/{createWorkflowSession.js → session/createSession.js} +71 -21
- package/lib/components/HDLKiosk/runtime/{domainTransitionRunner.js → session/transitionRunner.js} +10 -5
- package/lib/components/HDLKiosk/runtime/{workflowContext.js → session/workflowContext.js} +2 -2
- package/lib/components/HDLKiosk/runtime/{workflowLifecycle.js → session/workflowLifecycle.js} +2 -2
- package/lib/components/HDLKiosk/runtime/triggers.js +28 -0
- package/lib/components/HDLKiosk/slices/catalog/Screen/index.js +15 -8
- package/lib/components/HDLKiosk/slices/catalog/Screen/index.less +74 -13
- package/lib/components/HDLKiosk/slices/catalog/slice.js +3 -3
- package/lib/components/HDLKiosk/slices/customization/Screen/index.js +35 -36
- package/lib/components/HDLKiosk/slices/customization/Screen/index.less +5 -0
- package/lib/components/HDLKiosk/slices/customization/slice.js +5 -6
- package/lib/components/HDLKiosk/slices/fulfillment/slice.js +3 -3
- package/lib/components/HDLKiosk/slices/fulfillment/view.js +1 -1
- package/lib/components/HDLKiosk/slices/identity/slice.js +4 -4
- package/lib/components/HDLKiosk/slices/identity/view.js +1 -1
- package/lib/components/HDLKiosk/slices/payment/slice.js +5 -5
- package/lib/components/HDLKiosk/slices/primaryProductPrompt/slice.js +1 -1
- package/lib/components/HDLKiosk/{runtime → ui}/HDLKioskWorkflowView.js +44 -130
- package/lib/components/HDLKiosk/ui/ScaleSimulatorConsole/index.js +390 -0
- package/lib/components/HDLKiosk/ui/ScaleSimulatorConsole/index.less +621 -0
- package/lib/components/HDLKiosk/{app → ui}/ScreenRenderer.js +1 -1
- package/lib/components/HDLKiosk/ui/controllers/useHDLKioskActionDispatcher.js +67 -0
- package/lib/components/HDLKiosk/{runtime → ui}/controllers/useHDLKioskCustomerController.js +1 -1
- package/lib/components/HDLKiosk/ui/controllers/useHDLKioskDeviceController.js +26 -0
- package/lib/components/HDLKiosk/ui/controllers/useHDLKioskExitController.js +54 -0
- package/lib/components/HDLKiosk/{runtime → ui}/controllers/useHDLKioskScreenData.js +1 -1
- package/lib/components/HDLKiosk/ui/controllers/useHDLKioskSessionController.js +40 -0
- package/lib/components/HDLKiosk/{app → ui}/entry/Screen/index.js +8 -6
- package/lib/components/HDLKiosk/{app → ui}/entry/model.js +2 -2
- package/lib/components/HDLKiosk/ui/scale.js +24 -0
- package/lib/components/HDLKiosk/{runtime/useHostSnapshot.js → ui/snapshots.js} +6 -7
- package/lib/components/HDLKiosk/{app → ui}/views.js +1 -1
- package/lib/components/HDLKiosk/{runtime → ui}/workflowEvent.js +1 -1
- package/lib/components/HDLKiosk/utils.js +4 -4
- package/lib/components/bigSale/templates/HDLKiosk/adapter/HDLKioskPaymentRuntime.js +2 -1
- package/lib/components/bigSale/templates/HDLKiosk/adapter/capabilities.js +1 -1
- package/lib/components/bigSale/templates/HDLKiosk/adapter/projection.js +21 -10
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales.js +20 -2
- package/lib/components/bigSale/templates/HDLKiosk/adapter/scaleTrigger.js +19 -4
- package/lib/components/bigSale/templates/HDLKiosk/adapter/useBigSaleHDLKioskHost.js +3 -0
- package/lib/components/bigSale/templates/HDLKiosk/index.js +4 -4
- package/package.json +3 -3
- package/es/components/HDLKiosk/app/constants.js +0 -9
- package/es/components/HDLKiosk/app/operations/barcode.js +0 -22
- package/es/components/HDLKiosk/app/operations/cart.js +0 -60
- package/es/components/HDLKiosk/app/operations/fulfillment.js +0 -11
- package/es/components/HDLKiosk/app/operations/session.js +0 -41
- package/es/components/HDLKiosk/app/operations/types.js +0 -11
- package/es/components/HDLKiosk/devices/entryArbiter.js +0 -33
- package/es/components/HDLKiosk/runtime/controllers/useHDLKioskDeviceController.js +0 -75
- package/es/components/HDLKiosk/runtime/controllers/useHDLKioskScannerController.js +0 -160
- package/es/components/HDLKiosk/runtime/controllers/useHDLKioskSessionController.js +0 -185
- package/es/components/HDLKiosk/runtime/useWorkflowSnapshot.js +0 -12
- package/es/components/HDLKiosk/slices/customization/operation.js +0 -80
- package/es/components/HDLKiosk/slices/identity/operation.js +0 -60
- package/es/private-materials/lowcode/authmodal/meta.d.ts +0 -1
- package/lib/components/HDLKiosk/app/constants.js +0 -9
- package/lib/components/HDLKiosk/app/operations/barcode.js +0 -21
- package/lib/components/HDLKiosk/app/operations/cart.js +0 -62
- package/lib/components/HDLKiosk/app/operations/fulfillment.js +0 -10
- package/lib/components/HDLKiosk/app/operations/session.js +0 -42
- package/lib/components/HDLKiosk/app/operations/types.js +0 -12
- package/lib/components/HDLKiosk/devices/entryArbiter.js +0 -33
- package/lib/components/HDLKiosk/runtime/controllers/useHDLKioskDeviceController.js +0 -76
- package/lib/components/HDLKiosk/runtime/controllers/useHDLKioskScannerController.js +0 -161
- package/lib/components/HDLKiosk/runtime/controllers/useHDLKioskSessionController.js +0 -186
- package/lib/components/HDLKiosk/runtime/useWorkflowSnapshot.js +0 -13
- package/lib/components/HDLKiosk/slices/customization/operation.js +0 -83
- package/lib/components/HDLKiosk/slices/identity/operation.js +0 -60
- /package/es/components/HDLKiosk/{app → ui}/entry/Screen/index.less +0 -0
- /package/lib/components/HDLKiosk/{app → ui}/entry/Screen/index.less +0 -0
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { _asyncToGenerator } from "../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
|
|
2
|
-
import { finalizeCartMutation } from "./cartConsistency.js";
|
|
3
|
-
import { defineOperation } from "./types.js";
|
|
4
|
-
//#region src/components/HDLKiosk/app/operations/cart.ts
|
|
5
|
-
const cartAddProductOperation = defineOperation({
|
|
6
|
-
id: "cart.addProduct",
|
|
7
|
-
conflictScope: "cart",
|
|
8
|
-
retry: "explicit-user",
|
|
9
|
-
execute: function() {
|
|
10
|
-
var _ref = _asyncToGenerator(function* (context, input, signal) {
|
|
11
|
-
return finalizeCartMutation(context, yield context.host.sales.addProduct(input, signal), signal);
|
|
12
|
-
});
|
|
13
|
-
return function execute(_x, _x2, _x3) {
|
|
14
|
-
return _ref.apply(this, arguments);
|
|
15
|
-
};
|
|
16
|
-
}()
|
|
17
|
-
});
|
|
18
|
-
const cartUpdateQuantityOperation = defineOperation({
|
|
19
|
-
id: "cart.updateQuantity",
|
|
20
|
-
conflictScope: "cart",
|
|
21
|
-
timeoutMs: 15e3,
|
|
22
|
-
retry: "explicit-user",
|
|
23
|
-
execute: function() {
|
|
24
|
-
var _ref2 = _asyncToGenerator(function* (context, input, signal) {
|
|
25
|
-
const mutation = yield context.host.sales.updateQuantity(input, signal);
|
|
26
|
-
return finalizeCartMutation(context, mutation, signal, () => {
|
|
27
|
-
var _mutation$data$confir;
|
|
28
|
-
if (mutation.status === "succeeded" && mutation.data.affectedLineId === input.lineId && ((_mutation$data$confir = mutation.data.confirmedLine) === null || _mutation$data$confir === void 0 ? void 0 : _mutation$data$confir.lineId) === input.lineId && decimalValuesEqual(mutation.data.confirmedLine.quantity, input.quantity)) return true;
|
|
29
|
-
const line = context.host.sales.getObservedSnapshot().cart.lines.find((item) => item.lineId === input.lineId);
|
|
30
|
-
return decimalValuesEqual(line === null || line === void 0 ? void 0 : line.quantity, input.quantity);
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
return function execute(_x4, _x5, _x6) {
|
|
34
|
-
return _ref2.apply(this, arguments);
|
|
35
|
-
};
|
|
36
|
-
}()
|
|
37
|
-
});
|
|
38
|
-
function decimalValuesEqual(left, right) {
|
|
39
|
-
if (left === void 0) return false;
|
|
40
|
-
const leftNumber = Number(left);
|
|
41
|
-
const rightNumber = Number(right);
|
|
42
|
-
return Number.isFinite(leftNumber) && Number.isFinite(rightNumber) && leftNumber === rightNumber;
|
|
43
|
-
}
|
|
44
|
-
const cartRemoveLineOperation = defineOperation({
|
|
45
|
-
id: "cart.removeLine",
|
|
46
|
-
conflictScope: "cart",
|
|
47
|
-
timeoutMs: 15e3,
|
|
48
|
-
retry: "explicit-user",
|
|
49
|
-
execute: function() {
|
|
50
|
-
var _ref3 = _asyncToGenerator(function* (context, input, signal) {
|
|
51
|
-
const mutation = yield context.host.sales.removeLine(input, signal);
|
|
52
|
-
return finalizeCartMutation(context, mutation, signal, () => mutation.status === "succeeded" && mutation.data.removedLineId === input.lineId || !context.host.sales.getObservedSnapshot().cart.lines.some((item) => item.lineId === input.lineId));
|
|
53
|
-
});
|
|
54
|
-
return function execute(_x7, _x8, _x9) {
|
|
55
|
-
return _ref3.apply(this, arguments);
|
|
56
|
-
};
|
|
57
|
-
}()
|
|
58
|
-
});
|
|
59
|
-
//#endregion
|
|
60
|
-
export { cartAddProductOperation, cartRemoveLineOperation, cartUpdateQuantityOperation };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { defineOperation } from "./types.js";
|
|
2
|
-
//#region src/components/HDLKiosk/app/operations/fulfillment.ts
|
|
3
|
-
const setFulfillmentOperation = defineOperation({
|
|
4
|
-
id: "fulfillment.set",
|
|
5
|
-
conflictScope: "cart",
|
|
6
|
-
timeoutMs: 2e4,
|
|
7
|
-
retry: "explicit-user",
|
|
8
|
-
execute: (context, input, signal) => context.host.sales.setFulfillment(input, signal)
|
|
9
|
-
});
|
|
10
|
-
//#endregion
|
|
11
|
-
export { setFulfillmentOperation };
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { _asyncToGenerator } from "../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
|
|
2
|
-
import { operationUnknown } from "./errors.js";
|
|
3
|
-
import { defineOperation } from "./types.js";
|
|
4
|
-
//#region src/components/HDLKiosk/app/operations/session.ts
|
|
5
|
-
function forwardFailure(result) {
|
|
6
|
-
return result;
|
|
7
|
-
}
|
|
8
|
-
const sessionEnsureOperation = defineOperation({
|
|
9
|
-
id: "session.ensure",
|
|
10
|
-
conflictScope: "session",
|
|
11
|
-
timeoutMs: 15e3,
|
|
12
|
-
retry: "explicit-user",
|
|
13
|
-
execute: ({ host }, _input, signal) => host.sales.ensureSession(signal)
|
|
14
|
-
});
|
|
15
|
-
const sessionResetOperation = defineOperation({
|
|
16
|
-
id: "session.reset",
|
|
17
|
-
tags: ["session-reset"],
|
|
18
|
-
conflictScope: "session",
|
|
19
|
-
timeoutMs: 15e3,
|
|
20
|
-
retry: "never",
|
|
21
|
-
execute: function() {
|
|
22
|
-
var _ref = _asyncToGenerator(function* ({ host }, _input, signal) {
|
|
23
|
-
const before = host.sales.getObservedSnapshot();
|
|
24
|
-
if (before.payment.status === "pending" || before.payment.status === "unknown") return operationUnknown("resetBlockedByPaymentState");
|
|
25
|
-
const reset = yield host.sales.clearAndReset(signal);
|
|
26
|
-
if (reset.status !== "succeeded") return forwardFailure(reset);
|
|
27
|
-
if (!reset.data.cartEmpty) return operationUnknown("resetHostResultNotEmpty");
|
|
28
|
-
const consistency = yield host.sales.waitForCartConsistency(signal);
|
|
29
|
-
if (consistency.status !== "succeeded") return forwardFailure(consistency);
|
|
30
|
-
return {
|
|
31
|
-
status: "succeeded",
|
|
32
|
-
data: void 0
|
|
33
|
-
};
|
|
34
|
-
});
|
|
35
|
-
return function execute(_x, _x2, _x3) {
|
|
36
|
-
return _ref.apply(this, arguments);
|
|
37
|
-
};
|
|
38
|
-
}()
|
|
39
|
-
});
|
|
40
|
-
//#endregion
|
|
41
|
-
export { sessionEnsureOperation, sessionResetOperation };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { createKernelOperationRegistry } from "../../kernel/operations/registry.js";
|
|
2
|
-
import { defineKernelOperation } from "../../kernel/operations/types.js";
|
|
3
|
-
//#region src/components/HDLKiosk/app/operations/types.ts
|
|
4
|
-
function defineOperation(operation) {
|
|
5
|
-
return defineKernelOperation(operation);
|
|
6
|
-
}
|
|
7
|
-
function createOperationRegistry(operations) {
|
|
8
|
-
return createKernelOperationRegistry(operations);
|
|
9
|
-
}
|
|
10
|
-
//#endregion
|
|
11
|
-
export { createOperationRegistry, defineOperation };
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
//#region src/components/HDLKiosk/devices/entryArbiter.ts
|
|
2
|
-
/**
|
|
3
|
-
* JS 同一执行上下文内同步锁定第一个入口。它不持有 Workflow,也不执行副作用。
|
|
4
|
-
*/
|
|
5
|
-
function createEntryArbiter() {
|
|
6
|
-
let active;
|
|
7
|
-
return {
|
|
8
|
-
claim: (entry) => {
|
|
9
|
-
if (active === void 0) {
|
|
10
|
-
active = entry;
|
|
11
|
-
return {
|
|
12
|
-
status: "accepted",
|
|
13
|
-
entry
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
if (active === entry) return {
|
|
17
|
-
status: "accepted",
|
|
18
|
-
entry
|
|
19
|
-
};
|
|
20
|
-
return {
|
|
21
|
-
status: "rejected",
|
|
22
|
-
reason: "workflowLocked",
|
|
23
|
-
activeEntry: active
|
|
24
|
-
};
|
|
25
|
-
},
|
|
26
|
-
activeEntry: () => active,
|
|
27
|
-
reset: () => {
|
|
28
|
-
active = void 0;
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
//#endregion
|
|
33
|
-
export { createEntryArbiter };
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { _asyncToGenerator } from "../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
|
|
2
|
-
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
|
-
//#region src/components/HDLKiosk/runtime/controllers/useHDLKioskDeviceController.ts
|
|
4
|
-
/**
|
|
5
|
-
* 文件角色:连接 Scale Port、入口 Ingress 与会话启动器。
|
|
6
|
-
* 运行机制:Entry 可见时消费称重边沿并请求 Scale Session;持续读数由 Scale Runtime 管理。
|
|
7
|
-
* 边界:Scanner 由独立的 Session 级 Scanner Controller 持有。
|
|
8
|
-
*/
|
|
9
|
-
function useHDLKioskDeviceController({ host, config, isActive, starting, session, sessionRef, activeRef, scaleIngress, start }) {
|
|
10
|
-
const [scaleConnectionState, setScaleConnectionState] = useState();
|
|
11
|
-
const rejectionSequence = useRef(0);
|
|
12
|
-
const scaleAvailable = host.capabilities.scale.available;
|
|
13
|
-
const scaleWeightChangeTrigger = host.capabilities.scale.weightChangeTrigger;
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
setScaleConnectionState(void 0);
|
|
16
|
-
}, [host]);
|
|
17
|
-
const rejectDeviceEvent = useCallback((event, reason) => {
|
|
18
|
-
rejectionSequence.current += 1;
|
|
19
|
-
try {
|
|
20
|
-
host.telemetry.emit({
|
|
21
|
-
name: "hdlKiosk.device.eventRejected",
|
|
22
|
-
traceId: `hdl-device-rejected-${rejectionSequence.current}`,
|
|
23
|
-
occurredAt: Date.now(),
|
|
24
|
-
attributes: {
|
|
25
|
-
eventType: event.type,
|
|
26
|
-
reason
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
} catch (_unused) {}
|
|
30
|
-
}, [host]);
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
const primaryWeightedProductId = config.primaryWeightedProductId;
|
|
33
|
-
if (!isActive || starting || !primaryWeightedProductId) return;
|
|
34
|
-
if (session) return void 0;
|
|
35
|
-
return host.devices.subscribe((event) => {
|
|
36
|
-
if (!activeRef.current) return;
|
|
37
|
-
if (event.type === "connectionChanged" && event.device === "scale") {
|
|
38
|
-
var _event$state;
|
|
39
|
-
setScaleConnectionState((_event$state = event.state) !== null && _event$state !== void 0 ? _event$state : event.connected ? "connected" : "disconnected");
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
if (event.type !== "weightChanged") return;
|
|
43
|
-
const activeSession = sessionRef.current;
|
|
44
|
-
const result = scaleIngress.accept(event, {
|
|
45
|
-
active: activeRef.current,
|
|
46
|
-
supported: scaleAvailable && scaleWeightChangeTrigger && config.enabledEntries.includes("scale"),
|
|
47
|
-
workflowLocked: Boolean(activeSession),
|
|
48
|
-
nodeAcceptsEvent: !activeSession,
|
|
49
|
-
paymentFrozen: false
|
|
50
|
-
});
|
|
51
|
-
if (result.status === "rejected") {
|
|
52
|
-
rejectDeviceEvent(event, result.reason);
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
_asyncToGenerator(function* () {
|
|
56
|
-
if (!(yield start({ entry: "scale" }))) rejectDeviceEvent(event, "sessionStartFailed");
|
|
57
|
-
})();
|
|
58
|
-
}, { sources: ["scale"] });
|
|
59
|
-
}, [
|
|
60
|
-
config.enabledEntries,
|
|
61
|
-
config.primaryWeightedProductId,
|
|
62
|
-
host,
|
|
63
|
-
isActive,
|
|
64
|
-
rejectDeviceEvent,
|
|
65
|
-
scaleAvailable,
|
|
66
|
-
scaleIngress,
|
|
67
|
-
scaleWeightChangeTrigger,
|
|
68
|
-
session,
|
|
69
|
-
start,
|
|
70
|
-
starting
|
|
71
|
-
]);
|
|
72
|
-
return { scaleConnectionState };
|
|
73
|
-
}
|
|
74
|
-
//#endregion
|
|
75
|
-
export { useHDLKioskDeviceController };
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import { _asyncToGenerator } from "../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
|
|
2
|
-
import { useCallback, useEffect, useRef } from "react";
|
|
3
|
-
//#region src/components/HDLKiosk/runtime/controllers/useHDLKioskScannerController.ts
|
|
4
|
-
/**
|
|
5
|
-
* 文件角色:在 HDLKiosk active 生命周期内唯一拥有 Scanner,并把扫码任务归属到 Session。
|
|
6
|
-
* 运行机制:Ingress 去重/背压后进入有限 FIFO;Session readyForCommands 后串行消费。
|
|
7
|
-
* 边界:不依赖任何 Screen mount,不负责 Workflow 导航,也不记录原始条码。
|
|
8
|
-
*/
|
|
9
|
-
const NON_WRITABLE_ACTIVITIES = new Set(["paymentCompleted"]);
|
|
10
|
-
const PAYMENT_OPERATION_IDS = new Set([
|
|
11
|
-
"checkout.open",
|
|
12
|
-
"checkout.payEftpos",
|
|
13
|
-
"checkout.requestStaffPaymentApproval",
|
|
14
|
-
"session.reset"
|
|
15
|
-
]);
|
|
16
|
-
function isPaymentFrozen(host) {
|
|
17
|
-
const status = host.sales.getObservedSnapshot().payment.status;
|
|
18
|
-
return status === "pending" || status === "unknown" || status === "succeeded";
|
|
19
|
-
}
|
|
20
|
-
function isHDLKioskSessionCartWritable(session) {
|
|
21
|
-
var _session$definition$n;
|
|
22
|
-
const snapshot = session.actor.getSnapshot();
|
|
23
|
-
if (snapshot.status === "blocked" || snapshot.status === "finished") return false;
|
|
24
|
-
const activity = (_session$definition$n = session.definition.nodes[snapshot.nodeId]) === null || _session$definition$n === void 0 ? void 0 : _session$definition$n.activity;
|
|
25
|
-
if (!activity || NON_WRITABLE_ACTIVITIES.has(activity)) return false;
|
|
26
|
-
return !(snapshot.activeOperation && PAYMENT_OPERATION_IDS.has(snapshot.activeOperation.definitionId));
|
|
27
|
-
}
|
|
28
|
-
function useHDLKioskScannerController({ host, config, isActive, starting, sessionRef, activeRef, scannerIngress, start, waitForReadySession }) {
|
|
29
|
-
const queueRef = useRef([]);
|
|
30
|
-
const startingRef = useRef(starting);
|
|
31
|
-
const processingRef = useRef(false);
|
|
32
|
-
const currentTaskRef = useRef();
|
|
33
|
-
const generationRef = useRef(0);
|
|
34
|
-
const rejectionSequence = useRef(0);
|
|
35
|
-
const scannerAvailable = host.capabilities.scanner.available;
|
|
36
|
-
startingRef.current = starting;
|
|
37
|
-
const emitRejected = useCallback((event, reason) => {
|
|
38
|
-
rejectionSequence.current += 1;
|
|
39
|
-
try {
|
|
40
|
-
host.telemetry.emit({
|
|
41
|
-
name: "hdlKiosk.device.eventRejected",
|
|
42
|
-
traceId: `hdl-scanner-rejected-${rejectionSequence.current}`,
|
|
43
|
-
occurredAt: Date.now(),
|
|
44
|
-
attributes: {
|
|
45
|
-
eventType: event.type,
|
|
46
|
-
reason
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
} catch (_unused) {}
|
|
50
|
-
}, [host]);
|
|
51
|
-
const emitCompleted = useCallback((task, target, result) => {
|
|
52
|
-
try {
|
|
53
|
-
host.telemetry.emit({
|
|
54
|
-
name: "hdlKiosk.scanner.taskFinished",
|
|
55
|
-
traceId: `hdl-scan:${target.actor.getSnapshot().sessionEpoch}:${task.event.eventId}`,
|
|
56
|
-
occurredAt: Date.now(),
|
|
57
|
-
attributes: {
|
|
58
|
-
eventId: task.event.eventId,
|
|
59
|
-
sessionEpoch: target.actor.getSnapshot().sessionEpoch,
|
|
60
|
-
status: result.status
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
} catch (_unused2) {}
|
|
64
|
-
}, [host]);
|
|
65
|
-
const processQueue = useCallback(_asyncToGenerator(function* () {
|
|
66
|
-
if (processingRef.current) return;
|
|
67
|
-
processingRef.current = true;
|
|
68
|
-
const generation = generationRef.current;
|
|
69
|
-
try {
|
|
70
|
-
while (activeRef.current && generation === generationRef.current && queueRef.current.length > 0) {
|
|
71
|
-
var _sessionRef$current;
|
|
72
|
-
const nextTask = queueRef.current[0];
|
|
73
|
-
if (!nextTask) continue;
|
|
74
|
-
let target = (_sessionRef$current = sessionRef.current) !== null && _sessionRef$current !== void 0 ? _sessionRef$current : yield waitForReadySession();
|
|
75
|
-
if (!target && nextTask.binding === "startBarcodeSession") target = yield start({ entry: "barcode" });
|
|
76
|
-
if (!target || nextTask.acceptedSessionEpoch !== void 0 && target.actor.getSnapshot().sessionEpoch !== nextTask.acceptedSessionEpoch || generation !== generationRef.current || !activeRef.current) {
|
|
77
|
-
const rejected = queueRef.current.shift();
|
|
78
|
-
if (rejected) emitRejected(rejected.event, "sessionStartFailed");
|
|
79
|
-
continue;
|
|
80
|
-
}
|
|
81
|
-
if (isPaymentFrozen(host) || !isHDLKioskSessionCartWritable(target)) {
|
|
82
|
-
const rejected = queueRef.current.shift();
|
|
83
|
-
if (rejected) emitRejected(rejected.event, "sessionNotCartWritable");
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
const pendingNavigation = target.actor.getSnapshot().pendingNavigation;
|
|
87
|
-
if (pendingNavigation) target.actor.resolvePendingNavigation(pendingNavigation.navigationId, "cancel");
|
|
88
|
-
const task = queueRef.current.shift();
|
|
89
|
-
if (!task) continue;
|
|
90
|
-
currentTaskRef.current = task;
|
|
91
|
-
const sessionEpoch = target.actor.getSnapshot().sessionEpoch;
|
|
92
|
-
const result = yield target.executeCommand("barcode.consume", { code: task.code }, `scan:${sessionEpoch}:${task.event.eventId}`);
|
|
93
|
-
currentTaskRef.current = void 0;
|
|
94
|
-
emitCompleted(task, target, result);
|
|
95
|
-
if (result.status === "partialFailure" || result.status === "unknown") queueRef.current = [];
|
|
96
|
-
}
|
|
97
|
-
} finally {
|
|
98
|
-
currentTaskRef.current = void 0;
|
|
99
|
-
processingRef.current = false;
|
|
100
|
-
}
|
|
101
|
-
}), [
|
|
102
|
-
activeRef,
|
|
103
|
-
emitCompleted,
|
|
104
|
-
emitRejected,
|
|
105
|
-
waitForReadySession,
|
|
106
|
-
host,
|
|
107
|
-
sessionRef,
|
|
108
|
-
start
|
|
109
|
-
]);
|
|
110
|
-
useEffect(() => {
|
|
111
|
-
if (!isActive || !scannerAvailable) return void 0;
|
|
112
|
-
return host.devices.subscribe((event) => {
|
|
113
|
-
if (!activeRef.current || event.type !== "barcode") return;
|
|
114
|
-
const activeSession = sessionRef.current;
|
|
115
|
-
const canStartBarcode = config.enabledEntries.includes("barcode");
|
|
116
|
-
const supported = Boolean(activeSession || startingRef.current || canStartBarcode);
|
|
117
|
-
const cartWritable = activeSession ? isHDLKioskSessionCartWritable(activeSession) : true;
|
|
118
|
-
const result = scannerIngress.accept(event, {
|
|
119
|
-
active: activeRef.current,
|
|
120
|
-
supported,
|
|
121
|
-
workflowLocked: false,
|
|
122
|
-
nodeAcceptsEvent: cartWritable,
|
|
123
|
-
paymentFrozen: isPaymentFrozen(host),
|
|
124
|
-
pendingEventCount: queueRef.current.length + (currentTaskRef.current ? 1 : 0)
|
|
125
|
-
});
|
|
126
|
-
if (result.status === "rejected") {
|
|
127
|
-
emitRejected(event, result.reason);
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
queueRef.current.push({
|
|
131
|
-
event: result.event,
|
|
132
|
-
code: result.code,
|
|
133
|
-
binding: activeSession || startingRef.current ? "existingOrPendingSession" : "startBarcodeSession",
|
|
134
|
-
acceptedSessionEpoch: activeSession === null || activeSession === void 0 ? void 0 : activeSession.actor.getSnapshot().sessionEpoch
|
|
135
|
-
});
|
|
136
|
-
processQueue();
|
|
137
|
-
}, { sources: ["scanner"] });
|
|
138
|
-
}, [
|
|
139
|
-
activeRef,
|
|
140
|
-
config.enabledEntries,
|
|
141
|
-
emitRejected,
|
|
142
|
-
host,
|
|
143
|
-
isActive,
|
|
144
|
-
processQueue,
|
|
145
|
-
scannerAvailable,
|
|
146
|
-
scannerIngress,
|
|
147
|
-
sessionRef
|
|
148
|
-
]);
|
|
149
|
-
useEffect(() => {
|
|
150
|
-
if (isActive) return;
|
|
151
|
-
generationRef.current += 1;
|
|
152
|
-
queueRef.current = [];
|
|
153
|
-
}, [isActive]);
|
|
154
|
-
useEffect(() => () => {
|
|
155
|
-
generationRef.current += 1;
|
|
156
|
-
queueRef.current = [];
|
|
157
|
-
}, [host]);
|
|
158
|
-
}
|
|
159
|
-
//#endregion
|
|
160
|
-
export { useHDLKioskScannerController };
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import { _asyncToGenerator } from "../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
|
|
2
|
-
import { createEntryArbiter } from "../../devices/entryArbiter.js";
|
|
3
|
-
import { createScaleIngress } from "../../devices/scaleIngress.js";
|
|
4
|
-
import { createScannerIngress } from "../../devices/scannerIngress.js";
|
|
5
|
-
import { builtInWorkflowHasActivity, isBuiltInWorkflowProductionReady } from "../../app/workflow/registry.js";
|
|
6
|
-
import { createHDLKioskWorkflowSession } from "../createWorkflowSession.js";
|
|
7
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
8
|
-
//#region src/components/HDLKiosk/runtime/controllers/useHDLKioskSessionController.ts
|
|
9
|
-
/**
|
|
10
|
-
* 文件角色:拥有 Entry、会话创建/销毁和回首页的顶层生命周期。
|
|
11
|
-
* 运行机制:结合 Capabilities 和入口 claim 决定 start;reset 成功后 dispose Actor
|
|
12
|
-
* 并推进 session epoch。当前应用不恢复跨刷新会话。
|
|
13
|
-
* 边界:不会仅靠页面导航开始下一单,也不消费具体 Screen 的局部交互。
|
|
14
|
-
*/
|
|
15
|
-
/**
|
|
16
|
-
* Barcode 的首次扫码只需要建立可写 Session 并消费条码;秤和称重主商品
|
|
17
|
-
* 是后续业务分支能力,不得阻断 Barcode Session 入口。
|
|
18
|
-
*/
|
|
19
|
-
function resolveHDLKioskEntryCapabilityBlockReason({ entry, capabilities, primaryWeightedProductId }) {
|
|
20
|
-
if (!capabilities.session.ensure) return "sessionEnsureUnavailable";
|
|
21
|
-
if (entry === "barcode") return capabilities.scanner.available ? void 0 : "scannerUnavailable";
|
|
22
|
-
if (!capabilities.products.primaryWeightedProductQuery || !primaryWeightedProductId) return "primaryProductUnavailable";
|
|
23
|
-
if (builtInWorkflowHasActivity(entry, "customization") && (!capabilities.customization.weightedProduct || !capabilities.scale.available)) return "customizationUnavailable";
|
|
24
|
-
if (entry === "scale" && (!capabilities.scale.available || !capabilities.scale.weightChangeTrigger)) return "scaleTriggerUnavailable";
|
|
25
|
-
}
|
|
26
|
-
function useHDLKioskSessionController({ host, config, isActive }) {
|
|
27
|
-
const [session, setSession] = useState();
|
|
28
|
-
const [starting, setStarting] = useState(false);
|
|
29
|
-
const [startErrorReference, setStartErrorReference] = useState();
|
|
30
|
-
const sessionRef = useRef(session);
|
|
31
|
-
const startingSessionRef = useRef();
|
|
32
|
-
const startPromiseRef = useRef();
|
|
33
|
-
const startAttemptSequence = useRef(0);
|
|
34
|
-
const returnAttemptSequence = useRef(0);
|
|
35
|
-
const returnPromiseRef = useRef();
|
|
36
|
-
const activeRef = useRef(isActive);
|
|
37
|
-
const mountedHostRef = useRef(host);
|
|
38
|
-
const entryArbiter = useMemo(() => createEntryArbiter(), [host]);
|
|
39
|
-
const scannerIngress = useMemo(() => createScannerIngress({ maxPendingEvents: 5 }), [host]);
|
|
40
|
-
const scaleIngress = useMemo(() => createScaleIngress(), [host]);
|
|
41
|
-
sessionRef.current = session;
|
|
42
|
-
activeRef.current = isActive;
|
|
43
|
-
useEffect(() => () => {
|
|
44
|
-
var _sessionRef$current, _startingSessionRef$c;
|
|
45
|
-
(_sessionRef$current = sessionRef.current) === null || _sessionRef$current === void 0 || _sessionRef$current.actor.dispose();
|
|
46
|
-
(_startingSessionRef$c = startingSessionRef.current) === null || _startingSessionRef$c === void 0 || _startingSessionRef$c.actor.dispose();
|
|
47
|
-
}, []);
|
|
48
|
-
useEffect(() => {
|
|
49
|
-
var _sessionRef$current2, _startingSessionRef$c2;
|
|
50
|
-
if (mountedHostRef.current === host) return;
|
|
51
|
-
(_sessionRef$current2 = sessionRef.current) === null || _sessionRef$current2 === void 0 || _sessionRef$current2.actor.dispose();
|
|
52
|
-
(_startingSessionRef$c2 = startingSessionRef.current) === null || _startingSessionRef$c2 === void 0 || _startingSessionRef$c2.actor.dispose();
|
|
53
|
-
startingSessionRef.current = void 0;
|
|
54
|
-
startPromiseRef.current = void 0;
|
|
55
|
-
startAttemptSequence.current += 1;
|
|
56
|
-
sessionRef.current = void 0;
|
|
57
|
-
entryArbiter.reset();
|
|
58
|
-
scannerIngress.reset();
|
|
59
|
-
scaleIngress.reset();
|
|
60
|
-
mountedHostRef.current = host;
|
|
61
|
-
setSession(void 0);
|
|
62
|
-
setStarting(false);
|
|
63
|
-
setStartErrorReference(void 0);
|
|
64
|
-
}, [
|
|
65
|
-
entryArbiter,
|
|
66
|
-
host,
|
|
67
|
-
scaleIngress,
|
|
68
|
-
scannerIngress
|
|
69
|
-
]);
|
|
70
|
-
const start = useCallback((request) => {
|
|
71
|
-
const { entry } = request;
|
|
72
|
-
if (!activeRef.current || !config.enabledEntries.includes(entry)) return Promise.resolve(void 0);
|
|
73
|
-
if (config.businessMode === "production" && !isBuiltInWorkflowProductionReady(entry)) {
|
|
74
|
-
setStartErrorReference(`workflow-placeholder-blocked-${Date.now()}`);
|
|
75
|
-
return Promise.resolve(void 0);
|
|
76
|
-
}
|
|
77
|
-
const capabilityBlockReason = resolveHDLKioskEntryCapabilityBlockReason({
|
|
78
|
-
entry,
|
|
79
|
-
capabilities: host.capabilities,
|
|
80
|
-
primaryWeightedProductId: config.primaryWeightedProductId
|
|
81
|
-
});
|
|
82
|
-
if (capabilityBlockReason) {
|
|
83
|
-
if (capabilityBlockReason === "sessionEnsureUnavailable") setStartErrorReference(`session-ensure-unavailable-${Date.now()}`);
|
|
84
|
-
return Promise.resolve(void 0);
|
|
85
|
-
}
|
|
86
|
-
const current = sessionRef.current;
|
|
87
|
-
if (current) return Promise.resolve(current.entry === entry ? current : void 0);
|
|
88
|
-
const pending = startPromiseRef.current;
|
|
89
|
-
if (pending) return pending.entry === entry ? pending.promise : Promise.resolve(void 0);
|
|
90
|
-
if (entryArbiter.claim(entry).status !== "accepted") return Promise.resolve(void 0);
|
|
91
|
-
const next = createHDLKioskWorkflowSession(entry, host, { primaryWeightedProductId: config.primaryWeightedProductId });
|
|
92
|
-
startingSessionRef.current = next;
|
|
93
|
-
startAttemptSequence.current += 1;
|
|
94
|
-
const attempt = startAttemptSequence.current;
|
|
95
|
-
setStarting(true);
|
|
96
|
-
setStartErrorReference(void 0);
|
|
97
|
-
const promise = next.ensure(`entry:${entry}:ensure:${attempt}`).then(function() {
|
|
98
|
-
var _ref = _asyncToGenerator(function* (result) {
|
|
99
|
-
if (attempt !== startAttemptSequence.current || mountedHostRef.current !== host || !activeRef.current) {
|
|
100
|
-
next.actor.dispose();
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
if (result.status !== "succeeded") {
|
|
104
|
-
next.actor.dispose();
|
|
105
|
-
entryArbiter.reset();
|
|
106
|
-
setStartErrorReference(result.status === "failed" || result.status === "partialFailure" || result.status === "unknown" ? result.error.traceId : `session-start-cancelled-${Date.now()}`);
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
sessionRef.current = next;
|
|
110
|
-
setSession(next);
|
|
111
|
-
return next;
|
|
112
|
-
});
|
|
113
|
-
return function(_x) {
|
|
114
|
-
return _ref.apply(this, arguments);
|
|
115
|
-
};
|
|
116
|
-
}()).finally(() => {
|
|
117
|
-
if (attempt !== startAttemptSequence.current) return;
|
|
118
|
-
startingSessionRef.current = void 0;
|
|
119
|
-
startPromiseRef.current = void 0;
|
|
120
|
-
setStarting(false);
|
|
121
|
-
});
|
|
122
|
-
startPromiseRef.current = {
|
|
123
|
-
entry,
|
|
124
|
-
promise
|
|
125
|
-
};
|
|
126
|
-
return promise;
|
|
127
|
-
}, [
|
|
128
|
-
config.enabledEntries,
|
|
129
|
-
config.primaryWeightedProductId,
|
|
130
|
-
entryArbiter,
|
|
131
|
-
host
|
|
132
|
-
]);
|
|
133
|
-
const waitForReadySession = useCallback(() => {
|
|
134
|
-
var _startPromiseRef$curr, _startPromiseRef$curr2;
|
|
135
|
-
const current = sessionRef.current;
|
|
136
|
-
if (current) return Promise.resolve(current);
|
|
137
|
-
return (_startPromiseRef$curr = (_startPromiseRef$curr2 = startPromiseRef.current) === null || _startPromiseRef$curr2 === void 0 ? void 0 : _startPromiseRef$curr2.promise) !== null && _startPromiseRef$curr !== void 0 ? _startPromiseRef$curr : Promise.resolve(void 0);
|
|
138
|
-
}, []);
|
|
139
|
-
const completeReset = useCallback((completedSession) => {
|
|
140
|
-
if (sessionRef.current !== completedSession) return;
|
|
141
|
-
completedSession.actor.dispose();
|
|
142
|
-
entryArbiter.reset();
|
|
143
|
-
scannerIngress.reset();
|
|
144
|
-
scaleIngress.reset();
|
|
145
|
-
sessionRef.current = void 0;
|
|
146
|
-
setSession(void 0);
|
|
147
|
-
}, [
|
|
148
|
-
entryArbiter,
|
|
149
|
-
scaleIngress,
|
|
150
|
-
scannerIngress
|
|
151
|
-
]);
|
|
152
|
-
return {
|
|
153
|
-
session,
|
|
154
|
-
starting,
|
|
155
|
-
startErrorReference,
|
|
156
|
-
sessionRef,
|
|
157
|
-
activeRef,
|
|
158
|
-
entryArbiter,
|
|
159
|
-
scannerIngress,
|
|
160
|
-
scaleIngress,
|
|
161
|
-
start,
|
|
162
|
-
waitForReadySession,
|
|
163
|
-
completeReset,
|
|
164
|
-
returnToEntry: useCallback((reason = "application") => {
|
|
165
|
-
if (returnPromiseRef.current) return returnPromiseRef.current;
|
|
166
|
-
const current = sessionRef.current;
|
|
167
|
-
if (!current) return Promise.resolve({
|
|
168
|
-
status: "succeeded",
|
|
169
|
-
data: void 0
|
|
170
|
-
});
|
|
171
|
-
returnAttemptSequence.current += 1;
|
|
172
|
-
const attempt = returnAttemptSequence.current;
|
|
173
|
-
const promise = current.reset(`return:${reason}:${attempt}`).then((result) => {
|
|
174
|
-
if (result.status === "succeeded") completeReset(current);
|
|
175
|
-
return result;
|
|
176
|
-
}).finally(() => {
|
|
177
|
-
if (returnPromiseRef.current === promise) returnPromiseRef.current = void 0;
|
|
178
|
-
});
|
|
179
|
-
returnPromiseRef.current = promise;
|
|
180
|
-
return promise;
|
|
181
|
-
}, [completeReset])
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
//#endregion
|
|
185
|
-
export { useHDLKioskSessionController };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { useSyncExternalStore } from "react";
|
|
2
|
-
//#region src/components/HDLKiosk/runtime/useWorkflowSnapshot.ts
|
|
3
|
-
/**
|
|
4
|
-
* 文件角色:将纯 Workflow Actor 的 Snapshot 接入 React 渲染。
|
|
5
|
-
* 运行机制:useSyncExternalStore 订阅 Actor,组件始终消费 Actor 发布的不可变快照。
|
|
6
|
-
* 边界:不发送事件、不派生业务事实,也不维护第二份当前节点状态。
|
|
7
|
-
*/
|
|
8
|
-
function useWorkflowSnapshot(actor) {
|
|
9
|
-
return useSyncExternalStore(actor.subscribe, actor.getSnapshot, actor.getSnapshot);
|
|
10
|
-
}
|
|
11
|
-
//#endregion
|
|
12
|
-
export { useWorkflowSnapshot };
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { _asyncToGenerator } from "../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
|
|
2
|
-
import { canonicalizeSkuValue, createSkuValueFingerprint } from "../../../../plus/skuOptionsSelection/utils/canonicalSkuValue.js";
|
|
3
|
-
import { operationFailed } from "../../app/operations/errors.js";
|
|
4
|
-
import { finalizeCartMutation } from "../../app/operations/cartConsistency.js";
|
|
5
|
-
import { defineOperation } from "../../app/operations/types.js";
|
|
6
|
-
import Decimal from "decimal.js";
|
|
7
|
-
//#region src/components/HDLKiosk/slices/customization/operation.ts
|
|
8
|
-
/**
|
|
9
|
-
* 文件角色:在 Customization Next 边界提交称重主商品本地草稿。
|
|
10
|
-
* 运行机制:校验稳定净重/必选项,调用 Host/OS 主商品 writer,再验证目标行、重量、
|
|
11
|
-
* SkuValue 和“新增或原行发生变化”的最小 receipt/Projection 事实。
|
|
12
|
-
* 边界:页面输入变化不调用本 Operation;OS 内部的加购弹窗与业务判断不属于 HDLKiosk。
|
|
13
|
-
*/
|
|
14
|
-
const productRemovePrimaryProductOperation = defineOperation({
|
|
15
|
-
id: "product.removePrimaryProduct",
|
|
16
|
-
conflictScope: "cart",
|
|
17
|
-
timeoutMs: 15e3,
|
|
18
|
-
retry: "explicit-user",
|
|
19
|
-
execute: function() {
|
|
20
|
-
var _ref = _asyncToGenerator(function* (context, input, signal) {
|
|
21
|
-
if (!input.lineId) return {
|
|
22
|
-
status: "succeeded",
|
|
23
|
-
data: {}
|
|
24
|
-
};
|
|
25
|
-
const mutation = yield context.host.sales.removeLine({ lineId: input.lineId }, signal);
|
|
26
|
-
return finalizeCartMutation(context, mutation, signal, () => mutation.status === "succeeded" && mutation.data.removedLineId === input.lineId || !context.host.sales.getObservedSnapshot().cart.lines.some((item) => item.lineId === input.lineId));
|
|
27
|
-
});
|
|
28
|
-
return function execute(_x, _x2, _x3) {
|
|
29
|
-
return _ref.apply(this, arguments);
|
|
30
|
-
};
|
|
31
|
-
}()
|
|
32
|
-
});
|
|
33
|
-
function hasValidSkuValue(input) {
|
|
34
|
-
const canonical = canonicalizeSkuValue(input.skuValue);
|
|
35
|
-
return Boolean(input.productId && canonical && canonical.productId === input.productId);
|
|
36
|
-
}
|
|
37
|
-
function sameSkuValue(expected, actual) {
|
|
38
|
-
const expectedFingerprint = createSkuValueFingerprint(expected);
|
|
39
|
-
return Boolean(expectedFingerprint && expectedFingerprint === createSkuValueFingerprint(actual));
|
|
40
|
-
}
|
|
41
|
-
function sameWeight(actual, expected) {
|
|
42
|
-
const actualValue = new Decimal(actual || NaN);
|
|
43
|
-
const expectedValue = new Decimal(expected || NaN);
|
|
44
|
-
return actualValue.isFinite() && expectedValue.isFinite() && actualValue.equals(expectedValue);
|
|
45
|
-
}
|
|
46
|
-
const productSyncPrimaryWeightedProductOperation = defineOperation({
|
|
47
|
-
id: "product.syncPrimaryWeightedProduct",
|
|
48
|
-
conflictScope: "cart",
|
|
49
|
-
retry: "explicit-user",
|
|
50
|
-
execute: function() {
|
|
51
|
-
var _ref2 = _asyncToGenerator(function* (context, input, signal) {
|
|
52
|
-
if (!hasValidSkuValue(input)) return operationFailed("customizationInputInvalid", "back");
|
|
53
|
-
const beforeLines = new Map(context.host.sales.getObservedSnapshot().cart.lines.map((line) => [line.lineId, line.quantity]));
|
|
54
|
-
const before = context.host.sales.getObservedSnapshot();
|
|
55
|
-
const previousPrimary = input.existingLineId ? before.cart.lines.find((line) => line.lineId === input.existingLineId) : void 0;
|
|
56
|
-
if (input.existingLineId && (!previousPrimary || previousPrimary.productId !== input.productId)) return operationFailed("customizationExistingLineInvalid", "back");
|
|
57
|
-
const mutation = yield context.host.sales.syncPrimaryWeightedProduct(input, signal);
|
|
58
|
-
return finalizeCartMutation(context, mutation, signal, () => {
|
|
59
|
-
const after = context.host.sales.getObservedSnapshot();
|
|
60
|
-
const projectionMatches = after.cart.lines.some((line) => {
|
|
61
|
-
if (mutation.status === "succeeded" && mutation.data.affectedLineId && line.lineId !== mutation.data.affectedLineId) return false;
|
|
62
|
-
if (line.productId !== input.productId) return false;
|
|
63
|
-
const skuMatches = sameSkuValue(input.skuValue, line.skuValue);
|
|
64
|
-
const weightMatches = sameWeight(line.quantity, input.measurement.netWeightKg);
|
|
65
|
-
const previousQuantity = beforeLines.get(line.lineId);
|
|
66
|
-
if (input.existingLineId) return line.lineId === input.existingLineId && skuMatches && weightMatches && mutation.status === "succeeded" && mutation.data.affectedLineId === input.existingLineId && after.observationId > before.observationId;
|
|
67
|
-
return skuMatches && weightMatches && (previousQuantity === void 0 || previousQuantity !== line.quantity);
|
|
68
|
-
});
|
|
69
|
-
const successfulOutcome = mutation.status === "succeeded" ? mutation.data : void 0;
|
|
70
|
-
const confirmedLine = successfulOutcome === null || successfulOutcome === void 0 ? void 0 : successfulOutcome.confirmedLine;
|
|
71
|
-
return Boolean(confirmedLine && confirmedLine.productId === input.productId && (!(successfulOutcome === null || successfulOutcome === void 0 ? void 0 : successfulOutcome.affectedLineId) || confirmedLine.lineId === successfulOutcome.affectedLineId) && (!input.existingLineId || (successfulOutcome === null || successfulOutcome === void 0 ? void 0 : successfulOutcome.affectedLineId) === input.existingLineId && confirmedLine.lineId === input.existingLineId) && sameWeight(confirmedLine.quantity, input.measurement.netWeightKg) && sameSkuValue(input.skuValue, confirmedLine.skuValue) && (Boolean(input.existingLineId) || !beforeLines.has(confirmedLine.lineId) || beforeLines.get(confirmedLine.lineId) !== confirmedLine.quantity)) || projectionMatches;
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
return function execute(_x4, _x5, _x6) {
|
|
75
|
-
return _ref2.apply(this, arguments);
|
|
76
|
-
};
|
|
77
|
-
}()
|
|
78
|
-
});
|
|
79
|
-
//#endregion
|
|
80
|
-
export { productRemovePrimaryProductOperation, productSyncPrimaryWeightedProductOperation };
|