Skip to content

Commit

Permalink
Merge pull request mixxxdj#13460 from christophehenry/depreciate-lodash
Browse files Browse the repository at this point in the history
Deprecate `lodash.mixxx.js`, and `script.deepMerge`
  • Loading branch information
JoergAtGithub authored Jul 22, 2024
2 parents 7c852d6 + d9107c6 commit a9b3e7f
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 6 deletions.
9 changes: 4 additions & 5 deletions res/controllers/common-controller-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,15 @@ const isSimpleObject = function(obj) {
return obj !== null && typeof obj === "object" && obj.constructor.name === "Object";
};

script.isSimpleObject = isSimpleObject;

/**
* Deeply merges 2 objects (Arrays and Objects only, not Map for instance).
* @param target {object | Array} Object to merge source into
* @param source {object | Array} Object to merge into source
* @deprecated Use {@link Object.assign} instead
*/
const deepMerge = function(target, source) {
script.deepMerge = function(target, source) {
console.warn("script.deepMerge is deprecated; use Object.assign instead");

if (target === source || target === undefined || target === null || source === undefined || source === null) {
return;
}
Expand All @@ -190,8 +191,6 @@ const deepMerge = function(target, source) {
}
};

script.deepMerge = deepMerge;

// ----------------- Mapping constants ---------------------

// Library column value, which can be used to interact with the CO for "[Library] sort_column"
Expand Down
17 changes: 16 additions & 1 deletion res/controllers/lodash.mixxx.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
*/
;(function() {
const DEPRECATION_MSG = (
"Lodash is deprecated and will be removed in a future release of Mixxx; refer to the page " +
"https://github.com/mixxxdj/mixxx/wiki/Lodash-Migration for migrations instructions"
);

console.warn(DEPRECATION_MSG);

/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
Expand Down Expand Up @@ -17068,8 +17074,17 @@
/*--------------------------------------------------------------------------*/

// Export lodash.
/**
* @deprecated since 2.5.0
* @global
*/
var _ = runInContext();

// Export to the global object.
root._ = _;
Object.defineProperty(root, "_", {
get() {
console.warn(DEPRECATION_MSG);
return _;
}
})
}.call(this));
30 changes: 30 additions & 0 deletions res/controllers/midi-components-0.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,13 @@
// Unset isShifted for each ComponentContainer recursively
this.isShifted = false;
},
/**
* @param newLayer Layer to apply to this
* @param reconnectComponents Whether components should be reconnected or not
* @deprecated since 2.5.0. Use @{ComponentContainer#setLayer} instead
*/
applyLayer: function(newLayer, reconnectComponents) {
console.warn("ComponentContainer.applyLayer is deprecated; use ComponentContainer.setLayer instead");
if (reconnectComponents !== false) {
reconnectComponents = true;
}
Expand All @@ -669,6 +675,30 @@
});
}
},
/**
* @param newLayer Layer to apply to this
* @param reconnectComponents Whether components should be reconnected or not
*/
setLayer(newLayer, reconnectComponents) {
if (reconnectComponents !== false) {
reconnectComponents = true;
}
if (reconnectComponents === true) {
this.forEachComponent(function(component) {
component.disconnect();
});
}

Object.assign(this, newLayer);

if (reconnectComponents === true) {
this.forEachComponent(function(component) {
component.connect();
component.trigger();
});
}

},
shutdown: function() {
this.forEachComponent(function(component) {
if (component.shutdown !== undefined
Expand Down

0 comments on commit a9b3e7f

Please sign in to comment.