(opts: { uid: string } | ElementLike)
| 20 | type Cache = Record<string, ExcalidrawElement | undefined>; |
| 21 | |
| 22 | const createElement = (opts: { uid: string } | ElementLike) => { |
| 23 | let uid: string; |
| 24 | let id: string; |
| 25 | let version: number | null; |
| 26 | let versionNonce: number | null = null; |
| 27 | if ("uid" in opts) { |
| 28 | const match = opts.uid.match(/^(\w+)(?::(\d+))?$/)!; |
| 29 | id = match[1]; |
| 30 | version = match[2] ? parseInt(match[2]) : null; |
| 31 | uid = version ? `${id}:${version}` : id; |
| 32 | } else { |
| 33 | ({ id, version, versionNonce } = opts); |
| 34 | uid = id; |
| 35 | } |
| 36 | return { |
| 37 | uid, |
| 38 | id, |
| 39 | version, |
| 40 | versionNonce: versionNonce || randomInteger(), |
| 41 | }; |
| 42 | }; |
| 43 | |
| 44 | const idsToElements = (ids: (Id | ElementLike)[], cache: Cache = {}) => { |
| 45 | return syncInvalidIndices( |
no test coverage detected
searching dependent graphs…