fix structured clone reference in drawing (#2945)
This PR fixes a rogue structuredClone reference in the drawing state. ### Change Type - [x] `patch` — Bug fix ### Release Notes - Fixes a reference to structuredClone that caused a crash on older browsers.
This commit is contained in:
parent
0f1599d5b3
commit
b2cb0d27b0
5 changed files with 9 additions and 3 deletions
|
@ -14,6 +14,7 @@ import {
|
||||||
createShapeId,
|
createShapeId,
|
||||||
last,
|
last,
|
||||||
snapAngle,
|
snapAngle,
|
||||||
|
structuredClone,
|
||||||
toFixed,
|
toFixed,
|
||||||
uniqueId,
|
uniqueId,
|
||||||
} from '@tldraw/editor'
|
} from '@tldraw/editor'
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { Migrations, Store, createRecordType } from '@tldraw/store'
|
import { Migrations, Store, createRecordType } from '@tldraw/store'
|
||||||
|
import { structuredClone } from '@tldraw/utils'
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import { bookmarkAssetMigrations } from './assets/TLBookmarkAsset'
|
import { bookmarkAssetMigrations } from './assets/TLBookmarkAsset'
|
||||||
import { imageAssetMigrations } from './assets/TLImageAsset'
|
import { imageAssetMigrations } from './assets/TLImageAsset'
|
||||||
|
|
|
@ -283,7 +283,7 @@ export function sortByIndex<T extends {
|
||||||
index: IndexKey;
|
index: IndexKey;
|
||||||
}>(a: T, b: T): -1 | 0 | 1;
|
}>(a: T, b: T): -1 | 0 | 1;
|
||||||
|
|
||||||
// @public (undocumented)
|
// @public
|
||||||
const structuredClone_2: <T>(i: T) => T;
|
const structuredClone_2: <T>(i: T) => T;
|
||||||
export { structuredClone_2 as structuredClone }
|
export { structuredClone_2 as structuredClone }
|
||||||
|
|
||||||
|
|
|
@ -3237,7 +3237,7 @@
|
||||||
{
|
{
|
||||||
"kind": "Variable",
|
"kind": "Variable",
|
||||||
"canonicalReference": "@tldraw/utils!structuredClone_2:var",
|
"canonicalReference": "@tldraw/utils!structuredClone_2:var",
|
||||||
"docComment": "/**\n * @public\n */\n",
|
"docComment": "/**\n * Create a deep copy of a value. Uses the structuredClone API if available, otherwise uses JSON.parse(JSON.stringify()).\n *\n * @param i - The value to clone.\n *\n * @public\n */\n",
|
||||||
"excerptTokens": [
|
"excerptTokens": [
|
||||||
{
|
{
|
||||||
"kind": "Content",
|
"kind": "Content",
|
||||||
|
|
|
@ -30,7 +30,11 @@ export function isNonNullish<T>(
|
||||||
return value !== null && value !== undefined
|
return value !== null && value !== undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @public */
|
/**
|
||||||
|
* Create a deep copy of a value. Uses the structuredClone API if available, otherwise uses JSON.parse(JSON.stringify()).
|
||||||
|
*
|
||||||
|
* @param i - The value to clone.
|
||||||
|
* @public */
|
||||||
export const structuredClone =
|
export const structuredClone =
|
||||||
typeof window !== 'undefined' && (window as any).structuredClone
|
typeof window !== 'undefined' && (window as any).structuredClone
|
||||||
? (window.structuredClone as <T>(i: T) => T)
|
? (window.structuredClone as <T>(i: T) => T)
|
||||||
|
|
Loading…
Reference in a new issue