fabric
Version:
Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.
1 lines • 2.14 kB
Source Map (JSON)
{"version":3,"file":"typeAssertions.min.mjs","sources":["../../../src/util/typeAssertions.ts"],"sourcesContent":["import type { FabricObject } from '../shapes/Object/Object';\nimport type { TFiller } from '../typedefs';\nimport type { FabricText } from '../shapes/Text/Text';\nimport type { Pattern } from '../Pattern';\nimport type { Path } from '../shapes/Path';\nimport type { ActiveSelection } from '../shapes/ActiveSelection';\n\nexport const isFiller = (\n filler: TFiller | string | null,\n): filler is TFiller => {\n return !!filler && (filler as TFiller).toLive !== undefined;\n};\n\nexport const isSerializableFiller = (\n filler: TFiller | string | null,\n): filler is TFiller => {\n return !!filler && typeof (filler as TFiller).toObject === 'function';\n};\n\nexport const isPattern = (filler: TFiller): filler is Pattern => {\n return (\n !!filler && (filler as Pattern).offsetX !== undefined && 'source' in filler\n );\n};\n\nexport const isTextObject = (\n fabricObject?: FabricObject,\n): fabricObject is FabricText => {\n return (\n !!fabricObject &&\n typeof (fabricObject as FabricText)._renderText === 'function'\n );\n};\n\nexport const isPath = (fabricObject?: FabricObject): fabricObject is Path => {\n // we could use instanceof but that would mean pulling in Text code for a simple check\n // @todo discuss what to do and how to do\n return (\n !!fabricObject &&\n typeof (fabricObject as Path)._renderPathCommands === 'function'\n );\n};\n\nexport const isActiveSelection = (\n fabricObject?: FabricObject,\n): fabricObject is ActiveSelection =>\n !!fabricObject && 'multiSelectionStacking' in fabricObject;\n"],"names":["isFiller","filler","undefined","toLive","isSerializableFiller","toObject","isPattern","offsetX","isTextObject","fabricObject","_renderText","isPath","_renderPathCommands","isActiveSelection"],"mappings":"AAOaA,MAAAA,EACXC,KAESA,QAAyCC,IAA9BD,EAAmBE,OAG5BC,EACXH,KAESA,GAAkD,mBAAhCA,EAAmBI,SAGnCC,EAAaL,KAEpBA,QAA0CC,IAA/BD,EAAmBM,SAAyB,WAAYN,EAI5DO,EACXC,KAGIA,GACkD,mBAA5CA,EAA4BC,YAI3BC,EAAUF,KAIjBA,GACoD,mBAA9CA,EAAsBG,oBAIrBC,EACXJ,KAEEA,GAAgB,2BAA4BA"}