{"version":3,"file":"decorator.mjs","names":[],"sources":["../../../../packages/util/decorator/zone-outside.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-deprecated -- 过期 API 保留至 v24.0.0，本文件为其实现在此引用自身类型 */\nimport { warn } from '@delon/util/other';\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\n\n/**\n * @deprecated Will be removed in v24.0.0\n */\nexport interface ZoneOptions {\n  ngZoneName?: string;\n}\n\ntype DecoratorType = (target: unknown, fn: string, descriptor: PropertyDescriptor) => PropertyDescriptor;\n\nfunction makeFn(type: 'runOutsideAngular' | 'run', options?: ZoneOptions): DecoratorType {\n  return (_, __, descriptor) => {\n    const source = descriptor.value;\n    descriptor.value = function (...data: NzSafeAny[]): () => void {\n      const that = this as NzSafeAny;\n      const ngZone = that[options?.ngZoneName ?? 'ngZone'];\n      if (!ngZone) {\n        if (typeof ngDevMode === 'undefined' || ngDevMode) {\n          warn(`ZoneOutside: Decorator should have 'ngZone' property with 'NgZone' class.`);\n        }\n        return source.call(this, ...data);\n      }\n      let res: NzSafeAny;\n      ngZone[type](() => {\n        res = source.call(this, ...data);\n      });\n      return res;\n    };\n\n    return descriptor;\n  };\n}\n\n/**\n * The decoration method runs in `runOutsideAngular`\n *\n * 装饰方法运行在 `runOutsideAngular` 内\n *\n * @deprecated Will be removed in v24.0.0\n *\n * ```ts\n * class MockClass {\n *  readonly ngZone = inject(NgZone);\n *\n *  {AT}ZoneOutside()\n *  runOutsideAngular(): void {}\n * }\n * ```\n */\nexport function ZoneOutside(options?: ZoneOptions): DecoratorType {\n  return makeFn('runOutsideAngular', options);\n}\n\n/**\n * The decoration method runs in `run`\n *\n * 装饰方法运行在 `run` 内\n *\n * @deprecated Will be removed in v24.0.0\n *\n * ```ts\n * class MockClass {\n *  readonly ngZone = inject(NgZone);\n *\n *  {AT}ZoneRun()\n *  run(): void {}\n * }\n * ```\n */\nexport function ZoneRun(options?: ZoneOptions): DecoratorType {\n  return makeFn('run', options);\n}\n"],"mappings":";AAaA,SAAS,OAAO,MAAmC,SAAqB;CACtE,QAAQ,GAAG,IAAI,eAAc;EAC3B,MAAM,SAAS,WAAW;EAC1B,WAAW,QAAQ,SAAU,GAAG,MAAiB;GAE/C,MAAM,SAAS,KAAK,SAAS,cAAc;GAC3C,IAAI,CAAC,QAAQ;IACX,IAAI,OAAO,cAAc,eAAe,WACtC,KAAK,2EAA2E;IAElF,OAAO,OAAO,KAAK,MAAM,GAAG,IAAI;GAClC;GACA,IAAI;GACJ,OAAO,KAAK,OAAM;IAChB,MAAM,OAAO,KAAK,MAAM,GAAG,IAAI;GACjC,CAAC;GACD,OAAO;EACT;EAEA,OAAO;CACT;AACF;AAkBA,SAAgB,YAAY,SAAqB;CAC/C,OAAO,OAAO,qBAAqB,OAAO;AAC5C;AAkBA,SAAgB,QAAQ,SAAqB;CAC3C,OAAO,OAAO,OAAO,OAAO;AAC9B"}