fabric
Version:
Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.
1 lines • 2.56 kB
Source Map (JSON)
{"version":3,"file":"typeAssertions.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","toLive","undefined","isSerializableFiller","toObject","isPattern","offsetX","isTextObject","fabricObject","_renderText","isPath","_renderPathCommands","isActiveSelection"],"mappings":"AAOaA,MAAAA,QAAQ,GACnBC,MAA+B,IACT;EACtB,OAAO,CAAC,CAACA,MAAM,IAAKA,MAAM,CAAaC,MAAM,KAAKC,SAAS,CAAA;AAC7D,EAAC;AAEYC,MAAAA,oBAAoB,GAC/BH,MAA+B,IACT;EACtB,OAAO,CAAC,CAACA,MAAM,IAAI,OAAQA,MAAM,CAAaI,QAAQ,KAAK,UAAU,CAAA;AACvE,EAAC;AAEYC,MAAAA,SAAS,GAAIL,MAAe,IAAwB;AAC/D,EAAA,OACE,CAAC,CAACA,MAAM,IAAKA,MAAM,CAAaM,OAAO,KAAKJ,SAAS,IAAI,QAAQ,IAAIF,MAAM,CAAA;AAE/E,EAAC;AAEYO,MAAAA,YAAY,GACvBC,YAA2B,IACI;EAC/B,OACE,CAAC,CAACA,YAAY,IACd,OAAQA,YAAY,CAAgBC,WAAW,KAAK,UAAU,CAAA;AAElE,EAAC;AAEYC,MAAAA,MAAM,GAAIF,YAA2B,IAA2B;AAC3E;AACA;EACA,OACE,CAAC,CAACA,YAAY,IACd,OAAQA,YAAY,CAAUG,mBAAmB,KAAK,UAAU,CAAA;AAEpE,EAAC;AAEM,MAAMC,iBAAiB,GAC5BJ,YAA2B,IAE3B,CAAC,CAACA,YAAY,IAAI,wBAAwB,IAAIA;;;;"}