@pisell/private-materials 6.12.200 → 6.12.201

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 (29) 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/index.js +9 -6
  10. package/es/components/HDLKiosk/locales.js +15 -0
  11. package/es/components/HDLKiosk/runtime/entryPreparation.js +48 -0
  12. package/es/components/HDLKiosk/runtime/session/createSession.js +46 -2
  13. package/es/components/HDLKiosk/slices/customization/Screen/index.js +25 -2
  14. package/es/components/HDLKiosk/ui/controllers/useHDLKioskSessionController.js +50 -9
  15. package/es/components/HDLKiosk/ui/entry/Screen/index.js +5 -2
  16. package/es/components/HDLKiosk/ui/entry/Screen/index.less +10 -0
  17. package/es/components/bigSale/templates/HDLKiosk/index.js +3 -1
  18. package/es/components/bigSale/templates/HDLKiosk/payment/HDLKioskPaymentRuntime.js +163 -25
  19. package/lib/components/HDLKiosk/index.js +9 -6
  20. package/lib/components/HDLKiosk/locales.js +15 -0
  21. package/lib/components/HDLKiosk/runtime/entryPreparation.js +48 -0
  22. package/lib/components/HDLKiosk/runtime/session/createSession.js +46 -2
  23. package/lib/components/HDLKiosk/slices/customization/Screen/index.js +25 -2
  24. package/lib/components/HDLKiosk/ui/controllers/useHDLKioskSessionController.js +49 -8
  25. package/lib/components/HDLKiosk/ui/entry/Screen/index.js +5 -2
  26. package/lib/components/HDLKiosk/ui/entry/Screen/index.less +10 -0
  27. package/lib/components/bigSale/templates/HDLKiosk/index.js +3 -1
  28. package/lib/components/bigSale/templates/HDLKiosk/payment/HDLKioskPaymentRuntime.js +162 -24
  29. package/package.json +3 -3
@@ -2,43 +2,83 @@ require("../../../../_virtual/_rolldown/runtime.js");
2
2
  const require_asyncToGenerator = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
3
3
  require("../../runtime/admissionPolicy.js");
4
4
  const require_application = require("../../runtime/application.js");
5
+ const require_entryPreparation = require("../../runtime/entryPreparation.js");
5
6
  let react = require("react");
6
7
  //#region src/components/HDLKiosk/ui/controllers/useHDLKioskSessionController.ts
7
8
  /**
8
9
  * 文件角色:把 React Entry 状态适配到无头 Application Runtime。
9
- * 运行机制:Controller 只处理能力/可见性和 UI pending;Trigger 路由、Session 创建、
10
- * ensure、单会话准入与销毁均由 Runtime 持有。
10
+ * 运行机制:Controller 先建立 Entry Host 清理屏障,再激活 Trigger;Session 创建、ensure、
11
+ * 单会话准入与销毁均由 Runtime 持有。
11
12
  * 边界:不直接创建 Actor,也不消费具体 Screen 的局部交互。
12
13
  */
13
- function useHDLKioskSessionController({ host, config, isActive }) {
14
+ function useHDLKioskSessionController({ host, config, isActive, entryPreparationBlocked = false }) {
14
15
  const applicationRuntime = (0, react.useMemo)(() => require_application.hdlKioskApplication.bind({
15
16
  host,
16
17
  config
17
18
  }), [config, host]);
18
19
  const snapshot = (0, react.useSyncExternalStore)(applicationRuntime.subscribe, applicationRuntime.getSnapshot, applicationRuntime.getSnapshot);
20
+ const [entryPreparationAttempt, setEntryPreparationAttempt] = (0, react.useState)(0);
21
+ const [entryPreparation, setEntryPreparation] = (0, react.useState)(() => ({ status: isActive ? "preparing" : "inactive" }));
19
22
  (0, react.useEffect)(() => {
20
23
  return () => applicationRuntime.dispose();
21
24
  }, [applicationRuntime]);
22
25
  (0, react.useEffect)(() => {
23
26
  if (!isActive) {
24
27
  applicationRuntime.deactivate();
28
+ setEntryPreparation({ status: "inactive" });
25
29
  return;
26
30
  }
27
- applicationRuntime.activate();
28
- return () => applicationRuntime.deactivate();
29
- }, [applicationRuntime, isActive]);
31
+ if (applicationRuntime.getSnapshot().session) {
32
+ applicationRuntime.activate();
33
+ setEntryPreparation({ status: "ready" });
34
+ return () => applicationRuntime.deactivate();
35
+ }
36
+ if (entryPreparationBlocked) {
37
+ applicationRuntime.deactivate();
38
+ setEntryPreparation({ status: "preparing" });
39
+ return () => applicationRuntime.deactivate();
40
+ }
41
+ applicationRuntime.deactivate();
42
+ setEntryPreparation({ status: "preparing" });
43
+ const abortController = new AbortController();
44
+ require_entryPreparation.prepareHDLKioskEntry(host, abortController.signal).then((result) => {
45
+ if (abortController.signal.aborted) return;
46
+ if (result.status === "succeeded") {
47
+ setEntryPreparation({ status: "ready" });
48
+ applicationRuntime.activate();
49
+ return;
50
+ }
51
+ setEntryPreparation({
52
+ status: "failed",
53
+ errorReference: result.status === "failed" || result.status === "partialFailure" || result.status === "unknown" ? result.error.traceId : result.reason || "entryPreparationCancelled"
54
+ });
55
+ });
56
+ return () => {
57
+ abortController.abort();
58
+ applicationRuntime.deactivate();
59
+ };
60
+ }, [
61
+ applicationRuntime,
62
+ entryPreparationBlocked,
63
+ entryPreparationAttempt,
64
+ host,
65
+ isActive
66
+ ]);
30
67
  const start = (0, react.useCallback)(function() {
31
68
  var _ref = require_asyncToGenerator._asyncToGenerator(function* ({ entry }) {
69
+ if (entryPreparation.status !== "ready") return void 0;
32
70
  const result = yield applicationRuntime.start(entry);
33
71
  return result.status === "started" || result.status === "duplicate" ? result.session : void 0;
34
72
  });
35
73
  return function(_x) {
36
74
  return _ref.apply(this, arguments);
37
75
  };
38
- }(), [applicationRuntime]);
76
+ }(), [applicationRuntime, entryPreparation.status]);
39
77
  return {
40
78
  session: snapshot.session,
41
79
  starting: snapshot.status === "starting",
80
+ preparingEntry: entryPreparation.status === "preparing",
81
+ entryPreparationErrorReference: entryPreparation.status === "failed" ? entryPreparation.errorReference : void 0,
42
82
  startErrorReference: snapshot.startFailure ? typeof snapshot.startFailure.error === "object" && snapshot.startFailure.error !== null && "traceId" in snapshot.startFailure.error && typeof snapshot.startFailure.error.traceId === "string" ? snapshot.startFailure.error.traceId : snapshot.startFailure.reason : void 0,
43
83
  exiting: snapshot.status === "exiting",
44
84
  exitError: snapshot.exitError,
@@ -48,7 +88,8 @@ function useHDLKioskSessionController({ host, config, isActive }) {
48
88
  requestExit: applicationRuntime.requestExit,
49
89
  resolveExit: applicationRuntime.resolveExit,
50
90
  completeOrder: applicationRuntime.completeOrder,
51
- recover: applicationRuntime.recover
91
+ recover: applicationRuntime.recover,
92
+ retryEntryPreparation: () => setEntryPreparationAttempt((attempt) => attempt + 1)
52
93
  };
53
94
  }
54
95
  //#endregion
@@ -179,7 +179,7 @@ function EntryGraphic({ entry }) {
179
179
  if (entry === "barcode") return /* @__PURE__ */ react.default.createElement(BarcodeGraphic, null);
180
180
  return /* @__PURE__ */ react.default.createElement(ScaleGraphic, null);
181
181
  }
182
- function EntryScreen({ locale, model, onLocaleChange, onTechnicalSupportClick, onSelect, busy = false, errorReference, errorMessage = "Unable to start a safe order session." }) {
182
+ function EntryScreen({ locale, model, onLocaleChange, onTechnicalSupportClick, onSelect, busy = false, errorReference, errorMessage = "Unable to start a safe order session.", retryLabel, onRetry }) {
183
183
  const [reachMode, setReachMode] = (0, react.useState)(false);
184
184
  const entryLocale = locale || "en";
185
185
  return /* @__PURE__ */ react.default.createElement("section", {
@@ -238,7 +238,10 @@ function EntryScreen({ locale, model, onLocaleChange, onTechnicalSupportClick, o
238
238
  }, model.assistanceMessage) : null, errorReference ? /* @__PURE__ */ react.default.createElement("div", {
239
239
  className: "hdl-inline-error hdl-entry-screen__error",
240
240
  role: "alert"
241
- }, /* @__PURE__ */ react.default.createElement("strong", null, errorMessage), /* @__PURE__ */ react.default.createElement("small", null, errorReference)) : null), /* @__PURE__ */ react.default.createElement("footer", { className: "hdl-entry-screen__utilities" }, /* @__PURE__ */ react.default.createElement("button", {
241
+ }, /* @__PURE__ */ react.default.createElement("strong", null, errorMessage), /* @__PURE__ */ react.default.createElement("small", null, errorReference), onRetry && retryLabel ? /* @__PURE__ */ react.default.createElement("button", {
242
+ type: "button",
243
+ onClick: onRetry
244
+ }, retryLabel) : null) : null), /* @__PURE__ */ react.default.createElement("footer", { className: "hdl-entry-screen__utilities" }, /* @__PURE__ */ react.default.createElement("button", {
242
245
  className: `hdl-entry-reach${reachMode ? " is-active" : ""}`,
243
246
  type: "button",
244
247
  "aria-pressed": reachMode,
@@ -745,6 +745,16 @@
745
745
  color: rgba(255, 255, 255, 0.68);
746
746
  }
747
747
 
748
+ .hdl-entry-screen__error button {
749
+ align-self: flex-start;
750
+ border: 1px solid rgba(255, 255, 255, 0.45);
751
+ border-radius: 999px;
752
+ padding: 7px 14px;
753
+ background: rgba(255, 255, 255, 0.12);
754
+ color: #fff;
755
+ cursor: pointer;
756
+ }
757
+
748
758
  .hdl-entry-screen__utilities {
749
759
  position: absolute;
750
760
  right: 52px;
@@ -158,9 +158,11 @@ function HDLKioskBigSaleTemplate({ isActive = true, context, businessCode, local
158
158
  renderCartContent,
159
159
  cartOverlayActions
160
160
  }), /* @__PURE__ */ react.default.createElement(require_HDLKioskPaymentRuntime.HDLKioskPaymentRuntime, {
161
+ active: isActive,
161
162
  context,
162
163
  controllerRef: paymentControllerRef,
163
- onPaymentResultChange: handlePaymentResultChange
164
+ onPaymentResultChange: handlePaymentResultChange,
165
+ telemetry: host.telemetry
164
166
  }), orderNoteModal);
165
167
  }
166
168
  //#endregion
@@ -1,4 +1,5 @@
1
1
  const require_runtime = require("../../../../../_virtual/_rolldown/runtime.js");
2
+ const require_objectSpread2 = require("../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
2
3
  const require_asyncToGenerator = require("../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
3
4
  const require_useEngineContext = require("../../../../../hooks/useEngineContext.js");
4
5
  const require_constants = require("../../../../checkout/constants.js");
@@ -17,6 +18,9 @@ react = require_runtime.__toESM(react);
17
18
  * BigSale 模板内的 Kiosk 支付桥。它持有需要 React/设备 UI 的 PaymentMethodRuntime,
18
19
  * 再把窄命令交给独立 HDLKiosk Host;Core 不感知 BigSale、PiPayment 或 window.app。
19
20
  */
21
+ function diagnosticText(value, fallback = "unknown") {
22
+ return (String(value !== null && value !== void 0 ? value : "").trim() || fallback).slice(0, 200);
23
+ }
20
24
  function asKioskMethod(method) {
21
25
  var _raw$channel_applicat;
22
26
  const raw = method;
@@ -37,7 +41,7 @@ function currentAmount(context) {
37
41
  const amount = require_transactionState.resolveBigSaleCurrentAmountDue(context);
38
42
  return typeof amount === "number" && Number.isFinite(amount) && amount > 0 ? amount : 0;
39
43
  }
40
- function HDLKioskPaymentRuntime({ context, controllerRef, onPaymentResultChange }) {
44
+ function HDLKioskPaymentRuntime({ active, context, controllerRef, onPaymentResultChange, telemetry }) {
41
45
  var _context$sales$tempOr, _engineContext$appHel5;
42
46
  const engineContext = require_useEngineContext.default();
43
47
  const runtimeRef = (0, react.useRef)(null);
@@ -45,11 +49,31 @@ function HDLKioskPaymentRuntime({ context, controllerRef, onPaymentResultChange
45
49
  const rawMethodsRef = (0, react.useRef)(/* @__PURE__ */ new Map());
46
50
  const paymentResultContextRef = (0, react.useRef)(context);
47
51
  const paymentResultChangeRef = (0, react.useRef)(onPaymentResultChange);
52
+ const activeRef = (0, react.useRef)(active);
53
+ const staffPaymentAttemptRef = (0, react.useRef)();
48
54
  paymentResultContextRef.current = context;
49
55
  paymentResultChangeRef.current = onPaymentResultChange;
56
+ activeRef.current = active;
50
57
  const authorizationStore = (0, react.useMemo)(() => require_staffPaymentAuthorization.createStaffPaymentAuthorizationStore(), []);
51
58
  const baseSales = context.sales.bookingTicket;
52
59
  const currencySymbol = ((_context$sales$tempOr = context.sales.tempOrder) === null || _context$sales$tempOr === void 0 ? void 0 : _context$sales$tempOr.currency_symbol) || "$";
60
+ const emitDiagnostic = (0, react.useCallback)((name, traceId, attributes) => {
61
+ try {
62
+ telemetry.emit({
63
+ name,
64
+ traceId,
65
+ occurredAt: Date.now(),
66
+ attributes
67
+ });
68
+ } catch (_unused) {}
69
+ }, [telemetry]);
70
+ (0, react.useEffect)(() => {
71
+ var _window$location;
72
+ emitDiagnostic("hdlKiosk.runtime.lifecycle", `hdl-payment-runtime:${Date.now()}:${active ? "active" : "inactive"}`, {
73
+ phase: active ? "activated" : "deactivated",
74
+ pathname: diagnosticText((_window$location = window.location) === null || _window$location === void 0 ? void 0 : _window$location.pathname, "/")
75
+ });
76
+ }, [active, emitDiagnostic]);
53
77
  const controller = (0, react.useMemo)(() => ({
54
78
  loadPaymentMethods: function() {
55
79
  var _ref = require_asyncToGenerator._asyncToGenerator(function* () {
@@ -128,6 +152,19 @@ function HDLKioskPaymentRuntime({ context, controllerRef, onPaymentResultChange
128
152
  if (typeof (globalApp === null || globalApp === void 0 ? void 0 : globalApp.runFunction) !== "function") return require_normalize.failed("staffPaymentAuthorizationUnavailable", "staff");
129
153
  const authorization = authorizationStore.begin();
130
154
  if (!authorization) return require_normalize.failed("staffPaymentAuthorizationInProgress", "retry");
155
+ const startedAt = Date.now();
156
+ const attempt = {
157
+ attemptId: `hdl-staff-payment:${startedAt}:${authorization.token}`,
158
+ authorization,
159
+ methodCode: method.code,
160
+ startedAt
161
+ };
162
+ staffPaymentAttemptRef.current = attempt;
163
+ emitDiagnostic("hdlKiosk.staffPayment.authorization", attempt.attemptId, {
164
+ phase: "started",
165
+ authorizationToken: authorization.token,
166
+ methodCode: method.code
167
+ });
131
168
  try {
132
169
  var _baseSales$getOtherPa;
133
170
  const otherParams = (yield baseSales === null || baseSales === void 0 || (_baseSales$getOtherPa = baseSales.getOtherParams) === null || _baseSales$getOtherPa === void 0 ? void 0 : _baseSales$getOtherPa.call(baseSales)) || (baseSales === null || baseSales === void 0 ? void 0 : baseSales.otherParams) || {};
@@ -139,30 +176,82 @@ function HDLKioskPaymentRuntime({ context, controllerRef, onPaymentResultChange
139
176
  paymentMethodType: method.type,
140
177
  amount
141
178
  },
142
- onClose: () => authorizationStore.cancel(authorization)
179
+ onClose: () => {
180
+ var _staffPaymentAttemptR;
181
+ const cancelled = authorizationStore.cancel(authorization);
182
+ emitDiagnostic("hdlKiosk.staffPayment.authorization", attempt.attemptId, {
183
+ phase: cancelled ? "closed" : "closeIgnored",
184
+ authorizationToken: authorization.token,
185
+ elapsedMs: Date.now() - attempt.startedAt
186
+ });
187
+ if (cancelled && ((_staffPaymentAttemptR = staffPaymentAttemptRef.current) === null || _staffPaymentAttemptR === void 0 ? void 0 : _staffPaymentAttemptR.authorization) === authorization) staffPaymentAttemptRef.current = void 0;
188
+ }
143
189
  });
144
- if (authorizationStore.isSettling(authorization)) return {
145
- status: "succeeded",
146
- data: void 0
147
- };
190
+ if (authorizationStore.isSettling(authorization)) {
191
+ emitDiagnostic("hdlKiosk.staffPayment.authorization", attempt.attemptId, {
192
+ phase: "dispatchSucceededDuringSettlement",
193
+ authorizationToken: authorization.token,
194
+ elapsedMs: Date.now() - attempt.startedAt
195
+ });
196
+ return {
197
+ status: "succeeded",
198
+ data: void 0
199
+ };
200
+ }
148
201
  if (require_staffPaymentAuthorization.isStaffPaymentAuthorizationCancelled(result)) {
202
+ var _staffPaymentAttemptR2;
149
203
  authorizationStore.cancel(authorization);
204
+ emitDiagnostic("hdlKiosk.staffPayment.authorization", attempt.attemptId, {
205
+ phase: "dispatchCancelled",
206
+ authorizationToken: authorization.token,
207
+ elapsedMs: Date.now() - attempt.startedAt
208
+ });
209
+ if (((_staffPaymentAttemptR2 = staffPaymentAttemptRef.current) === null || _staffPaymentAttemptR2 === void 0 ? void 0 : _staffPaymentAttemptR2.authorization) === authorization) staffPaymentAttemptRef.current = void 0;
150
210
  return require_normalize.failed("staffPaymentAuthorizationCancelled", "retry");
151
211
  }
152
212
  if ((result === null || result === void 0 ? void 0 : result.status) !== "success") {
213
+ var _staffPaymentAttemptR3;
153
214
  authorizationStore.fail(authorization);
215
+ emitDiagnostic("hdlKiosk.staffPayment.authorization", attempt.attemptId, {
216
+ phase: "dispatchFailed",
217
+ authorizationToken: authorization.token,
218
+ resultStatus: diagnosticText(result === null || result === void 0 ? void 0 : result.status),
219
+ elapsedMs: Date.now() - attempt.startedAt
220
+ });
221
+ if (((_staffPaymentAttemptR3 = staffPaymentAttemptRef.current) === null || _staffPaymentAttemptR3 === void 0 ? void 0 : _staffPaymentAttemptR3.authorization) === authorization) staffPaymentAttemptRef.current = void 0;
154
222
  return require_normalize.failed("staffPaymentAuthorizationDispatchFailed", "retry", result.msg);
155
223
  }
224
+ emitDiagnostic("hdlKiosk.staffPayment.authorization", attempt.attemptId, {
225
+ phase: "dispatchSucceeded",
226
+ authorizationToken: authorization.token,
227
+ elapsedMs: Date.now() - attempt.startedAt
228
+ });
156
229
  return {
157
230
  status: "succeeded",
158
231
  data: void 0
159
232
  };
160
233
  } catch (error) {
161
- if (authorizationStore.isSettling(authorization)) return {
162
- status: "succeeded",
163
- data: void 0
164
- };
234
+ var _staffPaymentAttemptR4;
235
+ if (authorizationStore.isSettling(authorization)) {
236
+ emitDiagnostic("hdlKiosk.staffPayment.authorization", attempt.attemptId, {
237
+ phase: "dispatchErroredDuringSettlement",
238
+ authorizationToken: authorization.token,
239
+ message: diagnosticText(error instanceof Error ? error.message : error),
240
+ elapsedMs: Date.now() - attempt.startedAt
241
+ });
242
+ return {
243
+ status: "succeeded",
244
+ data: void 0
245
+ };
246
+ }
165
247
  authorizationStore.fail(authorization);
248
+ emitDiagnostic("hdlKiosk.staffPayment.authorization", attempt.attemptId, {
249
+ phase: "dispatchFailed",
250
+ authorizationToken: authorization.token,
251
+ message: diagnosticText(error instanceof Error ? error.message : error),
252
+ elapsedMs: Date.now() - attempt.startedAt
253
+ });
254
+ if (((_staffPaymentAttemptR4 = staffPaymentAttemptRef.current) === null || _staffPaymentAttemptR4 === void 0 ? void 0 : _staffPaymentAttemptR4.authorization) === authorization) staffPaymentAttemptRef.current = void 0;
166
255
  return require_normalize.failed("staffPaymentAuthorizationDispatchFailed", "retry", error);
167
256
  }
168
257
  });
@@ -177,26 +266,48 @@ function HDLKioskPaymentRuntime({ context, controllerRef, onPaymentResultChange
177
266
  context,
178
267
  currencySymbol,
179
268
  (_engineContext$appHel5 = engineContext.appHelper) === null || _engineContext$appHel5 === void 0 ? void 0 : _engineContext$appHel5.utils,
269
+ emitDiagnostic,
180
270
  onPaymentResultChange
181
271
  ]);
182
272
  (0, react.useEffect)(() => {
183
273
  let cleanup;
184
274
  let globalApp;
185
275
  try {
186
- var _window2, _app$applicationManag, _globalApp$runFunctio;
276
+ var _window2, _app$applicationManag;
187
277
  const app = (_window2 = window) === null || _window2 === void 0 ? void 0 : _window2.app;
188
278
  globalApp = app === null || app === void 0 || (_app$applicationManag = app.applicationManager) === null || _app$applicationManag === void 0 ? void 0 : _app$applicationManag.get("global");
189
- cleanup = globalApp === null || globalApp === void 0 || (_globalApp$runFunctio = globalApp.runFunction) === null || _globalApp$runFunctio === void 0 ? void 0 : _globalApp$runFunctio.call(globalApp, "listenExternalCommand", {
279
+ if (typeof (globalApp === null || globalApp === void 0 ? void 0 : globalApp.runFunction) !== "function") throw new Error("global application is unavailable");
280
+ cleanup = globalApp.runFunction("listenExternalCommand", {
190
281
  app,
191
282
  handler: (command) => {
283
+ var _staffPaymentAttemptR5;
192
284
  if (command.command !== "payment_result") return;
285
+ const params = command.params || {};
286
+ const currentAttempt = staffPaymentAttemptRef.current;
287
+ const hostRequestId = diagnosticText(params.requestId, "missing");
288
+ const traceId = (currentAttempt === null || currentAttempt === void 0 ? void 0 : currentAttempt.attemptId) || `hdl-staff-payment:orphan:${hostRequestId}:${Date.now()}`;
289
+ emitDiagnostic("hdlKiosk.staffPayment.result", traceId, require_objectSpread2._objectSpread2({
290
+ phase: "received",
291
+ hostRequestId,
292
+ resultStatus: diagnosticText(params.status),
293
+ ok: params.ok === true,
294
+ hasActiveAttempt: Boolean(currentAttempt)
295
+ }, currentAttempt ? { methodCode: currentAttempt.methodCode } : {}));
193
296
  const authorization = authorizationStore.beginSettlement();
194
- if (!authorization) return;
297
+ if (!authorization) {
298
+ emitDiagnostic("hdlKiosk.staffPayment.result", traceId, {
299
+ phase: "ignored",
300
+ reason: "no-active-authorization",
301
+ hostRequestId,
302
+ resultStatus: diagnosticText(params.status)
303
+ });
304
+ return;
305
+ }
195
306
  try {
196
- var _globalApp$runFunctio2;
197
- globalApp === null || globalApp === void 0 || (_globalApp$runFunctio2 = globalApp.runFunction) === null || _globalApp$runFunctio2 === void 0 || _globalApp$runFunctio2.call(globalApp, "closeAuthorization");
198
- } catch (_unused) {}
199
- const result = require_staffPaymentAuthorization.resolveStaffPaymentResult(command.params || {});
307
+ var _globalApp$runFunctio;
308
+ globalApp === null || globalApp === void 0 || (_globalApp$runFunctio = globalApp.runFunction) === null || _globalApp$runFunctio === void 0 || _globalApp$runFunctio.call(globalApp, "closeAuthorization");
309
+ } catch (_unused2) {}
310
+ const result = require_staffPaymentAuthorization.resolveStaffPaymentResult(params);
200
311
  if (result.status === "succeeded") {
201
312
  var _currentContext$sales;
202
313
  const currentContext = paymentResultContextRef.current;
@@ -204,21 +315,48 @@ function HDLKioskPaymentRuntime({ context, controllerRef, onPaymentResultChange
204
315
  source: "staff",
205
316
  fallbackAmount: currentAmount(currentContext),
206
317
  currencySymbol: (_currentContext$sales = currentContext.sales.tempOrder) === null || _currentContext$sales === void 0 ? void 0 : _currentContext$sales.currency_symbol,
207
- rawResult: command.params
318
+ rawResult: params
208
319
  }));
320
+ emitDiagnostic("hdlKiosk.staffPayment.result", traceId, {
321
+ phase: "projected",
322
+ hostRequestId,
323
+ resultStatus: result.status
324
+ });
209
325
  }
210
- authorizationStore.complete(authorization, result);
326
+ const published = authorizationStore.complete(authorization, result);
327
+ emitDiagnostic("hdlKiosk.staffPayment.result", traceId, {
328
+ phase: published ? "published" : "publishIgnored",
329
+ hostRequestId,
330
+ resultStatus: result.status
331
+ });
332
+ if (published && ((_staffPaymentAttemptR5 = staffPaymentAttemptRef.current) === null || _staffPaymentAttemptR5 === void 0 ? void 0 : _staffPaymentAttemptR5.authorization) === authorization) staffPaymentAttemptRef.current = void 0;
211
333
  }
212
334
  });
213
- } catch (_unused2) {}
335
+ emitDiagnostic("hdlKiosk.staffPayment.result", `hdl-staff-payment-listener:${Date.now()}`, { phase: "listenerRegistered" });
336
+ } catch (error) {
337
+ emitDiagnostic("hdlKiosk.staffPayment.result", `hdl-staff-payment-listener:${Date.now()}`, {
338
+ phase: "listenerRegistrationFailed",
339
+ message: diagnosticText(error instanceof Error ? error.message : error)
340
+ });
341
+ }
214
342
  return () => {
343
+ var _window$location2;
215
344
  if (typeof cleanup === "function") cleanup();
216
- if (authorizationStore.dispose()) try {
217
- var _globalApp$runFunctio3;
218
- globalApp === null || globalApp === void 0 || (_globalApp$runFunctio3 = globalApp.runFunction) === null || _globalApp$runFunctio3 === void 0 || _globalApp$runFunctio3.call(globalApp, "closeAuthorization");
345
+ const hadActiveAuthorization = authorizationStore.dispose();
346
+ const currentAttempt = staffPaymentAttemptRef.current;
347
+ emitDiagnostic("hdlKiosk.runtime.lifecycle", (currentAttempt === null || currentAttempt === void 0 ? void 0 : currentAttempt.attemptId) || `hdl-payment-runtime:${Date.now()}:unmounted`, {
348
+ phase: "unmounted",
349
+ active: activeRef.current,
350
+ hadActiveAuthorization,
351
+ pathname: diagnosticText((_window$location2 = window.location) === null || _window$location2 === void 0 ? void 0 : _window$location2.pathname, "/")
352
+ });
353
+ staffPaymentAttemptRef.current = void 0;
354
+ if (hadActiveAuthorization) try {
355
+ var _globalApp$runFunctio2;
356
+ globalApp === null || globalApp === void 0 || (_globalApp$runFunctio2 = globalApp.runFunction) === null || _globalApp$runFunctio2 === void 0 || _globalApp$runFunctio2.call(globalApp, "closeAuthorization");
219
357
  } catch (_unused3) {}
220
358
  };
221
- }, [authorizationStore]);
359
+ }, [authorizationStore, emitDiagnostic]);
222
360
  (0, react.useLayoutEffect)(() => {
223
361
  controllerRef.current = controller;
224
362
  return () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/private-materials",
3
- "version": "6.12.200",
3
+ "version": "6.12.201",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -69,10 +69,10 @@
69
69
  "react-zoom-pan-pinch": "^3.7.0",
70
70
  "styled-components": "^6.0.0-rc.3",
71
71
  "use-sync-external-store": "^1.6.0",
72
- "@pisell/pi-payment-sdk": "0.0.3",
73
72
  "@pisell/utils": "3.0.4",
73
+ "@pisell/materials": "6.12.58",
74
74
  "@pisell/icon": "0.0.11",
75
- "@pisell/materials": "6.12.57",
75
+ "@pisell/pi-payment-sdk": "0.0.3",
76
76
  "@pisell/date-picker": "3.0.10"
77
77
  },
78
78
  "peerDependencies": {