@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.
Files changed (231) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/meta.js +1 -1
  5. package/build/lowcode/render/default/view.css +1 -1
  6. package/build/lowcode/render/default/view.js +10 -10
  7. package/build/lowcode/view.css +1 -1
  8. package/build/lowcode/view.js +10 -10
  9. package/es/components/HDLKiosk/{contracts → app/contracts}/config.js +1 -1
  10. package/es/components/HDLKiosk/app/manifest.js +11 -11
  11. package/es/components/HDLKiosk/app/operations.js +92 -0
  12. package/es/components/HDLKiosk/app/workflow/barcode.js +11 -13
  13. package/es/components/HDLKiosk/app/workflow/index.js +16 -0
  14. package/es/components/HDLKiosk/app/workflow/predicates.js +1 -1
  15. package/es/components/HDLKiosk/app/workflow/quick.js +1 -1
  16. package/es/components/HDLKiosk/app/workflow/registry.js +4 -4
  17. package/es/components/HDLKiosk/app/workflow/scale.js +5 -1
  18. package/es/components/HDLKiosk/docs/00-/346/226/207/344/273/266/345/257/274/350/210/252.md +104 -167
  19. 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
  20. 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
  21. package/es/components/HDLKiosk/docs/04-/350/256/276/345/244/207/344/270/216/347/247/260/351/207/215.md +43 -26
  22. package/es/components/HDLKiosk/docs/05-/344/272/244/346/230/223/345/256/211/345/205/250.md +2 -0
  23. package/es/components/HDLKiosk/docs/07-/345/220/216/347/273/255/345/267/245/344/275/234.md +1 -1
  24. 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
  25. 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
  26. package/es/components/HDLKiosk/docs/README.md +6 -2
  27. package/es/components/HDLKiosk/docs//345/256/236/346/226/275/350/277/233/345/272/246.md +8 -7
  28. package/es/components/HDLKiosk/docs//346/236/266/346/236/204/350/256/276/350/256/241.md +16 -18
  29. package/es/components/HDLKiosk/index.js +22 -28
  30. package/es/components/HDLKiosk/index.less +1 -1
  31. package/es/components/HDLKiosk/kernel/README.md +14 -13
  32. package/es/components/HDLKiosk/kernel/application/defineApplication.js +63 -24
  33. package/es/components/HDLKiosk/kernel/application/defineSlice.js +6 -6
  34. package/es/components/HDLKiosk/kernel/application/runtime.js +237 -0
  35. package/es/components/HDLKiosk/kernel/operations/coordinator.js +1 -1
  36. package/es/components/HDLKiosk/kernel/operations/registry.js +3 -3
  37. package/es/components/HDLKiosk/kernel/operations/sessionEpoch.js +1 -1
  38. package/es/components/HDLKiosk/kernel/operations/types.js +7 -3
  39. package/es/components/HDLKiosk/kernel/workflow/actor.js +51 -22
  40. package/es/components/HDLKiosk/kernel/workflow/compiler.js +23 -30
  41. package/es/components/HDLKiosk/runtime/createRuntime.js +238 -0
  42. package/es/components/HDLKiosk/{devices → runtime/devices}/dedupeStore.js +1 -1
  43. package/es/components/HDLKiosk/{devices → runtime/devices}/scaleIngress.js +1 -1
  44. package/es/components/HDLKiosk/{devices/scale/runtime.js → runtime/devices/scaleStore.js} +18 -24
  45. package/es/components/HDLKiosk/{devices → runtime/devices}/scannerIngress.js +1 -1
  46. package/es/components/HDLKiosk/runtime/devices/scannerSessionPort.js +60 -0
  47. package/es/components/HDLKiosk/runtime/devices/scannerSessionRouter.js +212 -0
  48. package/es/components/HDLKiosk/runtime/operations/barcode.js +18 -0
  49. package/es/components/HDLKiosk/runtime/operations/cart.js +44 -0
  50. package/es/components/HDLKiosk/{app → runtime}/operations/cartConsistency.js +1 -1
  51. package/es/components/HDLKiosk/{app → runtime}/operations/checkout.js +95 -110
  52. package/es/components/HDLKiosk/{app → runtime}/operations/checkoutRequirements.js +1 -1
  53. package/es/components/HDLKiosk/{app → runtime}/operations/checkoutSafety.js +1 -1
  54. package/es/components/HDLKiosk/{app → runtime}/operations/coordinator.js +2 -2
  55. package/es/components/HDLKiosk/runtime/operations/customization.js +70 -0
  56. package/es/components/HDLKiosk/{app → runtime}/operations/errors.js +1 -1
  57. package/es/components/HDLKiosk/runtime/operations/fulfillment.js +6 -0
  58. package/es/components/HDLKiosk/runtime/operations/identity.js +55 -0
  59. package/es/components/HDLKiosk/runtime/operations/registry.js +34 -0
  60. package/es/components/HDLKiosk/runtime/operations/session.js +29 -0
  61. package/es/components/HDLKiosk/runtime/operations/types.js +13 -0
  62. package/es/components/HDLKiosk/runtime/session/blockPolicy.js +14 -0
  63. package/es/components/HDLKiosk/runtime/{createWorkflowSession.js → session/createSession.js} +67 -17
  64. package/es/components/HDLKiosk/runtime/{domainTransitionRunner.js → session/transitionRunner.js} +10 -5
  65. package/es/components/HDLKiosk/runtime/{workflowContext.js → session/workflowContext.js} +2 -2
  66. package/es/components/HDLKiosk/runtime/{workflowLifecycle.js → session/workflowLifecycle.js} +2 -2
  67. package/es/components/HDLKiosk/runtime/triggers.js +28 -0
  68. package/es/components/HDLKiosk/slices/catalog/Screen/index.js +15 -8
  69. package/es/components/HDLKiosk/slices/catalog/Screen/index.less +74 -13
  70. package/es/components/HDLKiosk/slices/catalog/slice.js +2 -2
  71. package/es/components/HDLKiosk/slices/customization/Screen/index.js +37 -38
  72. package/es/components/HDLKiosk/slices/customization/Screen/index.less +5 -0
  73. package/es/components/HDLKiosk/slices/customization/slice.js +3 -4
  74. package/es/components/HDLKiosk/slices/fulfillment/slice.js +2 -2
  75. package/es/components/HDLKiosk/slices/fulfillment/view.js +1 -1
  76. package/es/components/HDLKiosk/slices/identity/Screen/index.js +2 -2
  77. package/es/components/HDLKiosk/slices/identity/slice.js +3 -3
  78. package/es/components/HDLKiosk/slices/identity/view.js +1 -1
  79. package/es/components/HDLKiosk/slices/payment/slice.js +3 -3
  80. package/es/components/HDLKiosk/slices/primaryProductPrompt/slice.js +2 -2
  81. package/es/components/HDLKiosk/slices/primaryProductPrompt/view.js +2 -2
  82. package/es/components/HDLKiosk/{runtime → ui}/HDLKioskWorkflowView.js +45 -131
  83. package/es/components/HDLKiosk/ui/ScaleSimulatorConsole/index.js +387 -0
  84. package/es/components/HDLKiosk/ui/ScaleSimulatorConsole/index.less +621 -0
  85. package/es/components/HDLKiosk/{app → ui}/ScreenRenderer.js +7 -7
  86. package/es/components/HDLKiosk/ui/controllers/useHDLKioskActionDispatcher.js +66 -0
  87. package/es/components/HDLKiosk/{runtime → ui}/controllers/useHDLKioskCustomerController.js +1 -1
  88. package/es/components/HDLKiosk/ui/controllers/useHDLKioskDeviceController.js +25 -0
  89. package/es/components/HDLKiosk/ui/controllers/useHDLKioskExitController.js +53 -0
  90. package/es/components/HDLKiosk/{runtime → ui}/controllers/useHDLKioskScreenData.js +1 -1
  91. package/es/components/HDLKiosk/ui/controllers/useHDLKioskSessionController.js +39 -0
  92. package/es/components/HDLKiosk/{app → ui}/entry/Screen/index.js +8 -6
  93. package/es/components/HDLKiosk/{app → ui}/entry/model.js +2 -2
  94. package/es/components/HDLKiosk/ui/scale.js +20 -0
  95. package/es/components/HDLKiosk/{runtime/useHostSnapshot.js → ui/snapshots.js} +6 -8
  96. package/es/components/HDLKiosk/{app → ui}/views.js +1 -1
  97. package/es/components/HDLKiosk/{runtime → ui}/workflowEvent.js +1 -1
  98. package/es/components/HDLKiosk/utils.js +4 -4
  99. package/es/components/bigSale/templates/HDLKiosk/adapter/HDLKioskPaymentRuntime.js +2 -1
  100. package/es/components/bigSale/templates/HDLKiosk/adapter/capabilities.js +1 -1
  101. package/es/components/bigSale/templates/HDLKiosk/adapter/projection.js +21 -11
  102. package/es/components/bigSale/templates/HDLKiosk/adapter/sales.js +21 -3
  103. package/es/components/bigSale/templates/HDLKiosk/adapter/scaleTrigger.js +20 -5
  104. package/es/components/bigSale/templates/HDLKiosk/adapter/useBigSaleHDLKioskHost.js +3 -0
  105. package/es/components/bigSale/templates/HDLKiosk/index.js +3 -3
  106. package/lib/components/HDLKiosk/{contracts → app/contracts}/config.js +1 -1
  107. package/lib/components/HDLKiosk/app/manifest.js +18 -19
  108. package/lib/components/HDLKiosk/app/operations.js +105 -0
  109. package/lib/components/HDLKiosk/app/workflow/barcode.js +11 -13
  110. package/lib/components/HDLKiosk/app/workflow/index.js +16 -0
  111. package/lib/components/HDLKiosk/app/workflow/predicates.js +1 -0
  112. package/lib/components/HDLKiosk/app/workflow/quick.js +1 -1
  113. package/lib/components/HDLKiosk/app/workflow/registry.js +3 -3
  114. package/lib/components/HDLKiosk/app/workflow/scale.js +5 -1
  115. package/lib/components/HDLKiosk/docs/00-/346/226/207/344/273/266/345/257/274/350/210/252.md +104 -167
  116. 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
  117. 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
  118. package/lib/components/HDLKiosk/docs/04-/350/256/276/345/244/207/344/270/216/347/247/260/351/207/215.md +43 -26
  119. package/lib/components/HDLKiosk/docs/05-/344/272/244/346/230/223/345/256/211/345/205/250.md +2 -0
  120. package/lib/components/HDLKiosk/docs/07-/345/220/216/347/273/255/345/267/245/344/275/234.md +1 -1
  121. 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
  122. 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
  123. package/lib/components/HDLKiosk/docs/README.md +6 -2
  124. package/lib/components/HDLKiosk/docs//345/256/236/346/226/275/350/277/233/345/272/246.md +8 -7
  125. package/lib/components/HDLKiosk/docs//346/236/266/346/236/204/350/256/276/350/256/241.md +16 -18
  126. package/lib/components/HDLKiosk/index.js +25 -31
  127. package/lib/components/HDLKiosk/index.less +1 -1
  128. package/lib/components/HDLKiosk/kernel/README.md +14 -13
  129. package/lib/components/HDLKiosk/kernel/application/defineApplication.js +65 -25
  130. package/lib/components/HDLKiosk/kernel/application/defineSlice.js +6 -6
  131. package/lib/components/HDLKiosk/kernel/application/runtime.js +237 -0
  132. package/lib/components/HDLKiosk/kernel/operations/coordinator.js +1 -1
  133. package/lib/components/HDLKiosk/kernel/operations/registry.js +3 -3
  134. package/lib/components/HDLKiosk/kernel/operations/sessionEpoch.js +1 -1
  135. package/lib/components/HDLKiosk/kernel/operations/types.js +8 -3
  136. package/lib/components/HDLKiosk/kernel/workflow/actor.js +51 -22
  137. package/lib/components/HDLKiosk/kernel/workflow/compiler.js +23 -30
  138. package/lib/components/HDLKiosk/runtime/createRuntime.js +239 -0
  139. package/lib/components/HDLKiosk/{devices → runtime/devices}/dedupeStore.js +1 -1
  140. package/lib/components/HDLKiosk/{devices → runtime/devices}/scaleIngress.js +1 -1
  141. package/lib/components/HDLKiosk/{devices/scale/runtime.js → runtime/devices/scaleStore.js} +17 -27
  142. package/lib/components/HDLKiosk/{devices → runtime/devices}/scannerIngress.js +1 -1
  143. package/lib/components/HDLKiosk/runtime/devices/scannerSessionPort.js +60 -0
  144. package/lib/components/HDLKiosk/runtime/devices/scannerSessionRouter.js +212 -0
  145. package/lib/components/HDLKiosk/runtime/operations/barcode.js +17 -0
  146. package/lib/components/HDLKiosk/runtime/operations/cart.js +46 -0
  147. package/lib/components/HDLKiosk/{app → runtime}/operations/cartConsistency.js +1 -1
  148. package/lib/components/HDLKiosk/{app → runtime}/operations/checkout.js +97 -112
  149. package/lib/components/HDLKiosk/{app → runtime}/operations/checkoutRequirements.js +1 -1
  150. package/lib/components/HDLKiosk/{app → runtime}/operations/checkoutSafety.js +1 -1
  151. package/lib/components/HDLKiosk/{app → runtime}/operations/coordinator.js +2 -2
  152. package/lib/components/HDLKiosk/runtime/operations/customization.js +73 -0
  153. package/lib/components/HDLKiosk/{app → runtime}/operations/errors.js +1 -1
  154. package/lib/components/HDLKiosk/runtime/operations/fulfillment.js +5 -0
  155. package/lib/components/HDLKiosk/runtime/operations/identity.js +55 -0
  156. package/lib/components/HDLKiosk/runtime/operations/registry.js +34 -0
  157. package/lib/components/HDLKiosk/runtime/operations/session.js +30 -0
  158. package/lib/components/HDLKiosk/runtime/operations/types.js +14 -0
  159. package/lib/components/HDLKiosk/runtime/session/blockPolicy.js +14 -0
  160. package/lib/components/HDLKiosk/runtime/{createWorkflowSession.js → session/createSession.js} +71 -21
  161. package/lib/components/HDLKiosk/runtime/{domainTransitionRunner.js → session/transitionRunner.js} +10 -5
  162. package/lib/components/HDLKiosk/runtime/{workflowContext.js → session/workflowContext.js} +2 -2
  163. package/lib/components/HDLKiosk/runtime/{workflowLifecycle.js → session/workflowLifecycle.js} +2 -2
  164. package/lib/components/HDLKiosk/runtime/triggers.js +28 -0
  165. package/lib/components/HDLKiosk/slices/catalog/Screen/index.js +15 -8
  166. package/lib/components/HDLKiosk/slices/catalog/Screen/index.less +74 -13
  167. package/lib/components/HDLKiosk/slices/catalog/slice.js +3 -3
  168. package/lib/components/HDLKiosk/slices/customization/Screen/index.js +38 -39
  169. package/lib/components/HDLKiosk/slices/customization/Screen/index.less +5 -0
  170. package/lib/components/HDLKiosk/slices/customization/slice.js +5 -6
  171. package/lib/components/HDLKiosk/slices/fulfillment/slice.js +3 -3
  172. package/lib/components/HDLKiosk/slices/fulfillment/view.js +1 -1
  173. package/lib/components/HDLKiosk/slices/identity/Screen/index.js +2 -2
  174. package/lib/components/HDLKiosk/slices/identity/slice.js +4 -4
  175. package/lib/components/HDLKiosk/slices/identity/view.js +1 -1
  176. package/lib/components/HDLKiosk/slices/payment/slice.js +5 -5
  177. package/lib/components/HDLKiosk/slices/primaryProductPrompt/slice.js +2 -2
  178. package/lib/components/HDLKiosk/slices/primaryProductPrompt/view.js +2 -2
  179. package/lib/components/HDLKiosk/{runtime → ui}/HDLKioskWorkflowView.js +46 -132
  180. package/lib/components/HDLKiosk/ui/ScaleSimulatorConsole/index.js +390 -0
  181. package/lib/components/HDLKiosk/ui/ScaleSimulatorConsole/index.less +621 -0
  182. package/lib/components/HDLKiosk/{app → ui}/ScreenRenderer.js +7 -7
  183. package/lib/components/HDLKiosk/ui/controllers/useHDLKioskActionDispatcher.js +67 -0
  184. package/lib/components/HDLKiosk/{runtime → ui}/controllers/useHDLKioskCustomerController.js +1 -1
  185. package/lib/components/HDLKiosk/ui/controllers/useHDLKioskDeviceController.js +26 -0
  186. package/lib/components/HDLKiosk/ui/controllers/useHDLKioskExitController.js +54 -0
  187. package/lib/components/HDLKiosk/{runtime → ui}/controllers/useHDLKioskScreenData.js +1 -1
  188. package/lib/components/HDLKiosk/ui/controllers/useHDLKioskSessionController.js +40 -0
  189. package/lib/components/HDLKiosk/{app → ui}/entry/Screen/index.js +8 -6
  190. package/lib/components/HDLKiosk/{app → ui}/entry/model.js +2 -2
  191. package/lib/components/HDLKiosk/ui/scale.js +24 -0
  192. package/lib/components/HDLKiosk/{runtime/useHostSnapshot.js → ui/snapshots.js} +6 -7
  193. package/lib/components/HDLKiosk/{app → ui}/views.js +1 -1
  194. package/lib/components/HDLKiosk/{runtime → ui}/workflowEvent.js +1 -1
  195. package/lib/components/HDLKiosk/utils.js +4 -4
  196. package/lib/components/bigSale/templates/HDLKiosk/adapter/HDLKioskPaymentRuntime.js +2 -1
  197. package/lib/components/bigSale/templates/HDLKiosk/adapter/capabilities.js +1 -1
  198. package/lib/components/bigSale/templates/HDLKiosk/adapter/projection.js +21 -10
  199. package/lib/components/bigSale/templates/HDLKiosk/adapter/sales.js +20 -2
  200. package/lib/components/bigSale/templates/HDLKiosk/adapter/scaleTrigger.js +19 -4
  201. package/lib/components/bigSale/templates/HDLKiosk/adapter/useBigSaleHDLKioskHost.js +3 -0
  202. package/lib/components/bigSale/templates/HDLKiosk/index.js +4 -4
  203. package/package.json +2 -2
  204. package/es/components/HDLKiosk/app/constants.js +0 -9
  205. package/es/components/HDLKiosk/app/operations/barcode.js +0 -22
  206. package/es/components/HDLKiosk/app/operations/cart.js +0 -60
  207. package/es/components/HDLKiosk/app/operations/fulfillment.js +0 -11
  208. package/es/components/HDLKiosk/app/operations/session.js +0 -41
  209. package/es/components/HDLKiosk/app/operations/types.js +0 -11
  210. package/es/components/HDLKiosk/devices/entryArbiter.js +0 -33
  211. package/es/components/HDLKiosk/runtime/controllers/useHDLKioskDeviceController.js +0 -75
  212. package/es/components/HDLKiosk/runtime/controllers/useHDLKioskScannerController.js +0 -160
  213. package/es/components/HDLKiosk/runtime/controllers/useHDLKioskSessionController.js +0 -185
  214. package/es/components/HDLKiosk/runtime/useWorkflowSnapshot.js +0 -12
  215. package/es/components/HDLKiosk/slices/customization/operation.js +0 -80
  216. package/es/components/HDLKiosk/slices/identity/operation.js +0 -60
  217. package/lib/components/HDLKiosk/app/constants.js +0 -9
  218. package/lib/components/HDLKiosk/app/operations/barcode.js +0 -21
  219. package/lib/components/HDLKiosk/app/operations/cart.js +0 -62
  220. package/lib/components/HDLKiosk/app/operations/fulfillment.js +0 -10
  221. package/lib/components/HDLKiosk/app/operations/session.js +0 -42
  222. package/lib/components/HDLKiosk/app/operations/types.js +0 -12
  223. package/lib/components/HDLKiosk/devices/entryArbiter.js +0 -33
  224. package/lib/components/HDLKiosk/runtime/controllers/useHDLKioskDeviceController.js +0 -76
  225. package/lib/components/HDLKiosk/runtime/controllers/useHDLKioskScannerController.js +0 -161
  226. package/lib/components/HDLKiosk/runtime/controllers/useHDLKioskSessionController.js +0 -186
  227. package/lib/components/HDLKiosk/runtime/useWorkflowSnapshot.js +0 -13
  228. package/lib/components/HDLKiosk/slices/customization/operation.js +0 -83
  229. package/lib/components/HDLKiosk/slices/identity/operation.js +0 -60
  230. /package/es/components/HDLKiosk/{app → ui}/entry/Screen/index.less +0 -0
  231. /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: `hdlKiosk.error.${code}`,
12
- traceId: `hdl-workflow-${Date.now()}-${workflowErrorSequence}`,
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 || node.visitPolicy !== "reuseResolution" && node.visitPolicy !== "once") return stepId;
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
- if (definition.nodes[candidateStepId].visitPolicy === "once" && stepResolutions.has(candidateStepId)) continue;
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 || startingNode.end === "blocked" ? "blocked" : startingNode.end === "success" ? "finished" : "idle",
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: (_ref2 = initialError !== null && initialError !== void 0 ? initialError : initialResolutionError) !== null && _ref2 !== void 0 ? _ref2 : startingNode.end === "blocked" ? createWorkflowError("workflowEndedBlocked", "staff") : void 0
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
- confirmedCheckout: next.confirmedCheckout,
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 _ref3 = require_asyncToGenerator._asyncToGenerator(function* (fromNodeId, nodeId, event, nextContext, blocked, lastError, confirmedCheckout) {
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 || node.end === "blocked" ? "blocked" : node.end === "success" ? "finished" : "idle",
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
- confirmedCheckout: confirmedCheckout !== null && confirmedCheckout !== void 0 ? confirmedCheckout : snapshot.confirmedCheckout,
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 _ref3.apply(this, arguments);
243
+ return _ref2.apply(this, arguments);
220
244
  };
221
245
  }();
222
246
  const blockForRuntimeError = function() {
223
- var _ref4 = require_asyncToGenerator._asyncToGenerator(function* (fromNodeId, event, code, cause) {
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 _ref4.apply(this, arguments);
257
+ return _ref3.apply(this, arguments);
234
258
  };
235
259
  }();
236
260
  const handleEvent = function() {
237
- var _ref5 = require_asyncToGenerator._asyncToGenerator(function* (event) {
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 === "skip") navigationHistory = navigationHistory.filter((stepId) => stepId !== fromNodeId);
361
- yield commit(fromNodeId, resolvedTarget, event, nextContext, false, void 0, result.confirmedCheckout);
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 _ref5.apply(this, arguments);
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
- const historyIndex = navigationHistory.lastIndexOf(resolution.stepId);
415
- if (historyIndex >= 0) navigationHistory = navigationHistory.slice(0, historyIndex);
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 _ref6 = require_asyncToGenerator._asyncToGenerator(function* () {
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 _ref6.apply(this, arguments);
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 canReachSuccess(initial, nodes) {
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.end === "success") return true;
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
- "end",
127
- "screen"
126
+ "isTerminal",
127
+ "surface"
128
128
  ], stepPath, issues);
129
- if (rawStep.screen !== void 0) addIssue(issues, "step.screen.forbidden", `${stepPath}.screen`, "Screen is resolved by the local Activity Contract");
130
- if (rawStep.visitPolicy !== void 0 && rawStep.visitPolicy !== "always" && rawStep.visitPolicy !== "reuseResolution" && rawStep.visitPolicy !== "once") addIssue(issues, "step.visitPolicy.invalid", `${stepPath}.visitPolicy`, "Step visitPolicy must be always, reuseResolution or once");
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", "base"], `${stepPath}.presentation`, issues);
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") if (typeof rawPresentation.base !== "string" || !rawPresentation.base.trim()) addIssue(issues, "step.presentation.base.invalid", `${stepPath}.presentation.base`, "Modal base must be a non-empty step id");
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.end !== void 0 && rawStep.end !== "success" && rawStep.end !== "blocked") addIssue(issues, "step.end.invalid", `${stepPath}.end`, "Step end must be success or blocked");
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
- screenId: activity.screenId,
231
+ surfaceId: activity.surfaceId,
236
232
  presentation,
237
233
  readiness: rawStep.readiness === "placeholder" ? "placeholder" : void 0,
238
- visitPolicy: rawStep.visitPolicy === "reuseResolution" || rawStep.visitPolicy === "once" ? rawStep.visitPolicy : "always",
234
+ visitPolicy: rawStep.visitPolicy === "once" ? "once" : "always",
239
235
  guardPhases: Object.freeze([...guardPhases]),
240
236
  on: Object.freeze(transitions),
241
- end: rawStep.end === "success" || rawStep.end === "blocked" ? rawStep.end : void 0
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
- if (!node.end && transitions.length === 0) addIssue(issues, "step.deadEnd", path, "A step without outgoing transitions must declare its end state");
257
- if (node.end && transitions.length > 0) addIssue(issues, "step.end.hasTransitions", path, "An end step cannot expose outgoing transitions");
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] && !canReachSuccess(initial, nodes)) addIssue(issues, "workflow.success.unreachable", "steps", "The first step cannot reach a successful end");
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 _ref, _activity$requirement;
282
- const activity = activities.require(node.activity);
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
- let react = require("react");
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: (_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,
55
- 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,
56
- isListening: publication.isListening === true,
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 {