drawboard-microservice 1.0.23 → 1.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -58182,6 +58182,25 @@ const DrawingAppContent = () => {
58182
58182
  const [isDrawingActive, setIsDrawingActive] = React.useState(false);
58183
58183
  const [scrollPosition, setScrollPosition] = React.useState({ left: 0, top: 0 });
58184
58184
  React.useEffect(() => {
58185
+ let timeoutId;
58186
+ const initWithFallback = () => {
58187
+ const devPayload = {
58188
+ widgetId: -1,
58189
+ userId: 0,
58190
+ role: "user",
58191
+ config: {},
58192
+ board: {
58193
+ id: 0,
58194
+ name: "Offline Board",
58195
+ parentId: 0
58196
+ }
58197
+ };
58198
+ console.log("Initializing in offline mode");
58199
+ setWidget(devPayload);
58200
+ setBoardId("offline-" + Date.now());
58201
+ setWidgetId(-1);
58202
+ setIsInitialized(true);
58203
+ };
58185
58204
  const unsubscribe = onWidgetInitialized((payload) => {
58186
58205
  console.log("Widget initialized via getInfo:", payload);
58187
58206
  setWidget(payload);
@@ -58195,6 +58214,11 @@ const DrawingAppContent = () => {
58195
58214
  initializeStatsModule(payload);
58196
58215
  }
58197
58216
  });
58217
+ timeoutId = setTimeout(() => {
58218
+ if (!isInitialized) {
58219
+ initWithFallback();
58220
+ }
58221
+ }, 1e3);
58198
58222
  if (process.env.NODE_ENV === "development") {
58199
58223
  const devPayload = {
58200
58224
  widgetId: -1,
@@ -58215,6 +58239,7 @@ const DrawingAppContent = () => {
58215
58239
  }
58216
58240
  return () => {
58217
58241
  unsubscribe();
58242
+ clearTimeout(timeoutId);
58218
58243
  };
58219
58244
  }, []);
58220
58245
  const initializeStatsModule = React.useCallback(async (widgetInfo) => {
@@ -58316,7 +58341,6 @@ const DrawingAppContent = () => {
58316
58341
  }, [shapes2, canvasConfig, strokeColor, strokeWidth, fontSize, fontFamily, textAlign, scale]);
58317
58342
  const sendWidgetConfigImmediately = React.useCallback(async () => {
58318
58343
  if (!widget || !widget.widgetId || widget.widgetId <= 0) {
58319
- console.log("Standalone mode, skipping widget config update");
58320
58344
  return;
58321
58345
  }
58322
58346
  try {
@@ -58330,10 +58354,8 @@ const DrawingAppContent = () => {
58330
58354
  body: JSON.stringify(config)
58331
58355
  });
58332
58356
  if (!response.ok) {
58333
- console.warn("Failed to update widget config:", response.statusText);
58334
58357
  }
58335
58358
  } catch (error) {
58336
- console.error("Error updating widget config:", error);
58337
58359
  }
58338
58360
  }, [widget, createWidgetConfig]);
58339
58361
  const getAuthToken = () => {
@@ -58346,7 +58368,6 @@ const DrawingAppContent = () => {
58346
58368
  const metrics = collectMetrics();
58347
58369
  await statsService.sendMetrics(metrics);
58348
58370
  } catch (error) {
58349
- console.error("Failed to send metrics:", error);
58350
58371
  }
58351
58372
  }, 3e4);
58352
58373
  return () => clearInterval(intervalId);
@@ -58359,10 +58380,11 @@ const DrawingAppContent = () => {
58359
58380
  config: canvasConfig,
58360
58381
  history: canvasHistory
58361
58382
  });
58362
- sendShapesUpdate(shapesToSend);
58383
+ if (sendShapesUpdate) {
58384
+ sendShapesUpdate(shapesToSend);
58385
+ }
58363
58386
  sendWidgetConfigImmediately();
58364
58387
  } catch (error) {
58365
- console.error("Failed to send canvas data to backend:", error);
58366
58388
  }
58367
58389
  }
58368
58390
  }, [boardId, canvasConfig, canvasHistory, sendShapesUpdate, widget, sendWidgetConfigImmediately]);
@@ -58397,9 +58419,14 @@ const DrawingAppContent = () => {
58397
58419
  if (newShapes) {
58398
58420
  setShapes(newShapes);
58399
58421
  if (widget && widget.widgetId > 0) {
58400
- await undoAction(boardId);
58401
- sendUndo();
58402
- sendWidgetConfigImmediately();
58422
+ try {
58423
+ await undoAction(boardId);
58424
+ if (sendUndo) {
58425
+ sendUndo();
58426
+ }
58427
+ sendWidgetConfigImmediately();
58428
+ } catch (error) {
58429
+ }
58403
58430
  }
58404
58431
  }
58405
58432
  };
@@ -58466,7 +58493,6 @@ const DrawingAppContent = () => {
58466
58493
  const [panStart, setPanStart] = React.useState({ x: 0, y: 0 });
58467
58494
  const handleOcrRecognize = React.useCallback(async () => {
58468
58495
  if (!ocrSelection || !stageRef.current) {
58469
- console.error("No OCR selection or stage reference");
58470
58496
  return;
58471
58497
  }
58472
58498
  try {
@@ -58480,7 +58506,6 @@ const DrawingAppContent = () => {
58480
58506
  const tempCanvas = document.createElement("canvas");
58481
58507
  const tempCtx = tempCanvas.getContext("2d");
58482
58508
  if (!tempCtx) {
58483
- console.error("Failed to get canvas context");
58484
58509
  if (hadOcrBorder) {
58485
58510
  setShapes(shapes2);
58486
58511
  }
@@ -58524,21 +58549,16 @@ const DrawingAppContent = () => {
58524
58549
  setOcrPreviewLatex(latexFormula);
58525
58550
  setShowOcrPreview(true);
58526
58551
  setIsOcrEditing(false);
58527
- console.log("OCR успешно распознано:", result);
58528
58552
  } else {
58529
58553
  if (hadOcrBorder) {
58530
58554
  setShapes(shapes2);
58531
58555
  }
58532
- console.error("OCR распознавание не удалось:", result.error);
58533
- alert("Не удалось распознать формулу. Попробуйте снова.");
58534
58556
  }
58535
58557
  } catch (error) {
58536
58558
  const shapesWithOcrBorder = shapes2.filter((shape) => shape.id.startsWith("ocr_border_"));
58537
58559
  if (shapesWithOcrBorder.length > 0) {
58538
58560
  setShapes(shapes2);
58539
58561
  }
58540
- console.error("Ошибка при OCR распознавании:", error);
58541
- alert("Ошибка при отправке изображения на сервер.");
58542
58562
  }
58543
58563
  }, [ocrSelection, shapes2, scale]);
58544
58564
  const handleOcrSelect = React.useCallback(() => {
@@ -58692,9 +58712,14 @@ const DrawingAppContent = () => {
58692
58712
  setOcrSelection(null);
58693
58713
  saveToHistory([]);
58694
58714
  if (widget && widget.widgetId > 0) {
58695
- await clearCanvas(boardId);
58696
- sendClear();
58697
- sendWidgetConfigImmediately();
58715
+ try {
58716
+ await clearCanvas(boardId);
58717
+ if (sendClear) {
58718
+ sendClear();
58719
+ }
58720
+ sendWidgetConfigImmediately();
58721
+ } catch (error) {
58722
+ }
58698
58723
  }
58699
58724
  };
58700
58725
  const handleLatexSymbolClick = (symbol) => {