1/** 2 * SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com 3 * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06 4 */ 5 6(function () { 7 const A = AUI().use('oop'); 8 9 const usedModules = {}; 10 11 const Dependency = { 12 _getAOP(object, methodName) { 13 return object._yuiaop && object._yuiaop[methodName]; 14 }, 15 16 _proxy(object, methodName, methodFn, context, guid, modules, _A) { 17 let args; 18 19 const queue = Dependency._proxyLoaders[guid]; 20 21 Dependency._replaceMethod(object, methodName, methodFn, context); 22 23 while ((args = queue.next())) { 24 methodFn.apply(context, args); 25 } 26 27 for (let i = modules.length - 1; i >= 0; i--) { 28 usedModules[modules[i]] = true; 29 } 30 }, 31 32 _proxyLoaders: {}, 33 34 _replaceMethod(object, methodName, methodFn) { 35 const AOP = Dependency._getAOP(object, methodName); 36 37 let proxy = object[methodName]; 38 39 if (AOP) { 40 proxy = AOP.method; 41 42 AOP.method = methodFn; 43 } 44 else { 45 object[methodName] = methodFn; 46 } 47 48 A.mix(methodFn, proxy); 49 }, 50 51 provide(object, methodName, methodFn, modules, proto) { 52 if (!Array.isArray(modules)) { 53 modules = [modules]; 54 } 55 56 let before; 57 58 const guid = A.guid(); 59 60 if (A.Lang.isObject(methodFn, true)) { 61 const config = methodFn; 62 63 methodFn = config.fn; 64 before = config.before; 65 66 if (!A.Lang.isFunction(before)) { 67 before = null; 68 } 69 } 70 71 if (proto && A.Lang.isFunction(object)) { 72 object = object.prototype; 73 } 74 75 const AOP = Dependency._getAOP(object, methodName); 76 77 if (AOP) { 78 delete object._yuiaop[methodName]; 79 } 80 81 const proxy = function () { 82 const args = arguments; 83 84 let context = object; 85 86 if (proto) { 87 context = this; 88 } 89 90 if (modules.length === 1) { 91 if (modules[0] in usedModules) { 92 Dependency._replaceMethod( 93 object, 94 methodName, 95 methodFn, 96 context 97 ); 98 99 methodFn.apply(context, args); 100 101 return; 102 } 103 } 104 105 let firstLoad = false; 106 107 let queue = Dependency._proxyLoaders[guid]; 108 109 if (!queue) { 110 firstLoad = true; 111 112 Dependency._proxyLoaders[guid] = new A.Queue(); 113 114 queue = Dependency._proxyLoaders[guid]; 115 } 116 117 queue.add(args); 118 119 if (firstLoad) { 120 modules.push( 121 A.bind( 122 Dependency._proxy, 123 Liferay, 124 object, 125 methodName, 126 methodFn, 127 context, 128 guid, 129 modules 130 ) 131 ); 132 133 A.use.apply(A, modules); 134 } 135 }; 136 137 proxy.toString = function () { 138 return methodFn.toString(); 139 }; 140 141 object[methodName] = proxy; 142 }, 143 }; 144 145 Liferay.Dependency = Dependency; 146 147 Liferay.provide = Dependency.provide; 148})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.