2023-02-09 10:24:24 -06:00
|
|
|
const SILENCED_WARN_PREFIXES = [
|
|
|
|
"Setting the `jquery-integration` optional feature flag",
|
2024-05-22 09:21:51 -05:00
|
|
|
'unexpectedly found "!', // https://github.com/emberjs/ember.js/issues/19392
|
2023-02-09 10:24:24 -06:00
|
|
|
];
|
|
|
|
|
2023-07-11 11:01:51 -05:00
|
|
|
class DeprecationSilencer {
|
|
|
|
constructor() {
|
|
|
|
this.silenced = new WeakMap();
|
2023-02-09 10:24:24 -06:00
|
|
|
}
|
|
|
|
|
2023-07-11 11:01:51 -05:00
|
|
|
silence(object, method) {
|
|
|
|
if (this.alreadySilenced(object, method)) {
|
2023-02-09 10:24:24 -06:00
|
|
|
return;
|
|
|
|
}
|
2023-07-11 11:01:51 -05:00
|
|
|
|
|
|
|
let original = object[method];
|
|
|
|
|
|
|
|
object[method] = (message, ...args) => {
|
|
|
|
if (!this.shouldSilence(message)) {
|
|
|
|
return original.call(object, message, ...args);
|
2023-02-09 10:24:24 -06:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-07-11 11:01:51 -05:00
|
|
|
alreadySilenced(object, method) {
|
|
|
|
let set = this.silenced.get(object);
|
|
|
|
|
|
|
|
if (!set) {
|
|
|
|
set = new Set();
|
|
|
|
this.silenced.set(object, set);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (set.has(method)) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
set.add(method);
|
|
|
|
return false;
|
|
|
|
}
|
2023-02-09 10:24:24 -06:00
|
|
|
}
|
|
|
|
|
2023-07-11 11:01:51 -05:00
|
|
|
shouldSilence(message) {
|
|
|
|
return SILENCED_WARN_PREFIXES.some((prefix) => message.startsWith(prefix));
|
2023-02-09 10:24:24 -06:00
|
|
|
}
|
2023-07-11 11:01:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
const DEPRECATION_SILENCER = new DeprecationSilencer();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Export a dummy babel plugin which applies the console.warn silences in worker
|
|
|
|
* processes. Does not actually affect babel output.
|
|
|
|
*/
|
|
|
|
module.exports = function () {
|
|
|
|
DEPRECATION_SILENCER.silence(console, "warn");
|
|
|
|
return {};
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports.silence = function silence(...args) {
|
|
|
|
DEPRECATION_SILENCER.silence(...args);
|
2023-02-09 10:24:24 -06:00
|
|
|
};
|