UNPKG

@tldraw/editor

Version:

tldraw infinite canvas SDK (editor).

8 lines (7 loc) 1.78 kB
{ "version": 3, "sources": ["../../../src/lib/config/defaultShapes.ts"], "sourcesContent": ["import { TLShapeUtilConstructor } from '../editor/shapes/ShapeUtil'\nimport { GroupShapeUtil } from '../editor/shapes/group/GroupShapeUtil'\n\n/** @public */\nexport type TLAnyShapeUtilConstructor = TLShapeUtilConstructor<any>\n\n/** @public */\nexport const coreShapes = [\n\t// created by grouping interactions, probably the corest core shape that we have\n\tGroupShapeUtil,\n] as const\n\nconst coreShapeTypes = new Set<string>(coreShapes.map((s) => s.type))\n\nexport function checkShapesAndAddCore(customShapes: readonly TLAnyShapeUtilConstructor[]) {\n\tconst shapes = [...coreShapes] as TLAnyShapeUtilConstructor[]\n\n\tconst addedCustomShapeTypes = new Set<string>()\n\tfor (const customShape of customShapes) {\n\t\tif (coreShapeTypes.has(customShape.type)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Shape type \"${customShape.type}\" is a core shapes type and cannot be overridden`\n\t\t\t)\n\t\t}\n\t\tif (addedCustomShapeTypes.has(customShape.type)) {\n\t\t\tthrow new Error(`Shape type \"${customShape.type}\" is defined more than once`)\n\t\t}\n\t\tshapes.push(customShape)\n\t\taddedCustomShapeTypes.add(customShape.type)\n\t}\n\n\treturn shapes\n}\n"], "mappings": "AACA,SAAS,sBAAsB;AAMxB,MAAM,aAAa;AAAA;AAAA,EAEzB;AACD;AAEA,MAAM,iBAAiB,IAAI,IAAY,WAAW,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC;AAE7D,SAAS,sBAAsB,cAAoD;AACzF,QAAM,SAAS,CAAC,GAAG,UAAU;AAE7B,QAAM,wBAAwB,oBAAI,IAAY;AAC9C,aAAW,eAAe,cAAc;AACvC,QAAI,eAAe,IAAI,YAAY,IAAI,GAAG;AACzC,YAAM,IAAI;AAAA,QACT,eAAe,YAAY,IAAI;AAAA,MAChC;AAAA,IACD;AACA,QAAI,sBAAsB,IAAI,YAAY,IAAI,GAAG;AAChD,YAAM,IAAI,MAAM,eAAe,YAAY,IAAI,6BAA6B;AAAA,IAC7E;AACA,WAAO,KAAK,WAAW;AACvB,0BAAsB,IAAI,YAAY,IAAI;AAAA,EAC3C;AAEA,SAAO;AACR;", "names": [] }