@pisell/private-materials 6.12.167 → 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 +11 -13
- 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 +105 -101
- package/es/components/HDLKiosk/docs/03-/344/270/232/345/212/241/346/265/201/347/250/213/344/270/216/344/272/244/344/272/222/350/247/204/345/210/231.md +2 -2
- 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/07-/345/220/216/347/273/255/345/267/245/344/275/234.md +1 -1
- 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 +14 -13
- 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 +51 -22
- package/es/components/HDLKiosk/kernel/workflow/compiler.js +23 -30
- 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 +37 -38
- package/es/components/HDLKiosk/slices/customization/Screen/index.less +5 -0
- package/es/components/HDLKiosk/slices/customization/slice.js +3 -4
- 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/Screen/index.js +2 -2
- package/es/components/HDLKiosk/slices/identity/slice.js +3 -3
- 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 +2 -2
- package/es/components/HDLKiosk/slices/primaryProductPrompt/view.js +2 -2
- package/es/components/HDLKiosk/{runtime → ui}/HDLKioskWorkflowView.js +45 -131
- 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 +7 -7
- 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/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/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 +11 -13
- 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 +105 -101
- package/lib/components/HDLKiosk/docs/03-/344/270/232/345/212/241/346/265/201/347/250/213/344/270/216/344/272/244/344/272/222/350/247/204/345/210/231.md +2 -2
- 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/07-/345/220/216/347/273/255/345/267/245/344/275/234.md +1 -1
- 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 +14 -13
- 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 +51 -22
- package/lib/components/HDLKiosk/kernel/workflow/compiler.js +23 -30
- 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 +38 -39
- 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/Screen/index.js +2 -2
- 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 +2 -2
- package/lib/components/HDLKiosk/slices/primaryProductPrompt/view.js +2 -2
- package/lib/components/HDLKiosk/{runtime → ui}/HDLKioskWorkflowView.js +46 -132
- 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 +7 -7
- 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 +2 -2
- 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/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,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 };
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { _asyncToGenerator } from "../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
|
|
2
|
-
import { createOperationError, operationFailed, operationUnknown } from "../../app/operations/errors.js";
|
|
3
|
-
import { defineOperation } from "../../app/operations/types.js";
|
|
4
|
-
//#region src/components/HDLKiosk/slices/identity/operation.ts
|
|
5
|
-
function partialFailure(code, cause) {
|
|
6
|
-
return {
|
|
7
|
-
status: "partialFailure",
|
|
8
|
-
error: createOperationError(code, "staff", cause)
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
function identityMatches(customerId, customer) {
|
|
12
|
-
if (!customerId) return (customer === null || customer === void 0 ? void 0 : customer.member) !== true;
|
|
13
|
-
if ((customer === null || customer === void 0 ? void 0 : customer.member) !== true) return false;
|
|
14
|
-
return customer.customerId === customerId;
|
|
15
|
-
}
|
|
16
|
-
const identitySyncOperation = defineOperation({
|
|
17
|
-
id: "identity.sync",
|
|
18
|
-
conflictScope: "customer",
|
|
19
|
-
timeoutMs: 15e3,
|
|
20
|
-
retry: "explicit-user",
|
|
21
|
-
execute: function() {
|
|
22
|
-
var _ref = _asyncToGenerator(function* (context, input, signal) {
|
|
23
|
-
var _input$customerId;
|
|
24
|
-
if (!input || input.customerId !== void 0 && !input.customerId.trim()) return operationFailed("identityInputInvalid", "back");
|
|
25
|
-
const customerId = (_input$customerId = input.customerId) === null || _input$customerId === void 0 ? void 0 : _input$customerId.trim();
|
|
26
|
-
const beforeSelection = context.host.sales.getObservedSnapshot();
|
|
27
|
-
const selected = yield context.host.sales.selectIdentity(customerId ? { customerId } : {}, signal);
|
|
28
|
-
if (selected.status !== "succeeded") return selected;
|
|
29
|
-
if (signal.aborted) return operationUnknown("identityAbortedAfterWrite");
|
|
30
|
-
const afterSelection = context.host.sales.getObservedSnapshot();
|
|
31
|
-
const hasOrderLines = beforeSelection.cart.lineCount > 0 || afterSelection.cart.lineCount > 0;
|
|
32
|
-
let summaryConfirmed = false;
|
|
33
|
-
if (hasOrderLines) {
|
|
34
|
-
const consistency = yield context.host.sales.waitForCartConsistency(signal);
|
|
35
|
-
if (consistency.status !== "succeeded") {
|
|
36
|
-
if (consistency.status === "unknown") return consistency;
|
|
37
|
-
return partialFailure("identityConsistencyFailed", consistency);
|
|
38
|
-
}
|
|
39
|
-
const summary = yield context.host.sales.recalculateSummary(signal);
|
|
40
|
-
if (summary.status !== "succeeded") {
|
|
41
|
-
if (summary.status === "unknown") return summary;
|
|
42
|
-
return partialFailure("identitySummaryRecalculationFailed", summary);
|
|
43
|
-
}
|
|
44
|
-
summaryConfirmed = Boolean(summary.data.confirmedSummary);
|
|
45
|
-
}
|
|
46
|
-
const observed = context.host.sales.getObservedSnapshot();
|
|
47
|
-
if (hasOrderLines && !summaryConfirmed && observed.summary.status !== "ready") return partialFailure("identitySummaryProjectionMissing");
|
|
48
|
-
if (!(customerId ? identityMatches(customerId, selected.data.customer) : selected.data.customer === void 0) && !identityMatches(customerId, observed.customer)) return operationUnknown("identitySelectionNotObserved");
|
|
49
|
-
return {
|
|
50
|
-
status: "succeeded",
|
|
51
|
-
data: void 0
|
|
52
|
-
};
|
|
53
|
-
});
|
|
54
|
-
return function execute(_x, _x2, _x3) {
|
|
55
|
-
return _ref.apply(this, arguments);
|
|
56
|
-
};
|
|
57
|
-
}()
|
|
58
|
-
});
|
|
59
|
-
//#endregion
|
|
60
|
-
export { identitySyncOperation };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const require_asyncToGenerator = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
|
|
2
|
-
const require_cartConsistency = require("./cartConsistency.js");
|
|
3
|
-
//#region src/components/HDLKiosk/app/operations/barcode.ts
|
|
4
|
-
const barcodeConsumeOperation = require("./types.js").defineOperation({
|
|
5
|
-
id: "barcode.consume",
|
|
6
|
-
conflictScope: "cart",
|
|
7
|
-
retry: "explicit-user",
|
|
8
|
-
execute: function() {
|
|
9
|
-
var _ref = require_asyncToGenerator._asyncToGenerator(function* (context, input, signal) {
|
|
10
|
-
const beforeFingerprint = context.host.sales.getObservedSnapshot().fingerprint.value;
|
|
11
|
-
const mutation = yield context.host.sales.consumeBarcode(input.code, signal);
|
|
12
|
-
if (mutation.status === "succeeded" && mutation.data.code === "requiresSelection") return mutation;
|
|
13
|
-
return require_cartConsistency.finalizeCartMutation(context, mutation, signal, () => mutation.status === "succeeded" && mutation.data.code === "added" && mutation.data.cartChangeConfirmed === true || context.host.sales.getObservedSnapshot().fingerprint.value !== beforeFingerprint);
|
|
14
|
-
});
|
|
15
|
-
return function execute(_x, _x2, _x3) {
|
|
16
|
-
return _ref.apply(this, arguments);
|
|
17
|
-
};
|
|
18
|
-
}()
|
|
19
|
-
});
|
|
20
|
-
//#endregion
|
|
21
|
-
exports.barcodeConsumeOperation = barcodeConsumeOperation;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
const require_asyncToGenerator = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
|
|
2
|
-
const require_cartConsistency = require("./cartConsistency.js");
|
|
3
|
-
const require_types = require("./types.js");
|
|
4
|
-
//#region src/components/HDLKiosk/app/operations/cart.ts
|
|
5
|
-
const cartAddProductOperation = require_types.defineOperation({
|
|
6
|
-
id: "cart.addProduct",
|
|
7
|
-
conflictScope: "cart",
|
|
8
|
-
retry: "explicit-user",
|
|
9
|
-
execute: function() {
|
|
10
|
-
var _ref = require_asyncToGenerator._asyncToGenerator(function* (context, input, signal) {
|
|
11
|
-
return require_cartConsistency.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 = require_types.defineOperation({
|
|
19
|
-
id: "cart.updateQuantity",
|
|
20
|
-
conflictScope: "cart",
|
|
21
|
-
timeoutMs: 15e3,
|
|
22
|
-
retry: "explicit-user",
|
|
23
|
-
execute: function() {
|
|
24
|
-
var _ref2 = require_asyncToGenerator._asyncToGenerator(function* (context, input, signal) {
|
|
25
|
-
const mutation = yield context.host.sales.updateQuantity(input, signal);
|
|
26
|
-
return require_cartConsistency.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 = require_types.defineOperation({
|
|
45
|
-
id: "cart.removeLine",
|
|
46
|
-
conflictScope: "cart",
|
|
47
|
-
timeoutMs: 15e3,
|
|
48
|
-
retry: "explicit-user",
|
|
49
|
-
execute: function() {
|
|
50
|
-
var _ref3 = require_asyncToGenerator._asyncToGenerator(function* (context, input, signal) {
|
|
51
|
-
const mutation = yield context.host.sales.removeLine(input, signal);
|
|
52
|
-
return require_cartConsistency.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
|
-
exports.cartAddProductOperation = cartAddProductOperation;
|
|
61
|
-
exports.cartRemoveLineOperation = cartRemoveLineOperation;
|
|
62
|
-
exports.cartUpdateQuantityOperation = cartUpdateQuantityOperation;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
//#region src/components/HDLKiosk/app/operations/fulfillment.ts
|
|
2
|
-
const setFulfillmentOperation = require("./types.js").defineOperation({
|
|
3
|
-
id: "fulfillment.set",
|
|
4
|
-
conflictScope: "cart",
|
|
5
|
-
timeoutMs: 2e4,
|
|
6
|
-
retry: "explicit-user",
|
|
7
|
-
execute: (context, input, signal) => context.host.sales.setFulfillment(input, signal)
|
|
8
|
-
});
|
|
9
|
-
//#endregion
|
|
10
|
-
exports.setFulfillmentOperation = setFulfillmentOperation;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
const require_asyncToGenerator = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
|
|
2
|
-
const require_errors = require("./errors.js");
|
|
3
|
-
const require_types = require("./types.js");
|
|
4
|
-
//#region src/components/HDLKiosk/app/operations/session.ts
|
|
5
|
-
function forwardFailure(result) {
|
|
6
|
-
return result;
|
|
7
|
-
}
|
|
8
|
-
const sessionEnsureOperation = require_types.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 = require_types.defineOperation({
|
|
16
|
-
id: "session.reset",
|
|
17
|
-
tags: ["session-reset"],
|
|
18
|
-
conflictScope: "session",
|
|
19
|
-
timeoutMs: 15e3,
|
|
20
|
-
retry: "never",
|
|
21
|
-
execute: function() {
|
|
22
|
-
var _ref = require_asyncToGenerator._asyncToGenerator(function* ({ host }, _input, signal) {
|
|
23
|
-
const before = host.sales.getObservedSnapshot();
|
|
24
|
-
if (before.payment.status === "pending" || before.payment.status === "unknown") return require_errors.operationUnknown("resetBlockedByPaymentState");
|
|
25
|
-
const reset = yield host.sales.clearAndReset(signal);
|
|
26
|
-
if (reset.status !== "succeeded") return forwardFailure(reset);
|
|
27
|
-
if (!reset.data.cartEmpty) return require_errors.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
|
-
exports.sessionEnsureOperation = sessionEnsureOperation;
|
|
42
|
-
exports.sessionResetOperation = sessionResetOperation;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const require_registry = require("../../kernel/operations/registry.js");
|
|
2
|
-
const require_types = require("../../kernel/operations/types.js");
|
|
3
|
-
//#region src/components/HDLKiosk/app/operations/types.ts
|
|
4
|
-
function defineOperation(operation) {
|
|
5
|
-
return require_types.defineKernelOperation(operation);
|
|
6
|
-
}
|
|
7
|
-
function createOperationRegistry(operations) {
|
|
8
|
-
return require_registry.createKernelOperationRegistry(operations);
|
|
9
|
-
}
|
|
10
|
-
//#endregion
|
|
11
|
-
exports.createOperationRegistry = createOperationRegistry;
|
|
12
|
-
exports.defineOperation = 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
|
-
exports.createEntryArbiter = createEntryArbiter;
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
require("../../../../_virtual/_rolldown/runtime.js");
|
|
2
|
-
const require_asyncToGenerator = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
|
|
3
|
-
let react = require("react");
|
|
4
|
-
//#region src/components/HDLKiosk/runtime/controllers/useHDLKioskDeviceController.ts
|
|
5
|
-
/**
|
|
6
|
-
* 文件角色:连接 Scale Port、入口 Ingress 与会话启动器。
|
|
7
|
-
* 运行机制:Entry 可见时消费称重边沿并请求 Scale Session;持续读数由 Scale Runtime 管理。
|
|
8
|
-
* 边界:Scanner 由独立的 Session 级 Scanner Controller 持有。
|
|
9
|
-
*/
|
|
10
|
-
function useHDLKioskDeviceController({ host, config, isActive, starting, session, sessionRef, activeRef, scaleIngress, start }) {
|
|
11
|
-
const [scaleConnectionState, setScaleConnectionState] = (0, react.useState)();
|
|
12
|
-
const rejectionSequence = (0, react.useRef)(0);
|
|
13
|
-
const scaleAvailable = host.capabilities.scale.available;
|
|
14
|
-
const scaleWeightChangeTrigger = host.capabilities.scale.weightChangeTrigger;
|
|
15
|
-
(0, react.useEffect)(() => {
|
|
16
|
-
setScaleConnectionState(void 0);
|
|
17
|
-
}, [host]);
|
|
18
|
-
const rejectDeviceEvent = (0, react.useCallback)((event, reason) => {
|
|
19
|
-
rejectionSequence.current += 1;
|
|
20
|
-
try {
|
|
21
|
-
host.telemetry.emit({
|
|
22
|
-
name: "hdlKiosk.device.eventRejected",
|
|
23
|
-
traceId: `hdl-device-rejected-${rejectionSequence.current}`,
|
|
24
|
-
occurredAt: Date.now(),
|
|
25
|
-
attributes: {
|
|
26
|
-
eventType: event.type,
|
|
27
|
-
reason
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
} catch (_unused) {}
|
|
31
|
-
}, [host]);
|
|
32
|
-
(0, react.useEffect)(() => {
|
|
33
|
-
const primaryWeightedProductId = config.primaryWeightedProductId;
|
|
34
|
-
if (!isActive || starting || !primaryWeightedProductId) return;
|
|
35
|
-
if (session) return void 0;
|
|
36
|
-
return host.devices.subscribe((event) => {
|
|
37
|
-
if (!activeRef.current) return;
|
|
38
|
-
if (event.type === "connectionChanged" && event.device === "scale") {
|
|
39
|
-
var _event$state;
|
|
40
|
-
setScaleConnectionState((_event$state = event.state) !== null && _event$state !== void 0 ? _event$state : event.connected ? "connected" : "disconnected");
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
if (event.type !== "weightChanged") return;
|
|
44
|
-
const activeSession = sessionRef.current;
|
|
45
|
-
const result = scaleIngress.accept(event, {
|
|
46
|
-
active: activeRef.current,
|
|
47
|
-
supported: scaleAvailable && scaleWeightChangeTrigger && config.enabledEntries.includes("scale"),
|
|
48
|
-
workflowLocked: Boolean(activeSession),
|
|
49
|
-
nodeAcceptsEvent: !activeSession,
|
|
50
|
-
paymentFrozen: false
|
|
51
|
-
});
|
|
52
|
-
if (result.status === "rejected") {
|
|
53
|
-
rejectDeviceEvent(event, result.reason);
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
require_asyncToGenerator._asyncToGenerator(function* () {
|
|
57
|
-
if (!(yield start({ entry: "scale" }))) rejectDeviceEvent(event, "sessionStartFailed");
|
|
58
|
-
})();
|
|
59
|
-
}, { sources: ["scale"] });
|
|
60
|
-
}, [
|
|
61
|
-
config.enabledEntries,
|
|
62
|
-
config.primaryWeightedProductId,
|
|
63
|
-
host,
|
|
64
|
-
isActive,
|
|
65
|
-
rejectDeviceEvent,
|
|
66
|
-
scaleAvailable,
|
|
67
|
-
scaleIngress,
|
|
68
|
-
scaleWeightChangeTrigger,
|
|
69
|
-
session,
|
|
70
|
-
start,
|
|
71
|
-
starting
|
|
72
|
-
]);
|
|
73
|
-
return { scaleConnectionState };
|
|
74
|
-
}
|
|
75
|
-
//#endregion
|
|
76
|
-
exports.useHDLKioskDeviceController = useHDLKioskDeviceController;
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
require("../../../../_virtual/_rolldown/runtime.js");
|
|
2
|
-
const require_asyncToGenerator = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
|
|
3
|
-
let react = require("react");
|
|
4
|
-
//#region src/components/HDLKiosk/runtime/controllers/useHDLKioskScannerController.ts
|
|
5
|
-
/**
|
|
6
|
-
* 文件角色:在 HDLKiosk active 生命周期内唯一拥有 Scanner,并把扫码任务归属到 Session。
|
|
7
|
-
* 运行机制:Ingress 去重/背压后进入有限 FIFO;Session readyForCommands 后串行消费。
|
|
8
|
-
* 边界:不依赖任何 Screen mount,不负责 Workflow 导航,也不记录原始条码。
|
|
9
|
-
*/
|
|
10
|
-
const NON_WRITABLE_ACTIVITIES = new Set(["paymentCompleted"]);
|
|
11
|
-
const PAYMENT_OPERATION_IDS = new Set([
|
|
12
|
-
"checkout.open",
|
|
13
|
-
"checkout.payEftpos",
|
|
14
|
-
"checkout.requestStaffPaymentApproval",
|
|
15
|
-
"session.reset"
|
|
16
|
-
]);
|
|
17
|
-
function isPaymentFrozen(host) {
|
|
18
|
-
const status = host.sales.getObservedSnapshot().payment.status;
|
|
19
|
-
return status === "pending" || status === "unknown" || status === "succeeded";
|
|
20
|
-
}
|
|
21
|
-
function isHDLKioskSessionCartWritable(session) {
|
|
22
|
-
var _session$definition$n;
|
|
23
|
-
const snapshot = session.actor.getSnapshot();
|
|
24
|
-
if (snapshot.status === "blocked" || snapshot.status === "finished") return false;
|
|
25
|
-
const activity = (_session$definition$n = session.definition.nodes[snapshot.nodeId]) === null || _session$definition$n === void 0 ? void 0 : _session$definition$n.activity;
|
|
26
|
-
if (!activity || NON_WRITABLE_ACTIVITIES.has(activity)) return false;
|
|
27
|
-
return !(snapshot.activeOperation && PAYMENT_OPERATION_IDS.has(snapshot.activeOperation.definitionId));
|
|
28
|
-
}
|
|
29
|
-
function useHDLKioskScannerController({ host, config, isActive, starting, sessionRef, activeRef, scannerIngress, start, waitForReadySession }) {
|
|
30
|
-
const queueRef = (0, react.useRef)([]);
|
|
31
|
-
const startingRef = (0, react.useRef)(starting);
|
|
32
|
-
const processingRef = (0, react.useRef)(false);
|
|
33
|
-
const currentTaskRef = (0, react.useRef)();
|
|
34
|
-
const generationRef = (0, react.useRef)(0);
|
|
35
|
-
const rejectionSequence = (0, react.useRef)(0);
|
|
36
|
-
const scannerAvailable = host.capabilities.scanner.available;
|
|
37
|
-
startingRef.current = starting;
|
|
38
|
-
const emitRejected = (0, react.useCallback)((event, reason) => {
|
|
39
|
-
rejectionSequence.current += 1;
|
|
40
|
-
try {
|
|
41
|
-
host.telemetry.emit({
|
|
42
|
-
name: "hdlKiosk.device.eventRejected",
|
|
43
|
-
traceId: `hdl-scanner-rejected-${rejectionSequence.current}`,
|
|
44
|
-
occurredAt: Date.now(),
|
|
45
|
-
attributes: {
|
|
46
|
-
eventType: event.type,
|
|
47
|
-
reason
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
} catch (_unused) {}
|
|
51
|
-
}, [host]);
|
|
52
|
-
const emitCompleted = (0, react.useCallback)((task, target, result) => {
|
|
53
|
-
try {
|
|
54
|
-
host.telemetry.emit({
|
|
55
|
-
name: "hdlKiosk.scanner.taskFinished",
|
|
56
|
-
traceId: `hdl-scan:${target.actor.getSnapshot().sessionEpoch}:${task.event.eventId}`,
|
|
57
|
-
occurredAt: Date.now(),
|
|
58
|
-
attributes: {
|
|
59
|
-
eventId: task.event.eventId,
|
|
60
|
-
sessionEpoch: target.actor.getSnapshot().sessionEpoch,
|
|
61
|
-
status: result.status
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
} catch (_unused2) {}
|
|
65
|
-
}, [host]);
|
|
66
|
-
const processQueue = (0, react.useCallback)(require_asyncToGenerator._asyncToGenerator(function* () {
|
|
67
|
-
if (processingRef.current) return;
|
|
68
|
-
processingRef.current = true;
|
|
69
|
-
const generation = generationRef.current;
|
|
70
|
-
try {
|
|
71
|
-
while (activeRef.current && generation === generationRef.current && queueRef.current.length > 0) {
|
|
72
|
-
var _sessionRef$current;
|
|
73
|
-
const nextTask = queueRef.current[0];
|
|
74
|
-
if (!nextTask) continue;
|
|
75
|
-
let target = (_sessionRef$current = sessionRef.current) !== null && _sessionRef$current !== void 0 ? _sessionRef$current : yield waitForReadySession();
|
|
76
|
-
if (!target && nextTask.binding === "startBarcodeSession") target = yield start({ entry: "barcode" });
|
|
77
|
-
if (!target || nextTask.acceptedSessionEpoch !== void 0 && target.actor.getSnapshot().sessionEpoch !== nextTask.acceptedSessionEpoch || generation !== generationRef.current || !activeRef.current) {
|
|
78
|
-
const rejected = queueRef.current.shift();
|
|
79
|
-
if (rejected) emitRejected(rejected.event, "sessionStartFailed");
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
|
-
if (isPaymentFrozen(host) || !isHDLKioskSessionCartWritable(target)) {
|
|
83
|
-
const rejected = queueRef.current.shift();
|
|
84
|
-
if (rejected) emitRejected(rejected.event, "sessionNotCartWritable");
|
|
85
|
-
continue;
|
|
86
|
-
}
|
|
87
|
-
const pendingNavigation = target.actor.getSnapshot().pendingNavigation;
|
|
88
|
-
if (pendingNavigation) target.actor.resolvePendingNavigation(pendingNavigation.navigationId, "cancel");
|
|
89
|
-
const task = queueRef.current.shift();
|
|
90
|
-
if (!task) continue;
|
|
91
|
-
currentTaskRef.current = task;
|
|
92
|
-
const sessionEpoch = target.actor.getSnapshot().sessionEpoch;
|
|
93
|
-
const result = yield target.executeCommand("barcode.consume", { code: task.code }, `scan:${sessionEpoch}:${task.event.eventId}`);
|
|
94
|
-
currentTaskRef.current = void 0;
|
|
95
|
-
emitCompleted(task, target, result);
|
|
96
|
-
if (result.status === "partialFailure" || result.status === "unknown") queueRef.current = [];
|
|
97
|
-
}
|
|
98
|
-
} finally {
|
|
99
|
-
currentTaskRef.current = void 0;
|
|
100
|
-
processingRef.current = false;
|
|
101
|
-
}
|
|
102
|
-
}), [
|
|
103
|
-
activeRef,
|
|
104
|
-
emitCompleted,
|
|
105
|
-
emitRejected,
|
|
106
|
-
waitForReadySession,
|
|
107
|
-
host,
|
|
108
|
-
sessionRef,
|
|
109
|
-
start
|
|
110
|
-
]);
|
|
111
|
-
(0, react.useEffect)(() => {
|
|
112
|
-
if (!isActive || !scannerAvailable) return void 0;
|
|
113
|
-
return host.devices.subscribe((event) => {
|
|
114
|
-
if (!activeRef.current || event.type !== "barcode") return;
|
|
115
|
-
const activeSession = sessionRef.current;
|
|
116
|
-
const canStartBarcode = config.enabledEntries.includes("barcode");
|
|
117
|
-
const supported = Boolean(activeSession || startingRef.current || canStartBarcode);
|
|
118
|
-
const cartWritable = activeSession ? isHDLKioskSessionCartWritable(activeSession) : true;
|
|
119
|
-
const result = scannerIngress.accept(event, {
|
|
120
|
-
active: activeRef.current,
|
|
121
|
-
supported,
|
|
122
|
-
workflowLocked: false,
|
|
123
|
-
nodeAcceptsEvent: cartWritable,
|
|
124
|
-
paymentFrozen: isPaymentFrozen(host),
|
|
125
|
-
pendingEventCount: queueRef.current.length + (currentTaskRef.current ? 1 : 0)
|
|
126
|
-
});
|
|
127
|
-
if (result.status === "rejected") {
|
|
128
|
-
emitRejected(event, result.reason);
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
queueRef.current.push({
|
|
132
|
-
event: result.event,
|
|
133
|
-
code: result.code,
|
|
134
|
-
binding: activeSession || startingRef.current ? "existingOrPendingSession" : "startBarcodeSession",
|
|
135
|
-
acceptedSessionEpoch: activeSession === null || activeSession === void 0 ? void 0 : activeSession.actor.getSnapshot().sessionEpoch
|
|
136
|
-
});
|
|
137
|
-
processQueue();
|
|
138
|
-
}, { sources: ["scanner"] });
|
|
139
|
-
}, [
|
|
140
|
-
activeRef,
|
|
141
|
-
config.enabledEntries,
|
|
142
|
-
emitRejected,
|
|
143
|
-
host,
|
|
144
|
-
isActive,
|
|
145
|
-
processQueue,
|
|
146
|
-
scannerAvailable,
|
|
147
|
-
scannerIngress,
|
|
148
|
-
sessionRef
|
|
149
|
-
]);
|
|
150
|
-
(0, react.useEffect)(() => {
|
|
151
|
-
if (isActive) return;
|
|
152
|
-
generationRef.current += 1;
|
|
153
|
-
queueRef.current = [];
|
|
154
|
-
}, [isActive]);
|
|
155
|
-
(0, react.useEffect)(() => () => {
|
|
156
|
-
generationRef.current += 1;
|
|
157
|
-
queueRef.current = [];
|
|
158
|
-
}, [host]);
|
|
159
|
-
}
|
|
160
|
-
//#endregion
|
|
161
|
-
exports.useHDLKioskScannerController = useHDLKioskScannerController;
|