@robotical/webapp-types 3.23.19 → 3.23.20

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marty-web-app",
3
- "version": "3.23.19",
3
+ "version": "3.23.20",
4
4
  "private": true,
5
5
  "engines": {
6
6
  "node": ">=20"
@@ -58,6 +58,7 @@
58
58
  "clean-mb": "shx rm -r ./node_modules/@robotical/martyblocks",
59
59
  "clean-mbjr": "shx rm -r ./node_modules/@robotical/martyblocksjr",
60
60
  "transpile-public-legacy": "node scripts/transpile-public-legacy.js",
61
+ "postinstall": "patch-package",
61
62
  "prepare": "npm run copy-mb && npm run copy-mbjr && npm run copy-space-shooter-assets && npm run copy-qr-wasm && NODE_OPTIONS=\"--max-old-space-size=8192\" npm run transpile-public-legacy",
62
63
  "prestart": "npm run copy-qr-wasm",
63
64
  "start": "react-scripts start",
@@ -149,6 +150,7 @@
149
150
  "axe-core": "^4.11.2",
150
151
  "csv-parse": "^5.6.0",
151
152
  "fs-extra": "^11.3.0",
153
+ "patch-package": "^8.0.1",
152
154
  "puppeteer": "^24.42.0",
153
155
  "react-native": "file:./stubs/react-native",
154
156
  "react-native-ble-plx": "file:./stubs/react-native-ble-plx",
@@ -1,5 +1,5 @@
1
1
  import { RaftTypeE } from "../../../types/raft";
2
- export type QRScannerErrorDisposition = "permission-denied" | "no-camera" | "camera-in-use" | "detector-unavailable" | "unexpected";
2
+ export type QRScannerErrorDisposition = "permission-denied" | "no-camera" | "camera-constraints" | "camera-in-use" | "detector-unavailable" | "unexpected";
3
3
  export declare const classifyQRScannerError: (error: unknown) => QRScannerErrorDisposition;
4
4
  export declare const reportQRScannerError: (error: unknown) => QRScannerErrorDisposition;
5
5
  type Props = {
@@ -87,6 +87,11 @@ export var classifyQRScannerError = function (error) {
87
87
  causeName === "NotFoundError") {
88
88
  return "no-camera";
89
89
  }
90
+ if (errorKind === "overconstrained" ||
91
+ errorName === "OverconstrainedError" ||
92
+ causeName === "OverconstrainedError") {
93
+ return "camera-constraints";
94
+ }
90
95
  if (errorKind === "in-use" ||
91
96
  errorName === "NotReadableError" ||
92
97
  causeName === "NotReadableError") {
@@ -111,6 +116,10 @@ export var reportQRScannerError = function (error) {
111
116
  Logger.warn(SHOW_LOGS, TAG, "No QR camera was found", error);
112
117
  return disposition;
113
118
  }
119
+ if (disposition === "camera-constraints") {
120
+ Logger.warn(SHOW_LOGS, TAG, "The QR camera cannot satisfy the requested constraints", error);
121
+ return disposition;
122
+ }
114
123
  if (disposition === "camera-in-use") {
115
124
  Logger.warn(SHOW_LOGS, TAG, "QR camera is already in use", error);
116
125
  return disposition;
@@ -229,6 +238,10 @@ function QRContent(_a) {
229
238
  onScannerUnavailable();
230
239
  window.applicationManager.toaster.error("No camera was found. Connect a camera and select QR Code Verification to try again, or use LED verification.", { autoClose: false });
231
240
  }
241
+ else if (disposition === "camera-constraints") {
242
+ onScannerUnavailable();
243
+ window.applicationManager.toaster.error("This camera cannot start with the required settings. Select QR Code Verification to try again, or use LED verification.", { autoClose: false });
244
+ }
232
245
  else if (disposition === "camera-in-use") {
233
246
  onScannerUnavailable();
234
247
  window.applicationManager.toaster.error("The camera is already in use. Close the other app using it and select QR Code Verification to try again, or use LED verification.", { autoClose: false });
@@ -1,4 +1,14 @@
1
1
  export type AppRuntime = "web-app" | "phone-webview";
2
+ export type MalformedRaftJsonDiagnostic = {
3
+ systemType: string;
4
+ topic: string;
5
+ connectionPhase: string;
6
+ payloadLength: number;
7
+ prefixHex: string;
8
+ frameTimeMs?: number;
9
+ error?: string;
10
+ };
11
+ export declare function captureMalformedRaftJsonDiagnostic(detail: MalformedRaftJsonDiagnostic, now?: number): boolean;
2
12
  export declare function initializeObservability(): boolean;
3
13
  export declare function isObservabilityTransportUrl(url: string): boolean;
4
14
  export declare function captureLoggerError(tag: string, messages: unknown[]): void;
@@ -14,6 +14,10 @@ import packageInfo from "../../../package.json";
14
14
  import isPhoneApp from "../../utils/phone-app-communication/is-phone-app";
15
15
  var appVersion = packageInfo.version;
16
16
  var LOCAL_HOSTNAMES = new Set(["localhost", "127.0.0.1", "::1"]);
17
+ var MALFORMED_RAFT_JSON_EVENT = "robotical:malformed-raft-device-json";
18
+ var MALFORMED_RAFT_JSON_REPORT_INTERVAL_MS = 60000;
19
+ var malformedRaftJsonListenerRegistered = false;
20
+ var lastMalformedRaftJsonReportAt = Number.NEGATIVE_INFINITY;
17
21
  var getEventHostname = function (event) {
18
22
  var _a;
19
23
  var eventUrl = (_a = event.request) === null || _a === void 0 ? void 0 : _a.url;
@@ -68,6 +72,43 @@ var getSafeAppSnapshot = function () {
68
72
  : undefined,
69
73
  };
70
74
  };
75
+ export function captureMalformedRaftJsonDiagnostic(detail, now) {
76
+ if (now === void 0) { now = Date.now(); }
77
+ if (!Sentry.isInitialized() ||
78
+ now - lastMalformedRaftJsonReportAt <
79
+ MALFORMED_RAFT_JSON_REPORT_INTERVAL_MS) {
80
+ return false;
81
+ }
82
+ lastMalformedRaftJsonReportAt = now;
83
+ try {
84
+ Sentry.withScope(function (scope) {
85
+ scope.setLevel("warning");
86
+ scope.setTag("diagnostic_kind", "malformed_raft_device_json");
87
+ scope.setTag("raft_system_type", detail.systemType);
88
+ scope.setTag("raft_topic", detail.topic);
89
+ scope.setTag("connection_phase", detail.connectionPhase);
90
+ scope.setContext("raft_packet", detail);
91
+ scope.setContext("app_snapshot", getSafeAppSnapshot());
92
+ Sentry.captureMessage("Discarded malformed RAFT device JSON", "warning");
93
+ });
94
+ return true;
95
+ }
96
+ catch (_a) {
97
+ // Monitoring must never interrupt the application path it observes.
98
+ return false;
99
+ }
100
+ }
101
+ var registerMalformedRaftJsonListener = function () {
102
+ if (malformedRaftJsonListenerRegistered)
103
+ return;
104
+ window.addEventListener(MALFORMED_RAFT_JSON_EVENT, function (event) {
105
+ var detail = event.detail;
106
+ if (detail) {
107
+ captureMalformedRaftJsonDiagnostic(detail);
108
+ }
109
+ });
110
+ malformedRaftJsonListenerRegistered = true;
111
+ };
71
112
  export function initializeObservability() {
72
113
  var _a;
73
114
  var dsn = (_a = process.env.REACT_APP_SENTRY_DSN) === null || _a === void 0 ? void 0 : _a.trim();
@@ -106,6 +147,7 @@ export function initializeObservability() {
106
147
  app_runtime: getRuntime(),
107
148
  app_version: appVersion,
108
149
  });
150
+ registerMalformedRaftJsonListener();
109
151
  return true;
110
152
  }
111
153
  export function isObservabilityTransportUrl(url) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robotical/webapp-types",
3
- "version": "3.23.19",
3
+ "version": "3.23.20",
4
4
  "description": "Type definitions for the Application Manager",
5
5
  "main": "dist/application-manager.d.ts",
6
6
  "types": "dist/application-manager.d.ts",