@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
|
@@ -8,13 +8,12 @@ function createWorkflowError(code, recovery, cause) {
|
|
|
8
8
|
code,
|
|
9
9
|
source: "workflow",
|
|
10
10
|
recovery,
|
|
11
|
-
safeMessageKey: `
|
|
12
|
-
traceId: `
|
|
11
|
+
safeMessageKey: `workflow.error.${code}`,
|
|
12
|
+
traceId: `workflow-${Date.now()}-${workflowErrorSequence}`,
|
|
13
13
|
cause
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
function createWorkflowActor({ definition, context, sessionEpoch, transitionRunner, lifecycle, reduceContext, beforeEach, now = Date.now, initialNodeId, initialError }) {
|
|
17
|
-
var _ref2;
|
|
18
17
|
const listeners = /* @__PURE__ */ new Set();
|
|
19
18
|
const mailbox = [];
|
|
20
19
|
let executionSequence = 0;
|
|
@@ -50,7 +49,7 @@ function createWorkflowActor({ definition, context, sessionEpoch, transitionRunn
|
|
|
50
49
|
visited.add(stepId);
|
|
51
50
|
const node = definition.nodes[stepId];
|
|
52
51
|
const storedResolution = stepResolutions.get(stepId);
|
|
53
|
-
if (!node || !storedResolution ||
|
|
52
|
+
if (!node || !storedResolution || storedResolution !== "omit" && node.visitPolicy !== "once") return stepId;
|
|
54
53
|
const transition = node.on[storedResolution];
|
|
55
54
|
if (!transition) return stepId;
|
|
56
55
|
stepId = transition.target;
|
|
@@ -116,7 +115,16 @@ function createWorkflowActor({ definition, context, sessionEpoch, transitionRunn
|
|
|
116
115
|
const direction = !fromNodeId ? "initial" : delta < 0 ? "backward" : "forward";
|
|
117
116
|
for (let candidateIndex = targetIndex; candidateIndex >= 0 && candidateIndex < definition.stepOrder.length; candidateIndex += delta) {
|
|
118
117
|
const candidateStepId = definition.stepOrder[candidateIndex];
|
|
119
|
-
|
|
118
|
+
const candidateNode = definition.nodes[candidateStepId];
|
|
119
|
+
if (candidateNode.presentation.mode === "modal") {
|
|
120
|
+
const fromNode = fromNodeId ? definition.nodes[fromNodeId] : void 0;
|
|
121
|
+
if (!fromNode || fromNode.presentation.mode === "modal") return {
|
|
122
|
+
type: "block",
|
|
123
|
+
error: createWorkflowError(fromNode ? "workflowNestedModalUnsupported" : "workflowModalRequiresPage", "staff")
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
const candidateResolution = stepResolutions.get(candidateStepId);
|
|
127
|
+
if (candidateResolution === "omit" || candidateNode.visitPolicy === "once" && candidateResolution) continue;
|
|
120
128
|
const decision = beforeEach({
|
|
121
129
|
navigationId,
|
|
122
130
|
intentId,
|
|
@@ -172,40 +180,56 @@ function createWorkflowActor({ definition, context, sessionEpoch, transitionRunn
|
|
|
172
180
|
sessionEpoch,
|
|
173
181
|
workflowId: definition.id,
|
|
174
182
|
nodeId: startingNodeId,
|
|
175
|
-
status: initialError || initialResolutionError
|
|
183
|
+
status: initialError || initialResolutionError ? "blocked" : startingNode.isTerminal ? "finished" : "idle",
|
|
176
184
|
context: Object.freeze(require_objectSpread2._objectSpread2({}, context)),
|
|
177
185
|
completedStepIds: Object.freeze([]),
|
|
178
186
|
stepResolutions: Object.freeze({}),
|
|
187
|
+
surface: Object.freeze({
|
|
188
|
+
pageStepId: startingNodeId,
|
|
189
|
+
overlays: Object.freeze([])
|
|
190
|
+
}),
|
|
179
191
|
navigationHistory: Object.freeze([]),
|
|
180
|
-
lastError:
|
|
192
|
+
lastError: initialError !== null && initialError !== void 0 ? initialError : initialResolutionError
|
|
181
193
|
});
|
|
182
194
|
const publish = (next) => {
|
|
183
195
|
snapshot = Object.freeze(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, next), {}, {
|
|
184
196
|
context: Object.freeze(require_objectSpread2._objectSpread2({}, next.context)),
|
|
185
197
|
completedStepIds: Object.freeze([...next.completedStepIds]),
|
|
186
198
|
stepResolutions: Object.freeze(require_objectSpread2._objectSpread2({}, next.stepResolutions)),
|
|
199
|
+
surface: Object.freeze({
|
|
200
|
+
pageStepId: next.surface.pageStepId,
|
|
201
|
+
overlays: Object.freeze([...next.surface.overlays])
|
|
202
|
+
}),
|
|
187
203
|
navigationHistory: Object.freeze([...next.navigationHistory]),
|
|
188
204
|
pendingNavigation: next.pendingNavigation ? Object.freeze(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, next.pendingNavigation), {}, {
|
|
189
205
|
to: Object.freeze(require_objectSpread2._objectSpread2({}, next.pendingNavigation.to)),
|
|
190
206
|
request: Object.freeze(require_objectSpread2._objectSpread2({}, next.pendingNavigation.request))
|
|
191
207
|
})) : void 0,
|
|
192
|
-
|
|
208
|
+
receipt: next.receipt,
|
|
193
209
|
activeOperation: next.activeOperation ? Object.freeze(require_objectSpread2._objectSpread2({}, next.activeOperation)) : void 0
|
|
194
210
|
}));
|
|
195
211
|
listeners.forEach((listener) => listener());
|
|
196
212
|
};
|
|
197
213
|
const commit = function() {
|
|
198
|
-
var
|
|
214
|
+
var _ref2 = require_asyncToGenerator._asyncToGenerator(function* (fromNodeId, nodeId, event, nextContext, blocked, lastError, receipt) {
|
|
199
215
|
const node = definition.nodes[nodeId];
|
|
216
|
+
const surface = node.presentation.mode === "modal" ? Object.freeze({
|
|
217
|
+
pageStepId: snapshot.surface.pageStepId,
|
|
218
|
+
overlays: Object.freeze([nodeId])
|
|
219
|
+
}) : Object.freeze({
|
|
220
|
+
pageStepId: nodeId,
|
|
221
|
+
overlays: Object.freeze([])
|
|
222
|
+
});
|
|
200
223
|
publish(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, snapshot), {}, {
|
|
201
224
|
nodeId,
|
|
202
|
-
status: blocked
|
|
225
|
+
status: blocked ? "blocked" : node.isTerminal ? "finished" : "idle",
|
|
203
226
|
context: nextContext,
|
|
204
227
|
completedStepIds: Object.freeze([...completedStepIds]),
|
|
205
228
|
stepResolutions: Object.freeze(readStepResolutions()),
|
|
229
|
+
surface,
|
|
206
230
|
navigationHistory: Object.freeze([...navigationHistory]),
|
|
207
231
|
pendingNavigation: void 0,
|
|
208
|
-
|
|
232
|
+
receipt: receipt !== null && receipt !== void 0 ? receipt : snapshot.receipt,
|
|
209
233
|
activeOperation: void 0,
|
|
210
234
|
lastError
|
|
211
235
|
}));
|
|
@@ -216,11 +240,11 @@ function createWorkflowActor({ definition, context, sessionEpoch, transitionRunn
|
|
|
216
240
|
});
|
|
217
241
|
});
|
|
218
242
|
return function commit(_x, _x2, _x3, _x4, _x5, _x6, _x7) {
|
|
219
|
-
return
|
|
243
|
+
return _ref2.apply(this, arguments);
|
|
220
244
|
};
|
|
221
245
|
}();
|
|
222
246
|
const blockForRuntimeError = function() {
|
|
223
|
-
var
|
|
247
|
+
var _ref3 = require_asyncToGenerator._asyncToGenerator(function* (fromNodeId, event, code, cause) {
|
|
224
248
|
const workflowError = createWorkflowError(code, "staff", cause);
|
|
225
249
|
lifecycle.runtimeError({
|
|
226
250
|
stepId: fromNodeId,
|
|
@@ -230,11 +254,11 @@ function createWorkflowActor({ definition, context, sessionEpoch, transitionRunn
|
|
|
230
254
|
yield commit(fromNodeId, fromNodeId, event, snapshot.context, true, workflowError);
|
|
231
255
|
});
|
|
232
256
|
return function blockForRuntimeError(_x8, _x9, _x10, _x11) {
|
|
233
|
-
return
|
|
257
|
+
return _ref3.apply(this, arguments);
|
|
234
258
|
};
|
|
235
259
|
}();
|
|
236
260
|
const handleEvent = function() {
|
|
237
|
-
var
|
|
261
|
+
var _ref4 = require_asyncToGenerator._asyncToGenerator(function* (event) {
|
|
238
262
|
var _repeatCounts$get, _transition$exitPolic;
|
|
239
263
|
if (disposed || snapshot.status === "finished" || snapshot.status === "blocked") return;
|
|
240
264
|
const fromNodeId = snapshot.nodeId;
|
|
@@ -357,8 +381,8 @@ function createWorkflowActor({ definition, context, sessionEpoch, transitionRunn
|
|
|
357
381
|
if (event.intent === "complete" && node.presentation.mode === "page" && movesForward && node.visitPolicy !== "once") {
|
|
358
382
|
navigationHistory = navigationHistory.filter((stepId) => stepId !== fromNodeId);
|
|
359
383
|
navigationHistory.push(fromNodeId);
|
|
360
|
-
} else if (event.intent === "
|
|
361
|
-
yield commit(fromNodeId, resolvedTarget, event, nextContext, false, void 0, result.
|
|
384
|
+
} else if (event.intent === "omit") navigationHistory = navigationHistory.filter((stepId) => stepId !== fromNodeId);
|
|
385
|
+
yield commit(fromNodeId, resolvedTarget, event, nextContext, false, void 0, result.receipt);
|
|
362
386
|
return;
|
|
363
387
|
}
|
|
364
388
|
if (result.status === "blocked") {
|
|
@@ -368,7 +392,7 @@ function createWorkflowActor({ definition, context, sessionEpoch, transitionRunn
|
|
|
368
392
|
yield commit(fromNodeId, fromNodeId, event, previousContext, false, result.lastError);
|
|
369
393
|
});
|
|
370
394
|
return function handleEvent(_x12) {
|
|
371
|
-
return
|
|
395
|
+
return _ref4.apply(this, arguments);
|
|
372
396
|
};
|
|
373
397
|
}();
|
|
374
398
|
function handleDirectNavigation(_x13, _x14) {
|
|
@@ -411,8 +435,13 @@ function createWorkflowActor({ definition, context, sessionEpoch, transitionRunn
|
|
|
411
435
|
if (resolution.type === "step") {
|
|
412
436
|
const fromIndex = definition.stepOrder.indexOf(fromNodeId);
|
|
413
437
|
if (definition.stepOrder.indexOf(resolution.stepId) < fromIndex) stepResolutions.delete(fromNodeId);
|
|
414
|
-
|
|
415
|
-
|
|
438
|
+
if (definition.nodes[resolution.stepId].presentation.mode === "modal" && definition.nodes[fromNodeId].presentation.mode === "page") {
|
|
439
|
+
navigationHistory = navigationHistory.filter((stepId) => stepId !== fromNodeId);
|
|
440
|
+
navigationHistory.push(fromNodeId);
|
|
441
|
+
} else {
|
|
442
|
+
const historyIndex = navigationHistory.lastIndexOf(resolution.stepId);
|
|
443
|
+
if (historyIndex >= 0) navigationHistory = navigationHistory.slice(0, historyIndex);
|
|
444
|
+
}
|
|
416
445
|
yield commit(fromNodeId, resolution.stepId, {
|
|
417
446
|
intentId,
|
|
418
447
|
intent: "directNavigation"
|
|
@@ -435,7 +464,7 @@ function createWorkflowActor({ definition, context, sessionEpoch, transitionRunn
|
|
|
435
464
|
return _handleDirectNavigation.apply(this, arguments);
|
|
436
465
|
}
|
|
437
466
|
const drain = function() {
|
|
438
|
-
var
|
|
467
|
+
var _ref5 = require_asyncToGenerator._asyncToGenerator(function* () {
|
|
439
468
|
if (processing || disposed) return;
|
|
440
469
|
processing = true;
|
|
441
470
|
try {
|
|
@@ -448,7 +477,7 @@ function createWorkflowActor({ definition, context, sessionEpoch, transitionRunn
|
|
|
448
477
|
}
|
|
449
478
|
});
|
|
450
479
|
return function drain() {
|
|
451
|
-
return
|
|
480
|
+
return _ref5.apply(this, arguments);
|
|
452
481
|
};
|
|
453
482
|
}();
|
|
454
483
|
return {
|
|
@@ -30,7 +30,7 @@ function resolveRepeat(value, path, issues) {
|
|
|
30
30
|
exceeded: "blocked"
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function canReachTerminal(initial, nodes) {
|
|
34
34
|
const visited = /* @__PURE__ */ new Set();
|
|
35
35
|
const pending = [initial];
|
|
36
36
|
while (pending.length > 0) {
|
|
@@ -39,7 +39,7 @@ function canReachSuccess(initial, nodes) {
|
|
|
39
39
|
visited.add(stepId);
|
|
40
40
|
const node = nodes[stepId];
|
|
41
41
|
if (!node) continue;
|
|
42
|
-
if (node.
|
|
42
|
+
if (node.isTerminal) return true;
|
|
43
43
|
Object.values(node.on).forEach((transition) => {
|
|
44
44
|
if (transition) pending.push(transition.target);
|
|
45
45
|
});
|
|
@@ -123,11 +123,11 @@ function compileWorkflowStructure(input, options) {
|
|
|
123
123
|
"visitPolicy",
|
|
124
124
|
"useGuards",
|
|
125
125
|
"on",
|
|
126
|
-
"
|
|
127
|
-
"
|
|
126
|
+
"isTerminal",
|
|
127
|
+
"surface"
|
|
128
128
|
], stepPath, issues);
|
|
129
|
-
if (rawStep.
|
|
130
|
-
if (rawStep.visitPolicy !== void 0 && rawStep.visitPolicy !== "always" && rawStep.visitPolicy !== "
|
|
129
|
+
if (rawStep.surface !== void 0) addIssue(issues, "step.surface.forbidden", `${stepPath}.surface`, "Surface is resolved by the local Activity Contract");
|
|
130
|
+
if (rawStep.visitPolicy !== void 0 && rawStep.visitPolicy !== "always" && rawStep.visitPolicy !== "once") addIssue(issues, "step.visitPolicy.invalid", `${stepPath}.visitPolicy`, "Step visitPolicy must be always or once");
|
|
131
131
|
const activityValue = rawStep.activity;
|
|
132
132
|
if (typeof activityValue !== "string" || !activities.has(activityValue)) addIssue(issues, "activity.unknown", `${stepPath}.activity`, `Unknown activity: ${String(activityValue)}`);
|
|
133
133
|
const fallbackActivityId = activities.ids[0];
|
|
@@ -161,18 +161,14 @@ function compileWorkflowStructure(input, options) {
|
|
|
161
161
|
const rawPresentation = rawStep.presentation;
|
|
162
162
|
let presentation = { mode: "page" };
|
|
163
163
|
if (rawPresentation !== void 0) {
|
|
164
|
-
if (isRecord(rawPresentation)) rejectUnknownFields(rawPresentation, ["mode"
|
|
164
|
+
if (isRecord(rawPresentation)) rejectUnknownFields(rawPresentation, ["mode"], `${stepPath}.presentation`, issues);
|
|
165
165
|
if (!isRecord(rawPresentation)) addIssue(issues, "step.presentation.invalid", `${stepPath}.presentation`, "Step presentation must be an object");
|
|
166
166
|
else if (rawPresentation.mode !== "page" && rawPresentation.mode !== "modal") addIssue(issues, "step.presentation.mode.invalid", `${stepPath}.presentation.mode`, "Presentation mode must be page or modal");
|
|
167
167
|
else if (!activity.allowedPresentations.includes(rawPresentation.mode)) addIssue(issues, "activity.presentation.unsupported", `${stepPath}.presentation.mode`, `Activity ${activity.id} does not support ${rawPresentation.mode}`);
|
|
168
|
-
else if (rawPresentation.mode === "modal")
|
|
169
|
-
else presentation = {
|
|
170
|
-
mode: "modal",
|
|
171
|
-
base: rawPresentation.base.trim()
|
|
172
|
-
};
|
|
168
|
+
else if (rawPresentation.mode === "modal") presentation = { mode: "modal" };
|
|
173
169
|
}
|
|
174
170
|
if (rawStep.readiness !== void 0 && rawStep.readiness !== "implemented" && rawStep.readiness !== "placeholder") addIssue(issues, "step.readiness.invalid", `${stepPath}.readiness`, "Step readiness must be implemented or placeholder");
|
|
175
|
-
if (rawStep.
|
|
171
|
+
if (rawStep.isTerminal !== void 0 && typeof rawStep.isTerminal !== "boolean") addIssue(issues, "step.isTerminal.invalid", `${stepPath}.isTerminal`, "Step isTerminal must be a boolean");
|
|
176
172
|
if (rawStep.on !== void 0 && !isRecord(rawStep.on)) addIssue(issues, "step.intents.invalid", `${stepPath}.on`, "Step intents must be an object");
|
|
177
173
|
const transitions = {};
|
|
178
174
|
const addTransition = (intent, rawTarget, path) => {
|
|
@@ -232,13 +228,13 @@ function compileWorkflowStructure(input, options) {
|
|
|
232
228
|
nodes[stepId] = Object.freeze({
|
|
233
229
|
id: stepId,
|
|
234
230
|
activity: activity.id,
|
|
235
|
-
|
|
231
|
+
surfaceId: activity.surfaceId,
|
|
236
232
|
presentation,
|
|
237
233
|
readiness: rawStep.readiness === "placeholder" ? "placeholder" : void 0,
|
|
238
|
-
visitPolicy: rawStep.visitPolicy === "
|
|
234
|
+
visitPolicy: rawStep.visitPolicy === "once" ? "once" : "always",
|
|
239
235
|
guardPhases: Object.freeze([...guardPhases]),
|
|
240
236
|
on: Object.freeze(transitions),
|
|
241
|
-
|
|
237
|
+
isTerminal: rawStep.isTerminal === true ? true : void 0
|
|
242
238
|
});
|
|
243
239
|
});
|
|
244
240
|
if (transitionCount > maxTransitions) addIssue(issues, "workflow.transitions.limit", "steps", `Workflow cannot contain more than ${maxTransitions} transitions`);
|
|
@@ -246,15 +242,14 @@ function compileWorkflowStructure(input, options) {
|
|
|
246
242
|
Object.entries(nodes).forEach(([stepId, node]) => {
|
|
247
243
|
var _stepIndex$get;
|
|
248
244
|
const path = `steps.${(_stepIndex$get = stepIndex.get(stepId)) !== null && _stepIndex$get !== void 0 ? _stepIndex$get : 0}`;
|
|
249
|
-
if (node.presentation.mode === "modal") {
|
|
250
|
-
const base = nodes[node.presentation.base];
|
|
251
|
-
if (!base) addIssue(issues, "step.presentation.base.missing", `${path}.presentation.base`, `Modal base step does not exist: ${node.presentation.base}`);
|
|
252
|
-
else if (node.presentation.base === stepId) addIssue(issues, "step.presentation.base.self", `${path}.presentation.base`, "Modal step cannot use itself as its base");
|
|
253
|
-
else if (base.presentation.mode === "modal") addIssue(issues, "step.presentation.base.modal", `${path}.presentation.base`, "Modal step cannot use another modal step as its base");
|
|
254
|
-
}
|
|
245
|
+
if (node.presentation.mode === "modal" && stepId === stepIds[0]) addIssue(issues, "workflow.initial.modal", `${path}.presentation.mode`, "Workflow initial step must provide a page surface");
|
|
255
246
|
const transitions = Object.entries(node.on).filter((entry) => entry[1]);
|
|
256
|
-
|
|
257
|
-
|
|
247
|
+
transitions.forEach(([intent, transition]) => {
|
|
248
|
+
var _nodes$transition$tar;
|
|
249
|
+
if (node.presentation.mode === "modal" && transition && ((_nodes$transition$tar = nodes[transition.target]) === null || _nodes$transition$tar === void 0 ? void 0 : _nodes$transition$tar.presentation.mode) === "modal") addIssue(issues, "transition.modal.nested", `${path}.on.${intent}`, "A modal step cannot navigate directly to another modal step");
|
|
250
|
+
});
|
|
251
|
+
if (!node.isTerminal && transitions.length === 0) addIssue(issues, "step.deadEnd", path, "A step without outgoing transitions must declare isTerminal: true");
|
|
252
|
+
if (node.isTerminal && transitions.length > 0) addIssue(issues, "step.isTerminal.hasTransitions", path, "A terminal step cannot expose outgoing transitions");
|
|
258
253
|
transitions.forEach(([intent, transition]) => {
|
|
259
254
|
var _stepIndex$get2, _stepIndex$get3;
|
|
260
255
|
if (!transition) return;
|
|
@@ -272,15 +267,14 @@ function compileWorkflowStructure(input, options) {
|
|
|
272
267
|
const reachable = initial ? reachableSteps(initial, nodes) : /* @__PURE__ */ new Set();
|
|
273
268
|
const unreachable = Object.keys(nodes).filter((stepId) => !reachable.has(stepId));
|
|
274
269
|
if (unreachable.length > 0) addIssue(issues, "workflow.steps.unreachable", "steps", `Every step must be reachable from the first step: ${unreachable.join(", ")}`);
|
|
275
|
-
if (initial && nodes[initial] && !
|
|
270
|
+
if (initial && nodes[initial] && !canReachTerminal(initial, nodes)) addIssue(issues, "workflow.terminal.unreachable", "steps", "The first step cannot reach a terminal step");
|
|
276
271
|
if (issues.length > 0) return {
|
|
277
272
|
status: "invalid",
|
|
278
273
|
issues: Object.freeze(issues)
|
|
279
274
|
};
|
|
280
275
|
const requirements = Object.freeze([...new Set(Object.values(nodes).flatMap((node) => {
|
|
281
|
-
var
|
|
282
|
-
|
|
283
|
-
return (_ref = (_activity$requirement = activity.requirements) !== null && _activity$requirement !== void 0 ? _activity$requirement : activity.checkoutRequirements) !== null && _ref !== void 0 ? _ref : [];
|
|
276
|
+
var _activity$requirement;
|
|
277
|
+
return (_activity$requirement = activities.require(node.activity).requirements) !== null && _activity$requirement !== void 0 ? _activity$requirement : [];
|
|
284
278
|
}))]);
|
|
285
279
|
return {
|
|
286
280
|
status: "valid",
|
|
@@ -289,8 +283,7 @@ function compileWorkflowStructure(input, options) {
|
|
|
289
283
|
initial,
|
|
290
284
|
stepOrder: Object.freeze([...stepIds]),
|
|
291
285
|
nodes: Object.freeze(nodes),
|
|
292
|
-
requirements
|
|
293
|
-
checkoutRequirements: requirements
|
|
286
|
+
requirements
|
|
294
287
|
})
|
|
295
288
|
};
|
|
296
289
|
}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
const require_objectSpread2 = require("../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
|
|
2
|
+
const require_asyncToGenerator = require("../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
|
|
3
|
+
const require_runtime = require("../kernel/application/runtime.js");
|
|
4
|
+
const require_manifest = require("../app/manifest.js");
|
|
5
|
+
const require_registry = require("../app/workflow/registry.js");
|
|
6
|
+
const require_triggers = require("./triggers.js");
|
|
7
|
+
const require_scannerSessionRouter = require("./devices/scannerSessionRouter.js");
|
|
8
|
+
const require_scannerSessionPort = require("./devices/scannerSessionPort.js");
|
|
9
|
+
const require_createSession = require("./session/createSession.js");
|
|
10
|
+
//#region src/components/HDLKiosk/runtime/createRuntime.ts
|
|
11
|
+
function resolveHDLKioskEntryCapabilityBlockReason({ entry, capabilities, primaryWeightedProductId }) {
|
|
12
|
+
if (!capabilities.session.ensure) return "sessionEnsureUnavailable";
|
|
13
|
+
if (entry === "barcode") return capabilities.scanner.available ? void 0 : "scannerUnavailable";
|
|
14
|
+
if (!capabilities.products.primaryWeightedProductQuery || !primaryWeightedProductId) return "primaryProductUnavailable";
|
|
15
|
+
if (require_registry.builtInWorkflowHasActivity(entry, "customization") && (!capabilities.customization.weightedProduct || !capabilities.scale.available)) return "customizationUnavailable";
|
|
16
|
+
if (entry === "scale" && (!capabilities.scale.available || !capabilities.scale.weightChangeTrigger)) return "scaleTriggerUnavailable";
|
|
17
|
+
}
|
|
18
|
+
const ENTRY_BY_WORKFLOW_ID = Object.freeze({
|
|
19
|
+
"hdl.quick": "quick",
|
|
20
|
+
"hdl.barcode": "barcode",
|
|
21
|
+
"hdl.scale": "scale"
|
|
22
|
+
});
|
|
23
|
+
function readStartPayload(payload) {
|
|
24
|
+
if (!payload || typeof payload !== "object") return {};
|
|
25
|
+
return payload;
|
|
26
|
+
}
|
|
27
|
+
function createHDLKioskApplicationRuntime(host, options) {
|
|
28
|
+
let sessionSequence = 0;
|
|
29
|
+
let active = false;
|
|
30
|
+
let disposed = false;
|
|
31
|
+
let startPromise;
|
|
32
|
+
let returnPromise;
|
|
33
|
+
let returnSequence = 0;
|
|
34
|
+
let snapshot = Object.freeze({
|
|
35
|
+
starting: false,
|
|
36
|
+
returning: false
|
|
37
|
+
});
|
|
38
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
39
|
+
const { config } = options;
|
|
40
|
+
const scannerRouter = require_scannerSessionRouter.createScannerSessionRouter({
|
|
41
|
+
host,
|
|
42
|
+
entrySupported: config.enabledEntries.includes("barcode")
|
|
43
|
+
});
|
|
44
|
+
const runtime = require_runtime.createApplicationRuntime({
|
|
45
|
+
definition: require_manifest.hdlKioskApplication,
|
|
46
|
+
triggerAdapters: require_triggers.createHDLKioskEntryTriggerAdapters(host, config, scannerRouter.triggerAdapter),
|
|
47
|
+
maxActiveSessions: 1,
|
|
48
|
+
sessionFactory: {
|
|
49
|
+
create: function() {
|
|
50
|
+
var _ref = require_asyncToGenerator._asyncToGenerator(function* ({ workflowId, payload, cause }) {
|
|
51
|
+
if (!scannerRouter.beginSessionStart(cause.correlationId)) throw new Error(`Scanner Session start conflict: ${cause.correlationId}`);
|
|
52
|
+
try {
|
|
53
|
+
const entry = ENTRY_BY_WORKFLOW_ID[workflowId];
|
|
54
|
+
if (!entry) throw new Error(`Unknown HDLKiosk Workflow: ${workflowId}`);
|
|
55
|
+
const startPayload = readStartPayload(payload);
|
|
56
|
+
sessionSequence += 1;
|
|
57
|
+
const session = require_createSession.createHDLKioskWorkflowSession(entry, host, {
|
|
58
|
+
sessionId: `${require_manifest.hdlKioskApplication.id}:${sessionSequence}`,
|
|
59
|
+
initialContext: startPayload.initialContext,
|
|
60
|
+
primaryWeightedProductId: config.primaryWeightedProductId,
|
|
61
|
+
cause
|
|
62
|
+
});
|
|
63
|
+
const ensured = yield session.ensure(`start:${cause.trigger}:${cause.occurrenceId}`);
|
|
64
|
+
if (ensured.status !== "succeeded") {
|
|
65
|
+
session.dispose();
|
|
66
|
+
throw new Error(ensured.status === "failed" || ensured.status === "partialFailure" || ensured.status === "unknown" ? `HDLKiosk Session ensure failed: ${ensured.error.traceId}` : "HDLKiosk Session ensure cancelled");
|
|
67
|
+
}
|
|
68
|
+
return session;
|
|
69
|
+
} catch (error) {
|
|
70
|
+
scannerRouter.failSessionStart(cause.correlationId);
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
return function create(_x) {
|
|
75
|
+
return _ref.apply(this, arguments);
|
|
76
|
+
};
|
|
77
|
+
}(),
|
|
78
|
+
onStarted: ({ session, cause }) => {
|
|
79
|
+
if (!session.isActive()) {
|
|
80
|
+
scannerRouter.failSessionStart(cause.correlationId);
|
|
81
|
+
throw new Error(`Inactive HDLKiosk Session started: ${session.id}`);
|
|
82
|
+
}
|
|
83
|
+
if (!scannerRouter.bindSession(cause.correlationId, require_scannerSessionPort.createHDLKioskScannerSessionPort(host, session))) throw new Error(`Scanner Session bind conflict: ${cause.correlationId}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
const updateSnapshot = (next) => {
|
|
88
|
+
const candidate = Object.freeze(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, snapshot), next));
|
|
89
|
+
if (candidate.session === snapshot.session && candidate.starting === snapshot.starting && candidate.startErrorReference === snapshot.startErrorReference && candidate.returning === snapshot.returning && candidate.returnError === snapshot.returnError) return;
|
|
90
|
+
snapshot = candidate;
|
|
91
|
+
listeners.forEach((listener) => listener());
|
|
92
|
+
};
|
|
93
|
+
const unsubscribeSessions = runtime.sessions.subscribe((event) => {
|
|
94
|
+
var _snapshot$session;
|
|
95
|
+
if (event.type === "started") {
|
|
96
|
+
updateSnapshot({
|
|
97
|
+
session: event.session,
|
|
98
|
+
starting: false,
|
|
99
|
+
startErrorReference: void 0,
|
|
100
|
+
returning: false,
|
|
101
|
+
returnError: void 0
|
|
102
|
+
});
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (((_snapshot$session = snapshot.session) === null || _snapshot$session === void 0 ? void 0 : _snapshot$session.id) === event.sessionId) updateSnapshot({ session: void 0 });
|
|
106
|
+
});
|
|
107
|
+
const disposeSession = (sessionId) => {
|
|
108
|
+
if (!runtime.disposeSession(sessionId)) return false;
|
|
109
|
+
scannerRouter.releaseSession(sessionId);
|
|
110
|
+
return true;
|
|
111
|
+
};
|
|
112
|
+
const completeReset = (session) => {
|
|
113
|
+
if (snapshot.session !== session) return;
|
|
114
|
+
disposeSession(session.id);
|
|
115
|
+
};
|
|
116
|
+
const applicationRuntime = {
|
|
117
|
+
id: runtime.id,
|
|
118
|
+
getSnapshot: () => snapshot,
|
|
119
|
+
subscribe: (listener) => {
|
|
120
|
+
listeners.add(listener);
|
|
121
|
+
return () => listeners.delete(listener);
|
|
122
|
+
},
|
|
123
|
+
activate: () => {
|
|
124
|
+
runtime.activate();
|
|
125
|
+
active = true;
|
|
126
|
+
},
|
|
127
|
+
deactivate: () => {
|
|
128
|
+
active = false;
|
|
129
|
+
runtime.deactivate();
|
|
130
|
+
},
|
|
131
|
+
start: (entry) => {
|
|
132
|
+
if (!active || !config.enabledEntries.includes(entry)) return Promise.resolve(void 0);
|
|
133
|
+
if (startPromise) return startPromise;
|
|
134
|
+
if (config.businessMode === "production" && !require_registry.isBuiltInWorkflowProductionReady(entry)) {
|
|
135
|
+
updateSnapshot({ startErrorReference: `workflow-placeholder-blocked-${Date.now()}` });
|
|
136
|
+
return Promise.resolve(void 0);
|
|
137
|
+
}
|
|
138
|
+
const capabilityBlockReason = resolveHDLKioskEntryCapabilityBlockReason({
|
|
139
|
+
entry,
|
|
140
|
+
capabilities: host.capabilities,
|
|
141
|
+
primaryWeightedProductId: config.primaryWeightedProductId
|
|
142
|
+
});
|
|
143
|
+
if (capabilityBlockReason) {
|
|
144
|
+
if (capabilityBlockReason === "sessionEnsureUnavailable") updateSnapshot({ startErrorReference: `session-ensure-unavailable-${Date.now()}` });
|
|
145
|
+
return Promise.resolve(void 0);
|
|
146
|
+
}
|
|
147
|
+
const current = snapshot.session;
|
|
148
|
+
if (current) return Promise.resolve(current.entry === entry ? current : void 0);
|
|
149
|
+
updateSnapshot({
|
|
150
|
+
starting: true,
|
|
151
|
+
startErrorReference: void 0
|
|
152
|
+
});
|
|
153
|
+
const launch = runtime.workflow("hdl.quick").start().then((session) => {
|
|
154
|
+
if (active && !disposed) return session;
|
|
155
|
+
disposeSession(session.id);
|
|
156
|
+
}).catch(() => {
|
|
157
|
+
if (!snapshot.session && active && !disposed) updateSnapshot({ startErrorReference: `session-start-failed-${Date.now()}` });
|
|
158
|
+
}).finally(() => {
|
|
159
|
+
if (startPromise === launch) {
|
|
160
|
+
startPromise = void 0;
|
|
161
|
+
updateSnapshot({ starting: false });
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
startPromise = launch;
|
|
165
|
+
return launch;
|
|
166
|
+
},
|
|
167
|
+
completeReset,
|
|
168
|
+
returnToEntry: (reason = "application") => {
|
|
169
|
+
if (returnPromise) return returnPromise;
|
|
170
|
+
const current = snapshot.session;
|
|
171
|
+
if (!current) return Promise.resolve({
|
|
172
|
+
status: "succeeded",
|
|
173
|
+
data: void 0
|
|
174
|
+
});
|
|
175
|
+
returnSequence += 1;
|
|
176
|
+
updateSnapshot({
|
|
177
|
+
returning: true,
|
|
178
|
+
returnError: void 0
|
|
179
|
+
});
|
|
180
|
+
const pending = current.reset(`return:${reason}:${returnSequence}`).then((result) => {
|
|
181
|
+
if (result.status === "succeeded") {
|
|
182
|
+
updateSnapshot({ returning: false });
|
|
183
|
+
completeReset(current);
|
|
184
|
+
return result;
|
|
185
|
+
}
|
|
186
|
+
updateSnapshot({
|
|
187
|
+
returning: false,
|
|
188
|
+
returnError: result.status === "failed" || result.status === "partialFailure" || result.status === "unknown" ? result.error : {
|
|
189
|
+
code: "resetCancelled",
|
|
190
|
+
source: "operation",
|
|
191
|
+
recovery: "staff",
|
|
192
|
+
safeMessageKey: "hdlKiosk.error.resetCancelled",
|
|
193
|
+
traceId: `hdl-reset-cancelled-${Date.now()}`
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
return result;
|
|
197
|
+
}).catch((cause) => {
|
|
198
|
+
const error = {
|
|
199
|
+
code: "resetUnhandled",
|
|
200
|
+
source: "operation",
|
|
201
|
+
recovery: "staff",
|
|
202
|
+
safeMessageKey: "hdlKiosk.error.resetUnhandled",
|
|
203
|
+
traceId: `hdl-reset-unhandled-${Date.now()}`,
|
|
204
|
+
cause
|
|
205
|
+
};
|
|
206
|
+
updateSnapshot({
|
|
207
|
+
returning: false,
|
|
208
|
+
returnError: error
|
|
209
|
+
});
|
|
210
|
+
return {
|
|
211
|
+
status: "failed",
|
|
212
|
+
error
|
|
213
|
+
};
|
|
214
|
+
}).finally(() => {
|
|
215
|
+
if (returnPromise === pending) returnPromise = void 0;
|
|
216
|
+
});
|
|
217
|
+
returnPromise = pending;
|
|
218
|
+
return pending;
|
|
219
|
+
},
|
|
220
|
+
dispose: () => {
|
|
221
|
+
if (disposed) return;
|
|
222
|
+
disposed = true;
|
|
223
|
+
active = false;
|
|
224
|
+
runtime.dispose();
|
|
225
|
+
scannerRouter.dispose();
|
|
226
|
+
unsubscribeSessions();
|
|
227
|
+
snapshot = Object.freeze({
|
|
228
|
+
starting: false,
|
|
229
|
+
returning: false
|
|
230
|
+
});
|
|
231
|
+
listeners.forEach((listener) => listener());
|
|
232
|
+
listeners.clear();
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
return Object.freeze(applicationRuntime);
|
|
236
|
+
}
|
|
237
|
+
//#endregion
|
|
238
|
+
exports.createHDLKioskApplicationRuntime = createHDLKioskApplicationRuntime;
|
|
239
|
+
exports.resolveHDLKioskEntryCapabilityBlockReason = resolveHDLKioskEntryCapabilityBlockReason;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region src/components/HDLKiosk/devices/dedupeStore.ts
|
|
1
|
+
//#region src/components/HDLKiosk/runtime/devices/dedupeStore.ts
|
|
2
2
|
const DEFAULT_MAX_ENTRIES = 256;
|
|
3
3
|
const DEFAULT_TTL_MS = 2 * 6e4;
|
|
4
4
|
function createDedupeStore({ maxEntries = DEFAULT_MAX_ENTRIES, ttlMs = DEFAULT_TTL_MS, now = Date.now } = {}) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_dedupeStore = require("./dedupeStore.js");
|
|
2
|
-
//#region src/components/HDLKiosk/devices/scaleIngress.ts
|
|
2
|
+
//#region src/components/HDLKiosk/runtime/devices/scaleIngress.ts
|
|
3
3
|
const NON_NEGATIVE_DECIMAL = /^(?:0|[1-9]\d*)(?:\.\d+)?$/;
|
|
4
4
|
function isValidWeightChange(weight) {
|
|
5
5
|
if (weight.unit !== "g" && weight.unit !== "kg") return false;
|
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
|
|
2
1
|
const require_objectSpread2 = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
|
|
3
|
-
|
|
4
|
-
react = require_runtime.__toESM(react);
|
|
5
|
-
//#region src/components/HDLKiosk/devices/scale/runtime.ts
|
|
6
|
-
/**
|
|
7
|
-
* 文件角色:提供 HDLKiosk 生命周期内唯一的电子秤 Snapshot Hub 和 React Provider。
|
|
8
|
-
* 运行机制:BigSale NativeScale owner 持续 publish 原始读数/连接状态,Entry 和称重详情
|
|
9
|
-
* 通过 useSyncExternalStore 共享读取;是否消费由当前 Screen/Ingress 决定。
|
|
10
|
-
* 边界:Runtime 不执行业务跳转,也不直接写购物车。
|
|
11
|
-
*/
|
|
2
|
+
//#region src/components/HDLKiosk/runtime/devices/scaleStore.ts
|
|
12
3
|
const EMPTY_SNAPSHOT = Object.freeze({
|
|
13
4
|
active: false,
|
|
14
5
|
revision: 0,
|
|
15
6
|
status: null,
|
|
16
7
|
connectionState: null,
|
|
17
|
-
isListening: false
|
|
8
|
+
isListening: false,
|
|
9
|
+
hasLiveSample: false,
|
|
10
|
+
sampleSequence: 0
|
|
18
11
|
});
|
|
19
12
|
/**
|
|
20
13
|
* HDLKiosk 生命周期内唯一的称重快照仓库。
|
|
@@ -23,6 +16,7 @@ const EMPTY_SNAPSHOT = Object.freeze({
|
|
|
23
16
|
function createHDLScaleRuntime() {
|
|
24
17
|
const listeners = /* @__PURE__ */ new Set();
|
|
25
18
|
let snapshot = EMPTY_SNAPSHOT;
|
|
19
|
+
let invalidatedAtSampleSequence = 0;
|
|
26
20
|
const emit = () => listeners.forEach((listener) => listener());
|
|
27
21
|
return {
|
|
28
22
|
getSnapshot: () => snapshot,
|
|
@@ -31,6 +25,7 @@ function createHDLScaleRuntime() {
|
|
|
31
25
|
return () => listeners.delete(listener);
|
|
32
26
|
},
|
|
33
27
|
activate: (ownerId) => {
|
|
28
|
+
invalidatedAtSampleSequence = 0;
|
|
34
29
|
snapshot = Object.freeze(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, EMPTY_SNAPSHOT), {}, {
|
|
35
30
|
active: true,
|
|
36
31
|
ownerId,
|
|
@@ -46,14 +41,22 @@ function createHDLScaleRuntime() {
|
|
|
46
41
|
publish: (ownerId, publication) => {
|
|
47
42
|
var _ref, _publication$status, _publication$rawData, _ref2, _publication$connecti, _publication$rawData2, _ref3, _publication$updatedA, _publication$rawData3;
|
|
48
43
|
if (!snapshot.active || snapshot.ownerId !== ownerId) return;
|
|
44
|
+
const sampleSequence = Number.isFinite(publication.sampleSequence) ? Math.max(snapshot.sampleSequence, Number(publication.sampleSequence)) : snapshot.sampleSequence;
|
|
45
|
+
const status = (_ref = (_publication$status = publication.status) !== null && _publication$status !== void 0 ? _publication$status : (_publication$rawData = publication.rawData) === null || _publication$rawData === void 0 ? void 0 : _publication$rawData.status) !== null && _ref !== void 0 ? _ref : null;
|
|
46
|
+
const connectionState = (_ref2 = (_publication$connecti = publication.connectionState) !== null && _publication$connecti !== void 0 ? _publication$connecti : (_publication$rawData2 = publication.rawData) === null || _publication$rawData2 === void 0 ? void 0 : _publication$rawData2.connectionState) !== null && _ref2 !== void 0 ? _ref2 : null;
|
|
47
|
+
const isListening = publication.isListening === true;
|
|
48
|
+
const healthy = connectionState === "connected" && isListening && !publication.error && status !== "overload" && status !== "negative";
|
|
49
|
+
if (!healthy) invalidatedAtSampleSequence = sampleSequence;
|
|
49
50
|
snapshot = Object.freeze({
|
|
50
51
|
active: true,
|
|
51
52
|
ownerId,
|
|
52
53
|
revision: snapshot.revision + 1,
|
|
53
54
|
grossWeightKg: publication.grossWeightKg,
|
|
54
|
-
status
|
|
55
|
-
connectionState
|
|
56
|
-
isListening
|
|
55
|
+
status,
|
|
56
|
+
connectionState,
|
|
57
|
+
isListening,
|
|
58
|
+
hasLiveSample: healthy && sampleSequence > invalidatedAtSampleSequence,
|
|
59
|
+
sampleSequence,
|
|
57
60
|
rawData: publication.rawData,
|
|
58
61
|
error: publication.error,
|
|
59
62
|
updatedAt: (_ref3 = (_publication$updatedA = publication.updatedAt) !== null && _publication$updatedA !== void 0 ? _publication$updatedA : (_publication$rawData3 = publication.rawData) === null || _publication$rawData3 === void 0 ? void 0 : _publication$rawData3.timestamp) !== null && _ref3 !== void 0 ? _ref3 : Date.now()
|
|
@@ -62,18 +65,5 @@ function createHDLScaleRuntime() {
|
|
|
62
65
|
}
|
|
63
66
|
};
|
|
64
67
|
}
|
|
65
|
-
const HDLScaleRuntimeContext = (0, react.createContext)(createHDLScaleRuntime());
|
|
66
|
-
function HDLScaleRuntimeProvider({ runtime, children }) {
|
|
67
|
-
return react.default.createElement(HDLScaleRuntimeContext.Provider, {
|
|
68
|
-
value: runtime,
|
|
69
|
-
children
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
function useHDLScaleSnapshot() {
|
|
73
|
-
const runtime = (0, react.useContext)(HDLScaleRuntimeContext);
|
|
74
|
-
return (0, react.useSyncExternalStore)(runtime.subscribe, runtime.getSnapshot, runtime.getSnapshot);
|
|
75
|
-
}
|
|
76
68
|
//#endregion
|
|
77
|
-
exports.HDLScaleRuntimeProvider = HDLScaleRuntimeProvider;
|
|
78
69
|
exports.createHDLScaleRuntime = createHDLScaleRuntime;
|
|
79
|
-
exports.useHDLScaleSnapshot = useHDLScaleSnapshot;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_dedupeStore = require("./dedupeStore.js");
|
|
2
|
-
//#region src/components/HDLKiosk/devices/scannerIngress.ts
|
|
2
|
+
//#region src/components/HDLKiosk/runtime/devices/scannerIngress.ts
|
|
3
3
|
function createScannerIngress({ maxPendingEvents = 20, dedupe = require_dedupeStore.createDedupeStore() } = {}) {
|
|
4
4
|
if (!Number.isInteger(maxPendingEvents) || maxPendingEvents < 1) throw new Error("HDLKiosk scanner queue limit must be a positive integer");
|
|
5
5
|
return {
|