monkey-front-core 22.2.2 → 22.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4225,10 +4225,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImpor
4225
4225
  * MIT Licence
4226
4226
  ************************* */
4227
4227
 
4228
+ function isPlainObject(value) {
4229
+ if (typeof value !== 'object' || value === null) {
4230
+ return false;
4231
+ }
4232
+ const proto = Object.getPrototypeOf(value);
4233
+ return proto === Object.prototype || proto === null;
4234
+ }
4228
4235
  function MonkeyEcxCoreService(params) {
4229
- return function (target, propertyName, propertyDescriptor) {
4230
- const method = propertyDescriptor.value;
4231
- propertyDescriptor.value = function (...args) {
4236
+ const wrap = (method) => {
4237
+ return function wrapped(...args) {
4232
4238
  const context = this;
4233
4239
  Object.entries(context).forEach(([key, value]) => {
4234
4240
  if (value instanceof MonkeyEcxService) {
@@ -4236,19 +4242,22 @@ function MonkeyEcxCoreService(params) {
4236
4242
  }
4237
4243
  });
4238
4244
  const requestArgs = args.map((arg) => {
4239
- if (typeof arg === 'object' &&
4240
- arg !== null &&
4241
- !Array.isArray(arg) &&
4242
- arg.context === undefined) {
4245
+ if (isPlainObject(arg) && arg.context === undefined) {
4243
4246
  return { ...arg };
4244
4247
  }
4245
4248
  return arg;
4246
4249
  });
4247
- const result = method.apply(context, requestArgs);
4248
- return result;
4250
+ return method.apply(context, requestArgs);
4249
4251
  };
4250
- return propertyDescriptor;
4251
4252
  };
4253
+ return ((...args) => {
4254
+ if (args.length === 2 && typeof args[1] === 'object' && 'kind' in args[1]) {
4255
+ return wrap(args[0]);
4256
+ }
4257
+ const descriptor = args[2];
4258
+ descriptor.value = wrap(descriptor.value);
4259
+ return descriptor;
4260
+ });
4252
4261
  }
4253
4262
 
4254
4263
  /** ************************