{"version":3,"file":"config.min.mjs","names":[],"sources":["../../src/config.ts"],"sourcesContent":["export type TConfiguration = Partial<BaseConfiguration>;\n\nclass BaseConfiguration {\n  /**\n   * Browser-specific constant to adjust CanvasRenderingContext2D.shadowBlur value,\n   * which is unitless and not rendered equally across browsers.\n   *\n   * Values that work quite well (as of October 2017) are:\n   * - Chrome: 1.5\n   * - Edge: 1.75\n   * - Firefox: 0.9\n   * - Safari: 0.95\n   *\n   * @since 2.0.0\n   * @type Number\n   * @default 1\n   */\n  browserShadowBlurConstant = 1;\n\n  /**\n   * Pixel per Inch as a default value set to 96. Can be changed for more realistic conversion.\n   */\n  DPI = 96;\n\n  /**\n   * Device Pixel Ratio\n   * @see https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/HTML-canvas-guide/SettingUptheCanvas/SettingUptheCanvas.html\n   */\n  devicePixelRatio =\n    typeof window !== 'undefined' ? window.devicePixelRatio : 1; // eslint-disable-line no-restricted-globals\n\n  /**\n   * Pixel limit for cache canvases. 1Mpx , 4Mpx should be fine.\n   * @since 1.7.14\n   * @type Number\n   */\n  perfLimitSizeTotal = 2097152;\n\n  /**\n   * Pixel limit for cache canvases width or height. IE fixes the maximum at 5000\n   * @since 1.7.14\n   * @type Number\n   */\n  maxCacheSideLimit = 4096;\n\n  /**\n   * Lowest pixel limit for cache canvases, set at 256PX\n   * @since 1.7.14\n   * @type Number\n   */\n  minCacheSideLimit = 256;\n\n  /**\n   * When 'true', style information is not retained when copy/pasting text, making\n   * pasted text use destination style.\n   * Defaults to 'false'.\n   * @type Boolean\n   * @deprecated\n   */\n  disableStyleCopyPaste = false;\n\n  /**\n   * Enable webgl for filtering picture is available\n   * A filtering backend will be initialized, this will both take memory and\n   * time since a default 2048x2048 canvas will be created for the gl context\n   * @since 2.0.0\n   * @type Boolean\n   */\n  enableGLFiltering = true;\n\n  /**\n   * if webgl is enabled and available, textureSize will determine the size\n   * of the canvas backend\n   *\n   * In order to support old hardware set to `2048` to avoid OOM\n   *\n   * @since 2.0.0\n   * @type Number\n   */\n  textureSize = 4096;\n\n  /**\n   * Skip performance testing of setupGLContext and force the use of putImageData that seems to be the one that works best on\n   * Chrome + old hardware. if your users are experiencing empty images after filtering you may try to force this to true\n   * this has to be set before instantiating the filtering backend ( before filtering the first image )\n   * @type Boolean\n   * @default false\n   */\n  forceGLPutImageData = false;\n\n  /**\n   * If disabled boundsOfCurveCache is not used. For apps that make heavy usage of pencil drawing probably disabling it is better\n   * With the standard behaviour of fabric to translate all curves in absolute commands and by not subtracting the starting point from\n   * the curve is very hard to hit any cache.\n   * Enable only if you know why it could be useful.\n   * Candidate for removal/simplification\n   * @default false\n   */\n  cachesBoundsOfCurve = false;\n\n  /**\n   * Map of font files\n   * Map<fontFamily, pathToFile> of font files\n   */\n  fontPaths: Record</** fontFamily */ string, /** pathToFile */ string> = {};\n\n  /**\n   * Defines the number of fraction digits to use when serializing object values.\n   * Used in exporting methods (`toObject`, `toJSON`, `toSVG`)\n   * You can use it to increase/decrease precision of such values like left, top, scaleX, scaleY, etc.\n   */\n  NUM_FRACTION_DIGITS = 4;\n}\n\nexport class Configuration extends BaseConfiguration {\n  constructor(config?: TConfiguration) {\n    super();\n    this.configure(config);\n  }\n\n  configure(config: TConfiguration = {}) {\n    Object.assign(this, config);\n  }\n\n  /**\n   * Map<fontFamily, pathToFile> of font files\n   */\n  addFonts(\n    paths: Record</** fontFamily */ string, /** pathToFile */ string> = {},\n  ) {\n    this.fontPaths = {\n      ...this.fontPaths,\n      ...paths,\n    };\n  }\n\n  removeFonts(fontFamilys: string[] = []) {\n    fontFamilys.forEach((fontFamily) => {\n      delete this.fontPaths[fontFamily];\n    });\n  }\n\n  clearFonts() {\n    this.fontPaths = {};\n  }\n\n  restoreDefaults<T extends BaseConfiguration>(keys?: (keyof T)[]) {\n    const defaults = new BaseConfiguration() as T;\n    const config =\n      keys?.reduce((acc, key) => {\n        acc[key] = defaults[key];\n        return acc;\n      }, {} as T) || defaults;\n    this.configure(config);\n  }\n}\n\nexport const config = new Configuration();\n"],"mappings":"2GAEA,IAAM,EAAN,KAAA,CAAA,aAAA,CAAA,EAAA,KAeE,4BAA4B,EAAA,CAAA,EAAA,KAK5B,MAAM,GAAA,CAAA,EAAA,KAMN,mBACoB,OAAX,OAAW,IAAc,OAAO,iBAAmB,EAAA,CAAA,EAAA,KAO5D,qBAAqB,QAAA,CAAA,EAAA,KAOrB,oBAAoB,KAAA,CAAA,EAAA,KAOpB,oBAAoB,IAAA,CAAA,EAAA,KASpB,wBAAA,CAAwB,EAAA,CAAA,EAAA,KASxB,oBAAA,CAAoB,EAAA,CAAA,EAAA,KAWpB,cAAc,KAAA,CAAA,EAAA,KASd,sBAAA,CAAsB,EAAA,CAAA,EAAA,KAUtB,sBAAA,CAAsB,EAAA,CAAA,EAAA,KAMtB,YAAwE,EAAA,CAAA,CAAA,EAAA,KAOxE,sBAAsB,EAAA,GA8CxB,MAAa,EAAS,IA3CtB,cAAmC,CAAA,CACjC,YAAY,EAAA,CACV,OAAA,CACA,KAAK,UAAU,EAAA,CAGjB,UAAU,EAAyB,EAAA,CAAA,CACjC,OAAO,OAAO,KAAM,EAAA,CAMtB,SACE,EAAoE,EAAA,CAAA,CAEpE,KAAK,UAAY,CAAA,GACZ,KAAK,UAAA,GACL,EAAA,CAIP,YAAY,EAAwB,EAAA,CAAA,CAClC,EAAY,QAAS,GAAA,CAAA,OACZ,KAAK,UAAU,IAAA,CAI1B,YAAA,CACE,KAAK,UAAY,EAAA,CAGnB,gBAA6C,EAAA,CAC3C,IAAM,EAAW,IAAI,EACf,GAAA,GAAA,KAAA,IAAA,GACJ,EAAM,QAAQ,EAAK,KACjB,EAAI,GAAO,EAAS,GACb,GACN,EAAA,CAAA,GAAY,EACjB,KAAK,UAAU,EAAA,GAAA,OAAA,KAAA"}