|
|
|
@ -23,27 +23,29 @@ export function runPatches (patches, type, returnValue, _this, args) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function makeOverride (patch) {
|
|
|
|
|
return function (...args) {
|
|
|
|
|
let returnValue;
|
|
|
|
|
if (!patch.childs.length) return patch.originalFunction.apply(this, args);
|
|
|
|
|
return {
|
|
|
|
|
[patch.originalFunction.name] (...args) {
|
|
|
|
|
let returnValue;
|
|
|
|
|
if (!patch.childs.length) return patch.originalFunction.apply(this, args);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
let tempReturn = runPatches(patch.childs, 'before', returnValue, this, args);
|
|
|
|
|
try {
|
|
|
|
|
let tempReturn = runPatches(patch.childs, 'before', returnValue, this, args);
|
|
|
|
|
|
|
|
|
|
if (Array.isArray(tempReturn)) args = tempReturn;
|
|
|
|
|
if (Array.isArray(tempReturn)) args = tempReturn;
|
|
|
|
|
|
|
|
|
|
tempReturn = void 0;
|
|
|
|
|
returnValue = patch.originalFunction.apply(this, args);
|
|
|
|
|
tempReturn = void 0;
|
|
|
|
|
returnValue = patch.originalFunction.apply(this, args);
|
|
|
|
|
|
|
|
|
|
tempReturn = runPatches(patch.childs, 'after', returnValue, this, args);
|
|
|
|
|
tempReturn = runPatches(patch.childs, 'after', returnValue, this, args);
|
|
|
|
|
|
|
|
|
|
if (typeof tempReturn !== 'undefined') returnValue = tempReturn;
|
|
|
|
|
} catch (err) {
|
|
|
|
|
error({ labels: _labels, message: [ err ] });
|
|
|
|
|
}
|
|
|
|
|
if (typeof tempReturn !== 'undefined') returnValue = tempReturn;
|
|
|
|
|
} catch (err) {
|
|
|
|
|
error({ labels: _labels, message: [ err ] });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return returnValue;
|
|
|
|
|
};
|
|
|
|
|
return returnValue;
|
|
|
|
|
}
|
|
|
|
|
}[patch.originalFunction.name];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function createPatch (id, moduleToPatch, functionName) {
|
|
|
|
|