@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
@@ -1,5 +1,6 @@
1
- import { _asyncToGenerator } from "../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
2
1
  import { useHDLKioskCustomerController } from "./controllers/useHDLKioskCustomerController.js";
2
+ import { useHDLKioskActionDispatcher } from "./controllers/useHDLKioskActionDispatcher.js";
3
+ import { useHDLKioskExitController } from "./controllers/useHDLKioskExitController.js";
3
4
  import { useHDLKioskScreenData } from "./controllers/useHDLKioskScreenData.js";
4
5
  import { canReopenWorkflowStep } from "../kernel/workflow/selectors.js";
5
6
  import { EndOrderDialog } from "../components/overlays/EndOrderDialog/index.js";
@@ -10,12 +11,11 @@ import { HDLKioskShell } from "../components/shell/HDLKioskShell/index.js";
10
11
  import { HDLKioskBottomBarHost, useHDLKioskCartDrawerController } from "../components/shell/HDLKioskBottomBarHost/index.js";
11
12
  import { BlockingNotice } from "../components/common/BlockingNotice/index.js";
12
13
  import { createCartDrawerModel } from "../utils.js";
13
- import { ScreenRenderer } from "../app/ScreenRenderer.js";
14
- import { useWorkflowSnapshot } from "./useWorkflowSnapshot.js";
15
- import { createWorkflowEvent } from "./workflowEvent.js";
14
+ import { ScreenRenderer } from "./ScreenRenderer.js";
15
+ import { useWorkflowSnapshot } from "./snapshots.js";
16
16
  import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
17
17
  import { locales } from "@pisell/utils";
18
- //#region src/components/HDLKiosk/runtime/HDLKioskWorkflowView.tsx
18
+ //#region src/components/HDLKiosk/ui/HDLKioskWorkflowView.tsx
19
19
  /**
20
20
  * 文件角色:承载一个活跃 HDLKiosk 会话的 React 组合视图。
21
21
  * 运行机制:组合 Customer/ScreenData Controller,订阅 Host 与 Actor
@@ -40,52 +40,42 @@ function HDLKioskWorkflowCartOverlay({ model, busy, memberAction, send, renderCa
40
40
  } : void 0
41
41
  });
42
42
  }
43
+ function HDLKioskWorkflowBlockingSurface({ snapshot, title, description, reference, hideBottomBar = false }) {
44
+ return /* @__PURE__ */ React.createElement(HDLKioskShell, { snapshot }, /* @__PURE__ */ React.createElement(HDLKioskBottomBarHost, { mode: hideBottomBar ? "hidden" : void 0 }, /* @__PURE__ */ React.createElement(HDLKioskHeader, null), /* @__PURE__ */ React.createElement("main", { className: "hdl-shell__main" }, /* @__PURE__ */ React.createElement(BlockingNotice, {
45
+ title,
46
+ description,
47
+ reference
48
+ }))));
49
+ }
43
50
  /**
44
51
  * 活跃点餐会话的 UI 编排层。
45
52
  *
46
53
  * 它把运行时控制器投影为 Screen/Dialog 所需的 props;具体页面不直接接触
47
54
  * Host、Workflow Actor 或会话计时器。
48
55
  */
49
- function HDLKioskWorkflowView({ session, host, sales, config, isActive, renderIdentityAuth, renderCartContent, cartOverlayActions, returnToEntry }) {
50
- var _snapshot$pendingNavi, _snapshot$pendingNavi2, _activeNode$presentat, _customer$error, _activeNode$presentat2;
56
+ function HDLKioskWorkflowView({ session, host, sales, config, isActive, returning, returnError, renderIdentityAuth, renderCartContent, cartOverlayActions, returnToEntry }) {
57
+ var _session$definition$n2, _customer$error, _activeNode$presentat;
51
58
  const snapshot = useWorkflowSnapshot(session.actor);
52
- const sequence = useRef(0);
53
- const resetInFlight = useRef(false);
54
- const [resetting, setResetting] = useState(false);
55
- const [resetError, setResetError] = useState();
59
+ const navigationSequence = useRef(0);
56
60
  const [memberLoginOpen, setMemberLoginOpen] = useState(false);
57
- const [commandState, setCommandState] = useState({ busy: false });
58
- const commandGeneration = useRef(0);
59
- const pendingCommands = useRef(0);
60
61
  const activeNode = session.definition.nodes[snapshot.nodeId];
61
- const pendingEndOrderNavigation = ((_snapshot$pendingNavi = snapshot.pendingNavigation) === null || _snapshot$pendingNavi === void 0 ? void 0 : _snapshot$pendingNavi.request.kind) === "confirmEndOrder" ? snapshot.pendingNavigation : void 0;
62
- const pendingAutomaticExitNavigation = ((_snapshot$pendingNavi2 = snapshot.pendingNavigation) === null || _snapshot$pendingNavi2 === void 0 ? void 0 : _snapshot$pendingNavi2.request.kind) === "performSessionExit" ? snapshot.pendingNavigation : void 0;
63
- const endOrderConfirmationOpen = Boolean(pendingEndOrderNavigation);
64
- const currentScreenId = activeNode.screenId;
65
62
  const customizationStepId = session.definition.stepOrder.find((stepId) => {
66
63
  var _session$definition$n;
67
64
  return ((_session$definition$n = session.definition.nodes[stepId]) === null || _session$definition$n === void 0 ? void 0 : _session$definition$n.activity) === "customization";
68
65
  });
69
- const screenDataNode = ((_activeNode$presentat = activeNode.presentation) === null || _activeNode$presentat === void 0 ? void 0 : _activeNode$presentat.mode) === "modal" ? session.definition.nodes[activeNode.presentation.base] : activeNode;
66
+ const screenDataNode = (_session$definition$n2 = session.definition.nodes[snapshot.surface.pageStepId]) !== null && _session$definition$n2 !== void 0 ? _session$definition$n2 : activeNode;
70
67
  const paymentSafeForReset = sales.payment.status === "idle" || sales.payment.status === "failed";
71
- const resetSession = useCallback(_asyncToGenerator(function* () {
72
- if (resetInFlight.current) return;
73
- resetInFlight.current = true;
74
- setResetting(true);
75
- setResetError(void 0);
76
- sequence.current += 1;
77
- const result = yield returnToEntry("ui");
78
- if (result.status === "succeeded") return;
79
- resetInFlight.current = false;
80
- setResetting(false);
81
- setResetError(result.status === "failed" || result.status === "partialFailure" || result.status === "unknown" ? result.error : {
82
- code: "resetCancelled",
83
- source: "operation",
84
- recovery: "staff",
85
- safeMessageKey: "hdlKiosk.error.resetCancelled",
86
- traceId: `hdl-reset-cancelled-${Date.now()}`
87
- });
88
- }), [returnToEntry]);
68
+ const { endOrderConfirmationOpen, resetSession, requestEndOrder, cancelEndOrder, confirmEndOrder } = useHDLKioskExitController({
69
+ session,
70
+ snapshot,
71
+ returnToEntry
72
+ });
73
+ const { send, commandState } = useHDLKioskActionDispatcher({
74
+ session,
75
+ snapshot,
76
+ activityId: activeNode.activity,
77
+ resetSession
78
+ });
89
79
  const customer = useHDLKioskCustomerController({
90
80
  session,
91
81
  snapshot,
@@ -93,7 +83,7 @@ function HDLKioskWorkflowView({ session, host, sales, config, isActive, renderId
93
83
  activityId: activeNode.activity,
94
84
  isActive,
95
85
  loginAvailable: Boolean(renderIdentityAuth),
96
- interactionBlocked: resetting || commandState.busy
86
+ interactionBlocked: returning || commandState.busy
97
87
  });
98
88
  const requestMemberLogin = useCallback(() => {
99
89
  if (customer.canLogin && renderIdentityAuth) setMemberLoginOpen(true);
@@ -102,106 +92,27 @@ function HDLKioskWorkflowView({ session, host, sales, config, isActive, renderId
102
92
  setMemberLoginOpen(false);
103
93
  customer.applyAuthenticatedCustomer(customerId);
104
94
  }, [customer.applyAuthenticatedCustomer]);
105
- const requestEndOrder = useCallback(() => {
106
- sequence.current += 1;
107
- session.actor.navigate({
108
- kind: "sessionExit",
109
- reason: "userRequest"
110
- }, `ui:${snapshot.sessionEpoch}:${sequence.current}`);
111
- }, [session, snapshot.sessionEpoch]);
112
95
  const editPrimaryProduct = useCallback(() => {
113
96
  if (!customizationStepId || customizationStepId === snapshot.nodeId) return;
114
- sequence.current += 1;
97
+ navigationSequence.current += 1;
115
98
  session.actor.navigate({
116
99
  kind: "step",
117
100
  stepId: customizationStepId
118
- }, `ui:edit-primary-product:${snapshot.sessionEpoch}:${sequence.current}`);
101
+ }, `ui:edit-primary-product:${snapshot.sessionEpoch}:${navigationSequence.current}`);
119
102
  }, [
120
103
  customizationStepId,
121
104
  session.actor,
122
105
  snapshot.nodeId,
123
106
  snapshot.sessionEpoch
124
107
  ]);
125
- const cancelEndOrder = useCallback(() => {
126
- if (!pendingEndOrderNavigation) return;
127
- session.actor.resolvePendingNavigation(pendingEndOrderNavigation.navigationId, "cancel");
128
- }, [pendingEndOrderNavigation, session.actor]);
129
- const confirmEndOrder = useCallback(() => {
130
- if (!pendingEndOrderNavigation || !session.actor.resolvePendingNavigation(pendingEndOrderNavigation.navigationId, "allow")) return;
131
- resetSession();
132
- }, [
133
- pendingEndOrderNavigation,
134
- resetSession,
135
- session.actor
136
- ]);
137
- useEffect(() => {
138
- if (!pendingAutomaticExitNavigation || !session.actor.resolvePendingNavigation(pendingAutomaticExitNavigation.navigationId, "allow")) return;
139
- resetSession();
140
- }, [
141
- pendingAutomaticExitNavigation,
142
- resetSession,
143
- session.actor
144
- ]);
145
108
  const { catalog, customization, payment } = useHDLKioskScreenData({
146
109
  host,
147
- currentScreenId: screenDataNode.screenId,
110
+ currentScreenId: screenDataNode.surfaceId,
148
111
  activity: screenDataNode.activity,
149
112
  isActive,
150
113
  primaryWeightedProductId: config.primaryWeightedProductId
151
114
  });
152
- useEffect(() => {
153
- commandGeneration.current += 1;
154
- pendingCommands.current = 0;
155
- setCommandState({ busy: false });
156
- setMemberLoginOpen(false);
157
- }, [session]);
158
- const send = useCallback((action) => {
159
- if (action.kind === "session") {
160
- resetSession();
161
- return;
162
- }
163
- sequence.current += 1;
164
- const intentId = `ui:${snapshot.sessionEpoch}:${sequence.current}`;
165
- if (action.kind === "intent" || action.kind === "navigation") {
166
- const event = createWorkflowEvent(action, activeNode.activity, snapshot.nodeId, intentId);
167
- if (event) session.actor.send(event);
168
- return;
169
- }
170
- const generation = commandGeneration.current;
171
- pendingCommands.current += 1;
172
- setCommandState({
173
- busy: true,
174
- commandId: action.command
175
- });
176
- session.executeCommand(action.command, action.input, intentId).then((result) => {
177
- if (generation !== commandGeneration.current) return;
178
- pendingCommands.current = Math.max(0, pendingCommands.current - 1);
179
- setCommandState({
180
- busy: pendingCommands.current > 0,
181
- commandId: pendingCommands.current > 0 ? action.command : void 0,
182
- error: result.status === "failed" ? result.error : void 0
183
- });
184
- });
185
- }, [
186
- activeNode.activity,
187
- resetSession,
188
- session,
189
- snapshot.nodeId,
190
- snapshot.sessionEpoch
191
- ]);
192
- useEffect(() => {
193
- if (activeNode.activity !== "paymentMethod" || snapshot.status !== "idle" || sales.payment.status !== "succeeded") return;
194
- send({
195
- kind: "intent",
196
- activityId: "paymentMethod",
197
- intent: "complete"
198
- });
199
- }, [
200
- activeNode.activity,
201
- sales.payment.status,
202
- send,
203
- snapshot.status
204
- ]);
115
+ useEffect(() => setMemberLoginOpen(false), [session, snapshot.nodeId]);
205
116
  const memberAction = customer.visible ? {
206
117
  member: customer.member,
207
118
  memberName: customer.memberName,
@@ -211,7 +122,7 @@ function HDLKioskWorkflowView({ session, host, sales, config, isActive, renderId
211
122
  errorReference: (_customer$error = customer.error) === null || _customer$error === void 0 ? void 0 : _customer$error.traceId,
212
123
  onLogin: requestMemberLogin
213
124
  } : void 0;
214
- const canEndOrder = snapshot.status === "idle" && !resetting && !snapshot.pendingNavigation && !commandState.busy && !customer.busy && paymentSafeForReset;
125
+ const canEndOrder = snapshot.status === "idle" && !returning && !snapshot.pendingNavigation && !commandState.busy && !customer.busy && paymentSafeForReset;
215
126
  const cartDrawerModel = useMemo(() => createCartDrawerModel(sales, snapshot.context.primaryWeightedProductId), [sales, snapshot.context.primaryWeightedProductId]);
216
127
  const endOrderBottomBar = activeNode.activity === "paymentCompleted" ? void 0 : {
217
128
  ariaLabel: locales.getText("pisell2.hdl-kiosk.exit-order"),
@@ -226,25 +137,28 @@ function HDLKioskWorkflowView({ session, host, sales, config, isActive, renderId
226
137
  "aria-hidden": "true"
227
138
  }, /* @__PURE__ */ React.createElement("path", { d: "m15 5-7 7 7 7M8 12h10" })), /* @__PURE__ */ React.createElement("span", null, locales.getText("pisell2.hdl-kiosk.back")))
228
139
  };
229
- if (resetError) return /* @__PURE__ */ React.createElement(HDLKioskShell, { snapshot }, /* @__PURE__ */ React.createElement(HDLKioskBottomBarHost, null, /* @__PURE__ */ React.createElement(HDLKioskHeader, null), /* @__PURE__ */ React.createElement("main", { className: "hdl-shell__main" }, /* @__PURE__ */ React.createElement(BlockingNotice, {
140
+ if (returnError) return /* @__PURE__ */ React.createElement(HDLKioskWorkflowBlockingSurface, {
141
+ snapshot,
230
142
  title: locales.getText("pisell2.hdl-kiosk.reset-failed-title"),
231
143
  description: locales.getText("pisell2.hdl-kiosk.reset-failed-description"),
232
- reference: resetError.traceId
233
- }))));
144
+ reference: returnError.traceId
145
+ });
234
146
  if (snapshot.status === "blocked") {
235
147
  var _snapshot$lastError;
236
- return /* @__PURE__ */ React.createElement(HDLKioskShell, { snapshot }, /* @__PURE__ */ React.createElement(HDLKioskBottomBarHost, { mode: "hidden" }, /* @__PURE__ */ React.createElement(HDLKioskHeader, null), /* @__PURE__ */ React.createElement("main", { className: "hdl-shell__main" }, /* @__PURE__ */ React.createElement(BlockingNotice, {
148
+ return /* @__PURE__ */ React.createElement(HDLKioskWorkflowBlockingSurface, {
149
+ snapshot,
237
150
  title: locales.getText("pisell2.hdl-kiosk.blocked-title"),
238
151
  description: locales.getText("pisell2.hdl-kiosk.blocked-description"),
239
- reference: (_snapshot$lastError = snapshot.lastError) === null || _snapshot$lastError === void 0 ? void 0 : _snapshot$lastError.traceId
240
- }))));
152
+ reference: (_snapshot$lastError = snapshot.lastError) === null || _snapshot$lastError === void 0 ? void 0 : _snapshot$lastError.traceId,
153
+ hideBottomBar: true
154
+ });
241
155
  }
242
156
  return /* @__PURE__ */ React.createElement(HDLKioskShell, {
243
157
  snapshot,
244
158
  memberAction,
245
- variant: currentScreenId === "identity" ? "identityGate" : "default"
159
+ variant: screenDataNode.surfaceId === "identity" ? "identityGate" : "default"
246
160
  }, /* @__PURE__ */ React.createElement(HDLKioskBottomBarHost, {
247
- mode: ((_activeNode$presentat2 = activeNode.presentation) === null || _activeNode$presentat2 === void 0 ? void 0 : _activeNode$presentat2.mode) === "modal" || endOrderConfirmationOpen || memberLoginOpen ? "masked" : "visible",
161
+ mode: ((_activeNode$presentat = activeNode.presentation) === null || _activeNode$presentat === void 0 ? void 0 : _activeNode$presentat.mode) === "modal" || endOrderConfirmationOpen || memberLoginOpen ? "masked" : "visible",
248
162
  fallback: endOrderBottomBar,
249
163
  cartOverlayActions,
250
164
  promotionsAvailable: Boolean(renderCartContent)
@@ -257,7 +171,7 @@ function HDLKioskWorkflowView({ session, host, sales, config, isActive, renderId
257
171
  sales,
258
172
  send,
259
173
  commandState,
260
- resetting,
174
+ resetting: returning,
261
175
  capabilities: host.capabilities,
262
176
  businessMode: config.businessMode,
263
177
  scaleMinimumWeightKg: config.scaleTriggerMinimumWeightKg,
@@ -0,0 +1,387 @@
1
+ import React, { useCallback, useEffect, useRef, useState } from "react";
2
+ import "./index.less";
3
+ //#region src/components/HDLKiosk/ui/ScaleSimulatorConsole/index.tsx
4
+ const isScaleSimulatorApiAvailable = () => typeof window !== "undefined" && Boolean(window.pisellScaleSimulator);
5
+ const ACCESS_PASSWORD = "0000";
6
+ const PANEL_WIDTH = 720;
7
+ const PANEL_HEADER_VISIBLE_HEIGHT = 76;
8
+ const STATUS_OPTIONS = [
9
+ {
10
+ value: "stable",
11
+ label: "稳定"
12
+ },
13
+ {
14
+ value: "unstable",
15
+ label: "波动"
16
+ },
17
+ {
18
+ value: "overload",
19
+ label: "超载"
20
+ },
21
+ {
22
+ value: "negative",
23
+ label: "负数"
24
+ }
25
+ ];
26
+ const CONNECTION_LABELS = {
27
+ connected: "已连接",
28
+ connecting: "连接中",
29
+ disconnected: "已断开"
30
+ };
31
+ function getInitialPosition() {
32
+ if (typeof window === "undefined") return {
33
+ x: 32,
34
+ y: 96
35
+ };
36
+ return {
37
+ x: Math.max(20, Math.round((window.innerWidth - PANEL_WIDTH) / 2)),
38
+ y: Math.max(76, Math.round((window.innerHeight - 760) / 2))
39
+ };
40
+ }
41
+ function CloseIcon() {
42
+ return /* @__PURE__ */ React.createElement("svg", {
43
+ viewBox: "0 0 24 24",
44
+ "aria-hidden": "true"
45
+ }, /* @__PURE__ */ React.createElement("path", { d: "m6 6 12 12M18 6 6 18" }));
46
+ }
47
+ function MinimizeIcon({ minimized }) {
48
+ return /* @__PURE__ */ React.createElement("svg", {
49
+ viewBox: "0 0 24 24",
50
+ "aria-hidden": "true"
51
+ }, minimized ? /* @__PURE__ */ React.createElement("path", { d: "M7 10V7h3m4 0h3v3m0 4v3h-3m-4 0H7v-3" }) : /* @__PURE__ */ React.createElement("path", { d: "M6 16h12" }));
52
+ }
53
+ function ScaleGlyph() {
54
+ return /* @__PURE__ */ React.createElement("svg", {
55
+ viewBox: "0 0 32 32",
56
+ "aria-hidden": "true"
57
+ }, /* @__PURE__ */ React.createElement("path", { d: "M8 12h16l-1.5 4h-13L8 12Z" }), /* @__PURE__ */ React.createElement("path", { d: "M10 16h12l2 11H8l2-11Z" }), /* @__PURE__ */ React.createElement("rect", {
58
+ x: "12",
59
+ y: "19",
60
+ width: "8",
61
+ height: "5",
62
+ rx: "1.5"
63
+ }), /* @__PURE__ */ React.createElement("path", { d: "M11 8h10" }));
64
+ }
65
+ function ScaleSimulatorConsole({ authOpen, onAuthClose }) {
66
+ var _snapshot$weight, _STATUS_OPTIONS$find$, _STATUS_OPTIONS$find;
67
+ const [password, setPassword] = useState("");
68
+ const [passwordError, setPasswordError] = useState(false);
69
+ const [panelOpen, setPanelOpen] = useState(false);
70
+ const [minimized, setMinimized] = useState(false);
71
+ const [position, setPosition] = useState(getInitialPosition);
72
+ const [snapshot, setSnapshot] = useState(null);
73
+ const [api, setApi] = useState(null);
74
+ const [apiRevision, setApiRevision] = useState(0);
75
+ const [manualWeight, setManualWeight] = useState("1000");
76
+ const [manualStatus, setManualStatus] = useState("stable");
77
+ const [actionError, setActionError] = useState(null);
78
+ const passwordInputRef = useRef(null);
79
+ const panelRef = useRef(null);
80
+ const dragRef = useRef(null);
81
+ useEffect(() => {
82
+ var _passwordInputRef$cur;
83
+ if (!authOpen) return;
84
+ setPassword("");
85
+ setPasswordError(false);
86
+ (_passwordInputRef$cur = passwordInputRef.current) === null || _passwordInputRef$cur === void 0 || _passwordInputRef$cur.focus();
87
+ }, [authOpen]);
88
+ useEffect(() => {
89
+ var _window$pisellScaleSi;
90
+ if (!panelOpen) return void 0;
91
+ const nextApi = (_window$pisellScaleSi = window.pisellScaleSimulator) !== null && _window$pisellScaleSi !== void 0 ? _window$pisellScaleSi : null;
92
+ setApi(nextApi);
93
+ if (!nextApi) {
94
+ setSnapshot(null);
95
+ return;
96
+ }
97
+ setSnapshot(nextApi.getSnapshot());
98
+ return nextApi.subscribe(setSnapshot);
99
+ }, [panelOpen, apiRevision]);
100
+ useEffect(() => {
101
+ const handlePointerMove = (event) => {
102
+ var _panelRef$current$off, _panelRef$current;
103
+ const drag = dragRef.current;
104
+ if (!drag || drag.pointerId !== event.pointerId) return;
105
+ const panelWidth = (_panelRef$current$off = (_panelRef$current = panelRef.current) === null || _panelRef$current === void 0 ? void 0 : _panelRef$current.offsetWidth) !== null && _panelRef$current$off !== void 0 ? _panelRef$current$off : PANEL_WIDTH;
106
+ const nextX = drag.origin.x + event.clientX - drag.startX;
107
+ const nextY = drag.origin.y + event.clientY - drag.startY;
108
+ setPosition({
109
+ x: Math.min(Math.max(8, nextX), Math.max(8, window.innerWidth - panelWidth - 8)),
110
+ y: Math.min(Math.max(8, nextY), Math.max(8, window.innerHeight - PANEL_HEADER_VISIBLE_HEIGHT))
111
+ });
112
+ };
113
+ const handlePointerUp = (event) => {
114
+ var _dragRef$current;
115
+ if (((_dragRef$current = dragRef.current) === null || _dragRef$current === void 0 ? void 0 : _dragRef$current.pointerId) === event.pointerId) dragRef.current = null;
116
+ };
117
+ window.addEventListener("pointermove", handlePointerMove);
118
+ window.addEventListener("pointerup", handlePointerUp);
119
+ window.addEventListener("pointercancel", handlePointerUp);
120
+ return () => {
121
+ window.removeEventListener("pointermove", handlePointerMove);
122
+ window.removeEventListener("pointerup", handlePointerUp);
123
+ window.removeEventListener("pointercancel", handlePointerUp);
124
+ };
125
+ }, []);
126
+ const runAction = useCallback((action) => {
127
+ if (!api) return;
128
+ try {
129
+ setActionError(null);
130
+ action(api);
131
+ } catch (error) {
132
+ setActionError(error instanceof Error ? error.message : String(error));
133
+ }
134
+ }, [api]);
135
+ const submitPassword = (event) => {
136
+ event.preventDefault();
137
+ if (password !== ACCESS_PASSWORD) {
138
+ var _passwordInputRef$cur2;
139
+ setPasswordError(true);
140
+ (_passwordInputRef$cur2 = passwordInputRef.current) === null || _passwordInputRef$cur2 === void 0 || _passwordInputRef$cur2.select();
141
+ return;
142
+ }
143
+ setPasswordError(false);
144
+ setPanelOpen(true);
145
+ setMinimized(false);
146
+ setApiRevision((current) => current + 1);
147
+ onAuthClose();
148
+ };
149
+ const closePanel = () => {
150
+ api === null || api === void 0 || api.stopPlayback();
151
+ setPanelOpen(false);
152
+ setActionError(null);
153
+ };
154
+ const startDrag = (event) => {
155
+ if (event.target.closest("button")) return;
156
+ dragRef.current = {
157
+ pointerId: event.pointerId,
158
+ startX: event.clientX,
159
+ startY: event.clientY,
160
+ origin: position
161
+ };
162
+ };
163
+ const applyManualWeight = () => {
164
+ const weight = Number(manualWeight);
165
+ if (!Number.isFinite(weight)) {
166
+ setActionError("请输入有效的克重数值。");
167
+ return;
168
+ }
169
+ runAction((simulator) => simulator.setSnapshot({
170
+ weight,
171
+ status: manualStatus,
172
+ connectionState: "connected"
173
+ }));
174
+ };
175
+ const playPlaceItem = () => {
176
+ runAction((simulator) => simulator.play([
177
+ {
178
+ weight: 0,
179
+ status: "stable",
180
+ connectionState: "connected"
181
+ },
182
+ {
183
+ delayMs: 350,
184
+ weight: 1440,
185
+ status: "unstable"
186
+ },
187
+ {
188
+ delayMs: 160,
189
+ weight: 2080,
190
+ status: "unstable"
191
+ },
192
+ {
193
+ delayMs: 160,
194
+ weight: 1970,
195
+ status: "unstable"
196
+ },
197
+ {
198
+ delayMs: 320,
199
+ weight: 2e3,
200
+ status: "stable"
201
+ }
202
+ ]));
203
+ };
204
+ const playRemoveItem = () => {
205
+ const currentWeight = (snapshot === null || snapshot === void 0 ? void 0 : snapshot.weight) || 1e3;
206
+ runAction((simulator) => simulator.play([
207
+ {
208
+ weight: currentWeight,
209
+ status: "stable",
210
+ connectionState: "connected"
211
+ },
212
+ {
213
+ delayMs: 180,
214
+ weight: currentWeight * .45,
215
+ status: "unstable"
216
+ },
217
+ {
218
+ delayMs: 160,
219
+ weight: 28,
220
+ status: "unstable"
221
+ },
222
+ {
223
+ delayMs: 280,
224
+ weight: 0,
225
+ status: "stable"
226
+ }
227
+ ]));
228
+ };
229
+ const playJitter = () => {
230
+ const base = Math.max(100, (snapshot === null || snapshot === void 0 ? void 0 : snapshot.weight) || 1e3);
231
+ runAction((simulator) => simulator.play([
232
+ {
233
+ weight: base - 12,
234
+ status: "unstable",
235
+ connectionState: "connected"
236
+ },
237
+ {
238
+ delayMs: 220,
239
+ weight: base + 9,
240
+ status: "unstable"
241
+ },
242
+ {
243
+ delayMs: 220,
244
+ weight: base - 5,
245
+ status: "unstable"
246
+ },
247
+ {
248
+ delayMs: 220,
249
+ weight: base + 3,
250
+ status: "unstable"
251
+ }
252
+ ], { loop: true }));
253
+ };
254
+ const playReconnect = () => {
255
+ runAction((simulator) => simulator.play([
256
+ {
257
+ weight: 0,
258
+ status: "stable",
259
+ connectionState: "disconnected"
260
+ },
261
+ {
262
+ delayMs: 1500,
263
+ connectionState: "connecting"
264
+ },
265
+ {
266
+ delayMs: 900,
267
+ weight: 0,
268
+ status: "stable",
269
+ connectionState: "connected"
270
+ }
271
+ ]));
272
+ };
273
+ const displayWeight = (_snapshot$weight = snapshot === null || snapshot === void 0 ? void 0 : snapshot.weight) !== null && _snapshot$weight !== void 0 ? _snapshot$weight : 0;
274
+ const apiAvailable = Boolean(api);
275
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, authOpen ? /* @__PURE__ */ React.createElement("div", {
276
+ className: "hdl-scale-simulator-gate",
277
+ role: "presentation",
278
+ onMouseDown: (event) => {
279
+ if (event.target === event.currentTarget) onAuthClose();
280
+ }
281
+ }, /* @__PURE__ */ React.createElement("form", {
282
+ className: "hdl-scale-simulator-gate__card",
283
+ "aria-label": "称重模拟器访问验证",
284
+ onSubmit: submitPassword
285
+ }, /* @__PURE__ */ React.createElement("div", { className: "hdl-scale-simulator-gate__icon" }, /* @__PURE__ */ React.createElement(ScaleGlyph, null)), /* @__PURE__ */ React.createElement("div", { className: "hdl-scale-simulator-gate__copy" }, /* @__PURE__ */ React.createElement("small", null, "ENGINEERING ACCESS"), /* @__PURE__ */ React.createElement("h2", null, "称重模拟器"), /* @__PURE__ */ React.createElement("p", null, "请输入工程密码以打开设备控制台")), /* @__PURE__ */ React.createElement("label", { className: passwordError ? "is-error" : "" }, /* @__PURE__ */ React.createElement("span", null, "访问密码"), /* @__PURE__ */ React.createElement("input", {
286
+ ref: passwordInputRef,
287
+ type: "password",
288
+ inputMode: "numeric",
289
+ autoComplete: "off",
290
+ maxLength: 4,
291
+ value: password,
292
+ "aria-invalid": passwordError,
293
+ onChange: (event) => {
294
+ setPassword(event.target.value.replace(/\D/g, "").slice(0, 4));
295
+ setPasswordError(false);
296
+ },
297
+ onKeyDown: (event) => {
298
+ if (event.key === "Escape") onAuthClose();
299
+ }
300
+ })), passwordError ? /* @__PURE__ */ React.createElement("p", {
301
+ className: "hdl-scale-simulator-gate__error",
302
+ role: "alert"
303
+ }, "密码不正确,请重新输入。") : null, /* @__PURE__ */ React.createElement("div", { className: "hdl-scale-simulator-gate__actions" }, /* @__PURE__ */ React.createElement("button", {
304
+ type: "button",
305
+ onClick: onAuthClose
306
+ }, "取消"), /* @__PURE__ */ React.createElement("button", {
307
+ type: "submit",
308
+ className: "is-primary"
309
+ }, "打开控制台")))) : null, panelOpen ? /* @__PURE__ */ React.createElement("aside", {
310
+ ref: panelRef,
311
+ className: `hdl-scale-simulator-panel${minimized ? " is-minimized" : ""}`,
312
+ style: {
313
+ left: position.x,
314
+ top: position.y
315
+ },
316
+ "aria-label": "称重模拟器控制台"
317
+ }, /* @__PURE__ */ React.createElement("header", {
318
+ className: "hdl-scale-simulator-panel__header",
319
+ onPointerDown: startDrag
320
+ }, /* @__PURE__ */ React.createElement("span", { className: "hdl-scale-simulator-panel__brand" }, /* @__PURE__ */ React.createElement(ScaleGlyph, null)), /* @__PURE__ */ React.createElement("span", { className: "hdl-scale-simulator-panel__title" }, /* @__PURE__ */ React.createElement("small", null, "DEVICE LAB"), /* @__PURE__ */ React.createElement("strong", null, "称重模拟器")), /* @__PURE__ */ React.createElement("span", { className: `hdl-scale-simulator-panel__availability ${apiAvailable ? "is-online" : "is-offline"}` }, /* @__PURE__ */ React.createElement("i", null), apiAvailable ? `API v${api === null || api === void 0 ? void 0 : api.version}` : "API 未连接"), /* @__PURE__ */ React.createElement("span", { className: "hdl-scale-simulator-panel__window-actions" }, /* @__PURE__ */ React.createElement("button", {
321
+ type: "button",
322
+ "aria-label": minimized ? "还原称重模拟器" : "最小化称重模拟器",
323
+ onClick: () => setMinimized((current) => !current)
324
+ }, /* @__PURE__ */ React.createElement(MinimizeIcon, { minimized })), /* @__PURE__ */ React.createElement("button", {
325
+ type: "button",
326
+ "aria-label": "关闭称重模拟器",
327
+ onClick: closePanel
328
+ }, /* @__PURE__ */ React.createElement(CloseIcon, null)))), !minimized ? /* @__PURE__ */ React.createElement("div", { className: "hdl-scale-simulator-panel__body" }, !apiAvailable ? /* @__PURE__ */ React.createElement("div", {
329
+ className: "hdl-scale-simulator-panel__unavailable",
330
+ role: "status"
331
+ }, /* @__PURE__ */ React.createElement("strong", null, "未检测到 Android 称重模拟 API"), /* @__PURE__ */ React.createElement("p", null, "请确认当前是已启用模拟能力的 Android 测试包,并重新检测。"), /* @__PURE__ */ React.createElement("button", {
332
+ type: "button",
333
+ onClick: () => setApiRevision((current) => current + 1)
334
+ }, "重新检测")) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("section", { className: "hdl-scale-simulator-readout" }, /* @__PURE__ */ React.createElement("div", { className: "hdl-scale-simulator-readout__screen" }, /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("i", { "aria-hidden": "true" }), "NET WEIGHT"), /* @__PURE__ */ React.createElement("strong", null, (displayWeight / 1e3).toFixed(3)), /* @__PURE__ */ React.createElement("b", null, "kg"), /* @__PURE__ */ React.createElement("small", null, displayWeight.toFixed(0), " g")), /* @__PURE__ */ React.createElement("div", { className: "hdl-scale-simulator-readout__telemetry" }, /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("small", null, "设备连接"), /* @__PURE__ */ React.createElement("strong", { className: `is-${snapshot === null || snapshot === void 0 ? void 0 : snapshot.connectionState}` }, snapshot ? CONNECTION_LABELS[snapshot.connectionState] : "未知")), /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("small", null, "读数状态"), /* @__PURE__ */ React.createElement("strong", null, (_STATUS_OPTIONS$find$ = (_STATUS_OPTIONS$find = STATUS_OPTIONS.find((option) => option.value === (snapshot === null || snapshot === void 0 ? void 0 : snapshot.status))) === null || _STATUS_OPTIONS$find === void 0 ? void 0 : _STATUS_OPTIONS$find.label) !== null && _STATUS_OPTIONS$find$ !== void 0 ? _STATUS_OPTIONS$find$ : "未知")), /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("small", null, "业务监听"), /* @__PURE__ */ React.createElement("strong", null, (snapshot === null || snapshot === void 0 ? void 0 : snapshot.isWeighing) ? "运行中" : "未启动")), /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("small", null, "场景脚本"), /* @__PURE__ */ React.createElement("strong", null, (snapshot === null || snapshot === void 0 ? void 0 : snapshot.isPlaying) ? "播放中" : "已停止")))), !(snapshot === null || snapshot === void 0 ? void 0 : snapshot.isWeighing) ? /* @__PURE__ */ React.createElement("p", { className: "hdl-scale-simulator-panel__notice" }, "当前称重业务尚未启动监听。控制值会保留,但业务页面启动称重后才会收到读数。") : null, /* @__PURE__ */ React.createElement("section", { className: "hdl-scale-simulator-section" }, /* @__PURE__ */ React.createElement("div", { className: "hdl-scale-simulator-section__heading" }, /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("small", null, "MANUAL INPUT"), /* @__PURE__ */ React.createElement("strong", null, "手动称重")), /* @__PURE__ */ React.createElement("button", {
335
+ type: "button",
336
+ className: "is-subtle",
337
+ onClick: () => runAction((simulator) => simulator.reset())
338
+ }, "重置设备")), /* @__PURE__ */ React.createElement("div", { className: "hdl-scale-simulator-manual" }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("span", null, "原始重量"), /* @__PURE__ */ React.createElement("span", { className: "hdl-scale-simulator-manual__input" }, /* @__PURE__ */ React.createElement("input", {
339
+ type: "number",
340
+ step: "1",
341
+ "aria-label": "原始重量",
342
+ value: manualWeight,
343
+ onChange: (event) => setManualWeight(event.target.value)
344
+ }), /* @__PURE__ */ React.createElement("b", null, "g"))), /* @__PURE__ */ React.createElement("fieldset", null, /* @__PURE__ */ React.createElement("legend", null, "重量状态"), /* @__PURE__ */ React.createElement("span", null, STATUS_OPTIONS.map((option) => /* @__PURE__ */ React.createElement("button", {
345
+ key: option.value,
346
+ type: "button",
347
+ className: manualStatus === option.value ? "is-active" : "",
348
+ onClick: () => setManualStatus(option.value)
349
+ }, option.label)))), /* @__PURE__ */ React.createElement("button", {
350
+ type: "button",
351
+ className: "hdl-scale-simulator-manual__apply",
352
+ onClick: applyManualWeight
353
+ }, "应用读数"))), /* @__PURE__ */ React.createElement("section", { className: "hdl-scale-simulator-section" }, /* @__PURE__ */ React.createElement("div", { className: "hdl-scale-simulator-section__heading" }, /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement("small", null, "REAL-WORLD PRESETS"), /* @__PURE__ */ React.createElement("strong", null, "实际场景")), (snapshot === null || snapshot === void 0 ? void 0 : snapshot.isPlaying) ? /* @__PURE__ */ React.createElement("button", {
354
+ type: "button",
355
+ className: "is-stop",
356
+ onClick: () => runAction((simulator) => simulator.stopPlayback())
357
+ }, "停止场景") : null), /* @__PURE__ */ React.createElement("div", { className: "hdl-scale-simulator-presets" }, /* @__PURE__ */ React.createElement("button", {
358
+ type: "button",
359
+ onClick: playPlaceItem
360
+ }, /* @__PURE__ */ React.createElement("span", null, "01"), /* @__PURE__ */ React.createElement("strong", null, "放上 2kg 商品"), /* @__PURE__ */ React.createElement("small", null, "波动后稳定")), /* @__PURE__ */ React.createElement("button", {
361
+ type: "button",
362
+ onClick: playRemoveItem
363
+ }, /* @__PURE__ */ React.createElement("span", null, "02"), /* @__PURE__ */ React.createElement("strong", null, "取走商品"), /* @__PURE__ */ React.createElement("small", null, "逐步回落归零")), /* @__PURE__ */ React.createElement("button", {
364
+ type: "button",
365
+ onClick: playJitter
366
+ }, /* @__PURE__ */ React.createElement("span", null, "03"), /* @__PURE__ */ React.createElement("strong", null, "持续抖动"), /* @__PURE__ */ React.createElement("small", null, "循环不稳定读数")), /* @__PURE__ */ React.createElement("button", {
367
+ type: "button",
368
+ onClick: playReconnect
369
+ }, /* @__PURE__ */ React.createElement("span", null, "04"), /* @__PURE__ */ React.createElement("strong", null, "断线重连"), /* @__PURE__ */ React.createElement("small", null, "断开、连接中、恢复")), /* @__PURE__ */ React.createElement("button", {
370
+ type: "button",
371
+ onClick: () => runAction((simulator) => simulator.overload())
372
+ }, /* @__PURE__ */ React.createElement("span", null, "05"), /* @__PURE__ */ React.createElement("strong", null, "设备超载"), /* @__PURE__ */ React.createElement("small", null, "30kg overload")), /* @__PURE__ */ React.createElement("button", {
373
+ type: "button",
374
+ onClick: () => runAction((simulator) => simulator.setWeight(-50))
375
+ }, /* @__PURE__ */ React.createElement("span", null, "06"), /* @__PURE__ */ React.createElement("strong", null, "负数读数"), /* @__PURE__ */ React.createElement("small", null, "-50g negative")), /* @__PURE__ */ React.createElement("button", {
376
+ type: "button",
377
+ onClick: () => runAction((simulator) => simulator.zero())
378
+ }, /* @__PURE__ */ React.createElement("span", null, "07"), /* @__PURE__ */ React.createElement("strong", null, "快速归零"), /* @__PURE__ */ React.createElement("small", null, "0g stable")), /* @__PURE__ */ React.createElement("button", {
379
+ type: "button",
380
+ onClick: () => runAction((simulator) => simulator.disconnect())
381
+ }, /* @__PURE__ */ React.createElement("span", null, "08"), /* @__PURE__ */ React.createElement("strong", null, "立即断开"), /* @__PURE__ */ React.createElement("small", null, "disconnected")))), actionError ? /* @__PURE__ */ React.createElement("p", {
382
+ className: "hdl-scale-simulator-panel__error",
383
+ role: "alert"
384
+ }, actionError) : null)) : null) : null);
385
+ }
386
+ //#endregion
387
+ export { ScaleSimulatorConsole as default, isScaleSimulatorApiAvailable };