pixi.js
Version:
<p align="center"> <a href="https://pixijs.com" target="_blank" rel="noopener noreferrer"> <img height="150" src="https://files.pixijs.download/branding/pixijs-logo-transparent-dark.svg?v=1" alt="PixiJS logo"> </a> </p> <br/> <p align="center">
1 lines • 5.7 kB
Source Map (JSON)
{"version":3,"file":"deprecation.mjs","sources":["../../../src/utils/logging/deprecation.ts"],"sourcesContent":["// A set of warning messages already fired\nconst warnings: Set<string> = new Set();\n\n/**\n * deprecation name for version 8.0.0\n * @ignore\n * @internal\n */\nexport const v8_0_0 = '8.0.0';\n/**\n * deprecation name for version 8.1.0\n * @ignore\n * @internal\n */\nexport const v8_3_4 = '8.3.4';\n\n/**\n * Options for managing deprecation messages behavior globally\n * @category utils\n * @standard\n */\ninterface DeprecationOptions\n{\n /**\n * When set to true, all deprecation warning messages will be hidden.\n * Use this if you want to silence deprecation notifications.\n * @default false\n * @standard\n */\n quiet: boolean;\n /**\n * When set to true, deprecation messages will be displayed as plain text without color formatting.\n * Use this if you want to disable colored console output for deprecation warnings.\n * @default false\n * @standard\n */\n noColor: boolean;\n}\n\n/** @internal */\nexport type DeprecationFn = ((version: string, message: string, ignoreDepth?: number) => void) & DeprecationOptions;\n\nconst deprecationState: DeprecationOptions = {\n quiet: false,\n noColor: false\n};\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 *\n * Deprecation messages can be configured globally:\n * ```ts\n * // Suppress all deprecation messages\n * deprecation.quiet = true;\n *\n * // Put plain text to console instead of colorful messages\n * deprecation.noColor = true;\n * ```\n * @category utils\n * @ignore\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 const deprecation: DeprecationFn = ((version: string, message: string, ignoreDepth: number = 3) =>\n{\n // Suppress if is in quiet mode and ignore duplicate\n if (deprecationState.quiet || warnings.has(message)) return;\n\n /* eslint-disable no-console */\n let stack = new Error().stack;\n\n const deprecationMessage = `${message}\\nDeprecated since v${version}`;\n const useGroup = typeof console.groupCollapsed === 'function' && !deprecationState.noColor;\n\n // Handle IE < 10 and Safari < 6\n if (typeof stack === 'undefined')\n {\n console.warn('PixiJS Deprecation Warning: ', deprecationMessage);\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 (useGroup)\n {\n console.groupCollapsed(\n '%cPixiJS Deprecation Warning: %c%s',\n 'color:#614108;background:#fffbe6',\n 'font-weight:normal;color:#614108;background:#fffbe6',\n deprecationMessage\n );\n console.warn(stack);\n console.groupEnd();\n }\n else\n {\n console.warn('PixiJS Deprecation Warning: ', deprecationMessage);\n console.warn(stack);\n }\n }\n /* eslint-enable no-console */\n\n warnings.add(message);\n}) as DeprecationFn;\n\nObject.defineProperties(deprecation, {\n quiet: {\n get: () => deprecationState.quiet,\n set: (value: boolean) =>\n {\n deprecationState.quiet = value;\n },\n enumerable: true,\n configurable: false\n },\n noColor: {\n get: () => deprecationState.noColor,\n set: (value: boolean) =>\n {\n deprecationState.noColor = value;\n },\n enumerable: true,\n configurable: false\n }\n} satisfies {[key in keyof DeprecationOptions]: PropertyDescriptor});\n"],"names":[],"mappings":";AACA,MAAM,QAAA,uBAA4B,GAAA,EAAI;AAO/B,MAAM,MAAA,GAAS;AAMf,MAAM,MAAA,GAAS;AA4BtB,MAAM,gBAAA,GAAuC;AAAA,EACzC,KAAA,EAAO,KAAA;AAAA,EACP,OAAA,EAAS;AACb,CAAA;AAuBO,MAAM,WAAA,IAA8B,CAAC,OAAA,EAAiB,OAAA,EAAiB,cAAsB,CAAA,KACpG;AAEI,EAAA,IAAI,gBAAA,CAAiB,KAAA,IAAS,QAAA,CAAS,GAAA,CAAI,OAAO,CAAA,EAAG;AAGrD,EAAA,IAAI,KAAA,GAAQ,IAAI,KAAA,EAAM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