@pixi/utils
Version:
Collection of utilities used by PixiJS
1 lines • 3.06 kB
Source Map (JSON)
{"version":3,"file":"deprecation.mjs","sources":["../../src/logging/deprecation.ts"],"sourcesContent":["import type { Dict } from '../types';\n\n// A map of warning messages already fired\nconst warnings: Dict<boolean> = {};\n\n/**\n * Helper for warning developers about deprecated features & settings.\n * A stack track for warnings is given; useful for tracking-down where\n * deprecated methods/properties/classes are being used within the code.\n * @memberof PIXI.utils\n * @function deprecation\n * @param {string} version - The version where the feature became deprecated\n * @param {string} message - Message should include what is deprecated, where, and the new solution\n * @param {number} [ignoreDepth=3] - The number of steps to ignore at the top of the error stack\n * this is mostly to ignore internal deprecation calls.\n */\nexport function deprecation(version: string, message: string, ignoreDepth = 3): void\n{\n // Ignore duplicat\n if (warnings[message])\n {\n return;\n }\n\n /* eslint-disable no-console */\n let stack = new Error().stack;\n\n // Handle IE < 10 and Safari < 6\n if (typeof stack === 'undefined')\n {\n console.warn('PixiJS Deprecation Warning: ', `${message}\\nDeprecated since v${version}`);\n }\n else\n {\n // chop off the stack trace which includes PixiJS internal calls\n stack = stack.split('\\n').splice(ignoreDepth).join('\\n');\n\n if (console.groupCollapsed)\n {\n console.groupCollapsed(\n '%cPixiJS Deprecation Warning: %c%s',\n 'color:#614108;background:#fffbe6',\n 'font-weight:normal;color:#614108;background:#fffbe6',\n `${message}\\nDeprecated since v${version}`\n );\n console.warn(stack);\n console.groupEnd();\n }\n else\n {\n console.warn('PixiJS Deprecation Warning: ', `${message}\\nDeprecated since v${version}`);\n console.warn(stack);\n }\n }\n /* eslint-enable no-console */\n\n warnings[message] = true;\n}\n"],"names":[],"mappings":"AAGA,MAAM,WAA0B,EAAC,CAAA;AAaL,SAAA,WAAA,CAAA,OAAA,EAAiB,OAAiB,EAAA,WAAA,GAAc,CAC5E,EAAA;AAEI,EAAA,IAAI,SAAS,OACb,CAAA,EAAA;AACI,IAAA,OAAA;AAAA,GACJ;AAGA,EAAI,IAAA,KAAA,GAAQ,IAAI,KAAA,EAAQ,CAAA,KAAA,CAAA;AAGxB,EAAI,IAAA,OAAO,UAAU,WACrB,EAAA;AACI,IAAQ,OAAA,CAAA,IAAA,CAAK,gCAAgC,CAAG,EAAA,OAAA,CAAA;AAAA,kBAAA,EAA8B,OAAS,CAAA,CAAA,CAAA,CAAA;AAAA,GAG3F,MAAA;AAEI,IAAQ,KAAA,GAAA,KAAA,CAAM,MAAM,IAAI,CAAA,CAAE,OAAO,WAAW,CAAA,CAAE,KAAK,IAAI,CAAA,CAAA;AAEvD,IAAA,IAAI,QAAQ,cACZ,EAAA;AACI,MAAA,OAAA,CAAQ,cACJ,CAAA,oCAAA,EACA,kCACA,EAAA,qDAAA,EACA,CAAG,EAAA,OAAA,CAAA;AAAA,kBAAA,EAA8B,OACrC,CAAA,CAAA,CAAA,CAAA;AACA,MAAA,OAAA,CAAQ,KAAK,KAAK,CAAA,CAAA;AAClB,MAAA,OAAA,CAAQ,QAAS,EAAA,CAAA;AAAA,KAGrB,MAAA;AACI,MAAQ,OAAA,CAAA,IAAA,CAAK,gCAAgC,CAAG,EAAA,OAAA,CAAA;AAAA,kBAAA,EAA8B,OAAS,CAAA,CAAA,CAAA,CAAA;AACvF,MAAA,OAAA,CAAQ,KAAK,KAAK,CAAA,CAAA;AAAA,KACtB;AAAA,GACJ;AAGA,EAAA,QAAA,CAAS,OAAW,CAAA,GAAA,IAAA,CAAA;AACxB;;;;"}