goatdee-canvas 0.0.71 → 0.0.72
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.cjs +18 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.js +19 -28
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6393,42 +6393,33 @@ function useCanvasResize(args) {
|
|
|
6393
6393
|
}, []);
|
|
6394
6394
|
}
|
|
6395
6395
|
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
|
|
6404
|
-
|
|
6405
|
-
|
|
6406
|
-
|
|
6407
|
-
|
|
6408
|
-
|
|
6396
|
+
function parseActionData(raw) {
|
|
6397
|
+
if (typeof raw !== "string" || raw === "") {
|
|
6398
|
+
return undefined;
|
|
6399
|
+
}
|
|
6400
|
+
try {
|
|
6401
|
+
const parsed = JSON.parse(raw);
|
|
6402
|
+
if (parsed !== null && typeof parsed === "object") {
|
|
6403
|
+
return parsed;
|
|
6404
|
+
}
|
|
6405
|
+
}
|
|
6406
|
+
catch (_a) { }
|
|
6407
|
+
return raw;
|
|
6408
|
+
}
|
|
6409
6409
|
function useOnActionBridge(onAction, reportAction) {
|
|
6410
6410
|
const handlerRef = react.useRef(() => { });
|
|
6411
6411
|
const aliveRef = react.useRef(true);
|
|
6412
6412
|
handlerRef.current = (event) => {
|
|
6413
|
+
if (!aliveRef.current)
|
|
6414
|
+
return;
|
|
6413
6415
|
const detail = event.detail;
|
|
6414
6416
|
const action = detail === null || detail === void 0 ? void 0 : detail.action;
|
|
6415
6417
|
if (action == null || action === "")
|
|
6416
6418
|
return;
|
|
6417
|
-
const data =
|
|
6419
|
+
const data = parseActionData(detail === null || detail === void 0 ? void 0 : detail.data);
|
|
6420
|
+
// 上报到灯塔
|
|
6418
6421
|
reportAction(action);
|
|
6419
|
-
|
|
6420
|
-
action === "modified" ||
|
|
6421
|
-
action === "add") {
|
|
6422
|
-
onAction === null || onAction === void 0 ? void 0 : onAction(action, data);
|
|
6423
|
-
return;
|
|
6424
|
-
}
|
|
6425
|
-
requestAnimationFrame(() => {
|
|
6426
|
-
setTimeout(() => {
|
|
6427
|
-
if (!aliveRef.current)
|
|
6428
|
-
return;
|
|
6429
|
-
onAction === null || onAction === void 0 ? void 0 : onAction(action, data);
|
|
6430
|
-
}, 0);
|
|
6431
|
-
});
|
|
6422
|
+
onAction === null || onAction === void 0 ? void 0 : onAction(action, data);
|
|
6432
6423
|
};
|
|
6433
6424
|
react.useEffect(() => {
|
|
6434
6425
|
aliveRef.current = true;
|