UNPKG

fabric

Version:

Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.

1 lines 2.06 kB
{"version":3,"file":"typeAssertions.min.mjs","names":[],"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"],"mappings":"AAOA,MAAa,EACX,GAAA,CAAA,CAES,GAAW,EAAmB,SAA9B,IAAyC,GAGvC,EACX,GAAA,CAAA,CAES,GAAkD,OAAhC,EAAmB,UAAa,WAGhD,EAAa,GAAA,CAAA,CAEpB,GAAW,EAAmB,UAA9B,IAA0C,IAAa,WAAY,EAI5D,EACX,GAAA,CAAA,CAGI,GACkD,OAA5C,EAA4B,aAAgB,WAI3C,EAAU,GAAA,CAAA,CAIjB,GACoD,OAA9C,EAAsB,qBAAwB,WAI7C,EACX,GAAA,CAAA,CAEE,GAAgB,2BAA4B,EAAA,OAAA,KAAA,kBAAA,KAAA,SAAA,KAAA,OAAA,KAAA,UAAA,KAAA,qBAAA,KAAA"}