fix(structuredclone): change
This commit is contained in:
@@ -16,6 +16,7 @@ import { useOtherToolsStore } from "./useOtherToolsStore"
|
||||
import { usePaperSupportStore } from "./usePaperSupportStore"
|
||||
import { useRightToolsStore } from "./useRightToolsStore"
|
||||
import { useTopToolsStore } from "./useTopToolsStore"
|
||||
import { safeClone } from "./utils/clone"
|
||||
|
||||
interface PaperState {
|
||||
paperScope: paper.PaperScope | null
|
||||
@@ -239,7 +240,7 @@ const handleDelete = () => {
|
||||
}
|
||||
})
|
||||
}
|
||||
const currentLabelData = structuredClone(useLabelStore.getState().label)
|
||||
const currentLabelData = safeClone(useLabelStore.getState().label)
|
||||
operationIds.forEach((operationId, index) => {
|
||||
let result =
|
||||
currentLabelData
|
||||
@@ -1808,7 +1809,7 @@ export const usePaperStore = create<PaperState>((set) => ({
|
||||
!child.data ||
|
||||
(child.data && !Object.keys(child.data).length)
|
||||
)
|
||||
child.data = structuredClone(newDrawPath?.data || {})
|
||||
child.data = safeClone(newDrawPath?.data || {})
|
||||
})
|
||||
oldPolygon.remove()
|
||||
oldPolygon = null
|
||||
@@ -1886,7 +1887,7 @@ export const usePaperStore = create<PaperState>((set) => ({
|
||||
// if (!newDrawPath?.clockwise) newDrawPath?.reverse();
|
||||
if (newDrawPath instanceof paper.CompoundPath) {
|
||||
;(newDrawPath.children as paper.Path[]).forEach((child) => {
|
||||
child.data = structuredClone(
|
||||
child.data = safeClone(
|
||||
Object.assign({}, newDrawPath?.data || {}, {
|
||||
isHollowPolygon: !child.clockwise,
|
||||
})
|
||||
@@ -1894,7 +1895,7 @@ export const usePaperStore = create<PaperState>((set) => ({
|
||||
})
|
||||
if (oldParent instanceof paper.CompoundPath) {
|
||||
;(oldParent.children as paper.Path[]).forEach((child) => {
|
||||
child.data = structuredClone(
|
||||
child.data = safeClone(
|
||||
Object.assign({}, newDrawPath?.data || {}, {
|
||||
isHollowPolygon: !child.clockwise,
|
||||
})
|
||||
@@ -1946,7 +1947,7 @@ export const usePaperStore = create<PaperState>((set) => ({
|
||||
// if (!newDrawPath?.clockwise) newDrawPath?.reverse();
|
||||
if (newDrawPath instanceof paper.CompoundPath)
|
||||
(newDrawPath.children as paper.Path[]).forEach((child) => {
|
||||
child.data = structuredClone(newDrawPath?.data || {})
|
||||
child.data = safeClone(newDrawPath?.data || {})
|
||||
})
|
||||
oldPolygon.remove()
|
||||
oldPolygon = null
|
||||
@@ -2153,7 +2154,7 @@ export const usePaperStore = create<PaperState>((set) => ({
|
||||
return
|
||||
}
|
||||
// hollowPath.path.clockwise = false;
|
||||
hollowPath.path.data = structuredClone(
|
||||
hollowPath.path.data = safeClone(
|
||||
Object.assign({}, hollowPath.path?.data || {}, {
|
||||
isHollowPolygon: true,
|
||||
})
|
||||
@@ -2168,7 +2169,7 @@ export const usePaperStore = create<PaperState>((set) => ({
|
||||
// if (finnalPath instanceof paper.CompoundPath) {
|
||||
// (finnalPath.children as paper.Path[]).forEach((child) => {
|
||||
// // child.clockwise = false;
|
||||
// child.data = structuredClone(
|
||||
// child.data = safeClone(
|
||||
// Object.assign({}, oldPolygon?.data || {}, {
|
||||
// isHollowPolygon: true,
|
||||
// })
|
||||
@@ -2176,7 +2177,7 @@ export const usePaperStore = create<PaperState>((set) => ({
|
||||
// });
|
||||
// } else if (finnalPath instanceof paper.Path) {
|
||||
// // finnalPath.clockwise = false;
|
||||
// finnalPath.data = structuredClone(
|
||||
// finnalPath.data = safeClone(
|
||||
// Object.assign({}, oldPolygon?.data || {}, {
|
||||
// isHollowPolygon: true,
|
||||
// })
|
||||
@@ -2656,7 +2657,7 @@ export const usePaperStore = create<PaperState>((set) => ({
|
||||
if (polygon instanceof paper.CompoundPath)
|
||||
(polygon.children as paper.Path[]).forEach((child) => {
|
||||
if (!child.data || (child.data && !Object.keys(child.data).length))
|
||||
child.data = structuredClone(
|
||||
child.data = safeClone(
|
||||
Object.assign(
|
||||
{ isHollowPolygon: !child.clockwise },
|
||||
polygon?.data || {}
|
||||
@@ -2674,7 +2675,7 @@ export const usePaperStore = create<PaperState>((set) => ({
|
||||
polygon = oldPolygon?.subtract(eachPath) as any
|
||||
if (polygon instanceof paper.CompoundPath)
|
||||
(polygon.children as paper.Path[]).forEach((child) => {
|
||||
child.data = structuredClone(
|
||||
child.data = safeClone(
|
||||
Object.assign(
|
||||
{ isHollowPolygon: !child.clockwise },
|
||||
polygon?.data || {}
|
||||
@@ -2716,7 +2717,7 @@ export const usePaperStore = create<PaperState>((set) => ({
|
||||
polygon = oldPolygon.unite(eachPath) as any
|
||||
if (polygon instanceof paper.CompoundPath)
|
||||
(polygon.children as paper.Path[]).forEach((child) => {
|
||||
child.data = structuredClone(polygon?.data || {})
|
||||
child.data = safeClone(polygon?.data || {})
|
||||
})
|
||||
oldPolygon?.remove()
|
||||
oldPolygon = null
|
||||
|
||||
Reference in New Issue
Block a user