drawboard-microservice 1.0.24 → 1.0.26
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 +47 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +47 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -57869,10 +57869,6 @@ const useWebSocket = (boardId, onCanvasUpdate, userId = crypto.randomUUID()) =>
|
|
|
57869
57869
|
console.log("[WS] Already connected, skipping");
|
|
57870
57870
|
return;
|
|
57871
57871
|
}
|
|
57872
|
-
if (wsRef.current) {
|
|
57873
|
-
wsRef.current.close();
|
|
57874
|
-
wsRef.current = null;
|
|
57875
|
-
}
|
|
57876
57872
|
const ws = new WebSocket(
|
|
57877
57873
|
`${WS_BASE_URL}/ws/canvas/${boardIdRef.current}/`
|
|
57878
57874
|
);
|
|
@@ -58182,6 +58178,25 @@ const DrawingAppContent = () => {
|
|
|
58182
58178
|
const [isDrawingActive, setIsDrawingActive] = React.useState(false);
|
|
58183
58179
|
const [scrollPosition, setScrollPosition] = React.useState({ left: 0, top: 0 });
|
|
58184
58180
|
React.useEffect(() => {
|
|
58181
|
+
let timeoutId;
|
|
58182
|
+
const initWithFallback = () => {
|
|
58183
|
+
const devPayload = {
|
|
58184
|
+
widgetId: -1,
|
|
58185
|
+
userId: 0,
|
|
58186
|
+
role: "user",
|
|
58187
|
+
config: {},
|
|
58188
|
+
board: {
|
|
58189
|
+
id: 0,
|
|
58190
|
+
name: "Offline Board",
|
|
58191
|
+
parentId: 0
|
|
58192
|
+
}
|
|
58193
|
+
};
|
|
58194
|
+
console.log("Initializing in offline mode");
|
|
58195
|
+
setWidget(devPayload);
|
|
58196
|
+
setBoardId("offline-" + Date.now());
|
|
58197
|
+
setWidgetId(-1);
|
|
58198
|
+
setIsInitialized(true);
|
|
58199
|
+
};
|
|
58185
58200
|
const unsubscribe = onWidgetInitialized((payload) => {
|
|
58186
58201
|
console.log("Widget initialized via getInfo:", payload);
|
|
58187
58202
|
setWidget(payload);
|
|
@@ -58195,6 +58210,11 @@ const DrawingAppContent = () => {
|
|
|
58195
58210
|
initializeStatsModule(payload);
|
|
58196
58211
|
}
|
|
58197
58212
|
});
|
|
58213
|
+
timeoutId = setTimeout(() => {
|
|
58214
|
+
if (!isInitialized) {
|
|
58215
|
+
initWithFallback();
|
|
58216
|
+
}
|
|
58217
|
+
}, 1e3);
|
|
58198
58218
|
if (process.env.NODE_ENV === "development") {
|
|
58199
58219
|
const devPayload = {
|
|
58200
58220
|
widgetId: -1,
|
|
@@ -58215,6 +58235,7 @@ const DrawingAppContent = () => {
|
|
|
58215
58235
|
}
|
|
58216
58236
|
return () => {
|
|
58217
58237
|
unsubscribe();
|
|
58238
|
+
clearTimeout(timeoutId);
|
|
58218
58239
|
};
|
|
58219
58240
|
}, []);
|
|
58220
58241
|
const initializeStatsModule = React.useCallback(async (widgetInfo) => {
|
|
@@ -58316,7 +58337,6 @@ const DrawingAppContent = () => {
|
|
|
58316
58337
|
}, [shapes2, canvasConfig, strokeColor, strokeWidth, fontSize, fontFamily, textAlign, scale]);
|
|
58317
58338
|
const sendWidgetConfigImmediately = React.useCallback(async () => {
|
|
58318
58339
|
if (!widget || !widget.widgetId || widget.widgetId <= 0) {
|
|
58319
|
-
console.log("Standalone mode, skipping widget config update");
|
|
58320
58340
|
return;
|
|
58321
58341
|
}
|
|
58322
58342
|
try {
|
|
@@ -58330,10 +58350,8 @@ const DrawingAppContent = () => {
|
|
|
58330
58350
|
body: JSON.stringify(config)
|
|
58331
58351
|
});
|
|
58332
58352
|
if (!response.ok) {
|
|
58333
|
-
console.warn("Failed to update widget config:", response.statusText);
|
|
58334
58353
|
}
|
|
58335
58354
|
} catch (error) {
|
|
58336
|
-
console.error("Error updating widget config:", error);
|
|
58337
58355
|
}
|
|
58338
58356
|
}, [widget, createWidgetConfig]);
|
|
58339
58357
|
const getAuthToken = () => {
|
|
@@ -58346,7 +58364,6 @@ const DrawingAppContent = () => {
|
|
|
58346
58364
|
const metrics = collectMetrics();
|
|
58347
58365
|
await statsService.sendMetrics(metrics);
|
|
58348
58366
|
} catch (error) {
|
|
58349
|
-
console.error("Failed to send metrics:", error);
|
|
58350
58367
|
}
|
|
58351
58368
|
}, 3e4);
|
|
58352
58369
|
return () => clearInterval(intervalId);
|
|
@@ -58359,10 +58376,11 @@ const DrawingAppContent = () => {
|
|
|
58359
58376
|
config: canvasConfig,
|
|
58360
58377
|
history: canvasHistory
|
|
58361
58378
|
});
|
|
58362
|
-
sendShapesUpdate
|
|
58379
|
+
if (sendShapesUpdate) {
|
|
58380
|
+
sendShapesUpdate(shapesToSend);
|
|
58381
|
+
}
|
|
58363
58382
|
sendWidgetConfigImmediately();
|
|
58364
58383
|
} catch (error) {
|
|
58365
|
-
console.error("Failed to send canvas data to backend:", error);
|
|
58366
58384
|
}
|
|
58367
58385
|
}
|
|
58368
58386
|
}, [boardId, canvasConfig, canvasHistory, sendShapesUpdate, widget, sendWidgetConfigImmediately]);
|
|
@@ -58397,9 +58415,14 @@ const DrawingAppContent = () => {
|
|
|
58397
58415
|
if (newShapes) {
|
|
58398
58416
|
setShapes(newShapes);
|
|
58399
58417
|
if (widget && widget.widgetId > 0) {
|
|
58400
|
-
|
|
58401
|
-
|
|
58402
|
-
|
|
58418
|
+
try {
|
|
58419
|
+
await undoAction(boardId);
|
|
58420
|
+
if (sendUndo) {
|
|
58421
|
+
sendUndo();
|
|
58422
|
+
}
|
|
58423
|
+
sendWidgetConfigImmediately();
|
|
58424
|
+
} catch (error) {
|
|
58425
|
+
}
|
|
58403
58426
|
}
|
|
58404
58427
|
}
|
|
58405
58428
|
};
|
|
@@ -58466,7 +58489,6 @@ const DrawingAppContent = () => {
|
|
|
58466
58489
|
const [panStart, setPanStart] = React.useState({ x: 0, y: 0 });
|
|
58467
58490
|
const handleOcrRecognize = React.useCallback(async () => {
|
|
58468
58491
|
if (!ocrSelection || !stageRef.current) {
|
|
58469
|
-
console.error("No OCR selection or stage reference");
|
|
58470
58492
|
return;
|
|
58471
58493
|
}
|
|
58472
58494
|
try {
|
|
@@ -58480,7 +58502,6 @@ const DrawingAppContent = () => {
|
|
|
58480
58502
|
const tempCanvas = document.createElement("canvas");
|
|
58481
58503
|
const tempCtx = tempCanvas.getContext("2d");
|
|
58482
58504
|
if (!tempCtx) {
|
|
58483
|
-
console.error("Failed to get canvas context");
|
|
58484
58505
|
if (hadOcrBorder) {
|
|
58485
58506
|
setShapes(shapes2);
|
|
58486
58507
|
}
|
|
@@ -58524,21 +58545,16 @@ const DrawingAppContent = () => {
|
|
|
58524
58545
|
setOcrPreviewLatex(latexFormula);
|
|
58525
58546
|
setShowOcrPreview(true);
|
|
58526
58547
|
setIsOcrEditing(false);
|
|
58527
|
-
console.log("OCR успешно распознано:", result);
|
|
58528
58548
|
} else {
|
|
58529
58549
|
if (hadOcrBorder) {
|
|
58530
58550
|
setShapes(shapes2);
|
|
58531
58551
|
}
|
|
58532
|
-
console.error("OCR распознавание не удалось:", result.error);
|
|
58533
|
-
alert("Не удалось распознать формулу. Попробуйте снова.");
|
|
58534
58552
|
}
|
|
58535
58553
|
} catch (error) {
|
|
58536
58554
|
const shapesWithOcrBorder = shapes2.filter((shape) => shape.id.startsWith("ocr_border_"));
|
|
58537
58555
|
if (shapesWithOcrBorder.length > 0) {
|
|
58538
58556
|
setShapes(shapes2);
|
|
58539
58557
|
}
|
|
58540
|
-
console.error("Ошибка при OCR распознавании:", error);
|
|
58541
|
-
alert("Ошибка при отправке изображения на сервер.");
|
|
58542
58558
|
}
|
|
58543
58559
|
}, [ocrSelection, shapes2, scale]);
|
|
58544
58560
|
const handleOcrSelect = React.useCallback(() => {
|
|
@@ -58692,9 +58708,14 @@ const DrawingAppContent = () => {
|
|
|
58692
58708
|
setOcrSelection(null);
|
|
58693
58709
|
saveToHistory([]);
|
|
58694
58710
|
if (widget && widget.widgetId > 0) {
|
|
58695
|
-
|
|
58696
|
-
|
|
58697
|
-
|
|
58711
|
+
try {
|
|
58712
|
+
await clearCanvas(boardId);
|
|
58713
|
+
if (sendClear) {
|
|
58714
|
+
sendClear();
|
|
58715
|
+
}
|
|
58716
|
+
sendWidgetConfigImmediately();
|
|
58717
|
+
} catch (error) {
|
|
58718
|
+
}
|
|
58698
58719
|
}
|
|
58699
58720
|
};
|
|
58700
58721
|
const handleLatexSymbolClick = (symbol) => {
|
|
@@ -59318,6 +59339,9 @@ const DrawingAppContent = () => {
|
|
|
59318
59339
|
}
|
|
59319
59340
|
setIsDrawingActive(false);
|
|
59320
59341
|
};
|
|
59342
|
+
if (!isInitialized) {
|
|
59343
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "drawing-app-container", children: "Loading..." });
|
|
59344
|
+
}
|
|
59321
59345
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "drawing-app-container", children: [
|
|
59322
59346
|
/* @__PURE__ */ jsxRuntime.jsx("h1", { className: "top-header", children: "Paint" }),
|
|
59323
59347
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "drawing-toolbar-container", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "drawing-toolbar", children: [
|