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.81 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,GAAI,EAAA,CAAA;AAO/B,MAAM,MAAS,GAAA,QAAA;AAMf,MAAM,MAAS,GAAA,QAAA;AA4BtB,MAAM,gBAAuC,GAAA;AAAA,EACzC,KAAO,EAAA,KAAA;AAAA,EACP,OAAS,EAAA,KAAA;AACb,CAAA,CAAA;AAuBO,MAAM,WAA8B,GAAA,CAAC,OAAiB,EAAA,OAAA,EAAiB,cAAsB,CACpG,KAAA;AAEI,EAAA,IAAI,gBAAiB,CAAA,KAAA,IAAS,QAAS,CAAA,GAAA,CAAI,OAAO,CAAA;AAAG,IAAA,OAAA;AAGrD,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