1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | (function (factory) {
|
---|
9 | if (typeof module === "object" && typeof module.exports === "object") {
|
---|
10 | var v = factory(require, exports);
|
---|
11 | if (v !== undefined) module.exports = v;
|
---|
12 | }
|
---|
13 | else if (typeof define === "function" && define.amd) {
|
---|
14 | define("@angular/compiler/src/lifecycle_reflector", ["require", "exports"], factory);
|
---|
15 | }
|
---|
16 | })(function (require, exports) {
|
---|
17 | "use strict";
|
---|
18 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
19 | exports.getAllLifecycleHooks = exports.hasLifecycleHook = exports.LIFECYCLE_HOOKS_VALUES = exports.LifecycleHooks = void 0;
|
---|
20 | var LifecycleHooks;
|
---|
21 | (function (LifecycleHooks) {
|
---|
22 | LifecycleHooks[LifecycleHooks["OnInit"] = 0] = "OnInit";
|
---|
23 | LifecycleHooks[LifecycleHooks["OnDestroy"] = 1] = "OnDestroy";
|
---|
24 | LifecycleHooks[LifecycleHooks["DoCheck"] = 2] = "DoCheck";
|
---|
25 | LifecycleHooks[LifecycleHooks["OnChanges"] = 3] = "OnChanges";
|
---|
26 | LifecycleHooks[LifecycleHooks["AfterContentInit"] = 4] = "AfterContentInit";
|
---|
27 | LifecycleHooks[LifecycleHooks["AfterContentChecked"] = 5] = "AfterContentChecked";
|
---|
28 | LifecycleHooks[LifecycleHooks["AfterViewInit"] = 6] = "AfterViewInit";
|
---|
29 | LifecycleHooks[LifecycleHooks["AfterViewChecked"] = 7] = "AfterViewChecked";
|
---|
30 | })(LifecycleHooks = exports.LifecycleHooks || (exports.LifecycleHooks = {}));
|
---|
31 | exports.LIFECYCLE_HOOKS_VALUES = [
|
---|
32 | LifecycleHooks.OnInit, LifecycleHooks.OnDestroy, LifecycleHooks.DoCheck, LifecycleHooks.OnChanges,
|
---|
33 | LifecycleHooks.AfterContentInit, LifecycleHooks.AfterContentChecked, LifecycleHooks.AfterViewInit,
|
---|
34 | LifecycleHooks.AfterViewChecked
|
---|
35 | ];
|
---|
36 | function hasLifecycleHook(reflector, hook, token) {
|
---|
37 | return reflector.hasLifecycleHook(token, getHookName(hook));
|
---|
38 | }
|
---|
39 | exports.hasLifecycleHook = hasLifecycleHook;
|
---|
40 | function getAllLifecycleHooks(reflector, token) {
|
---|
41 | return exports.LIFECYCLE_HOOKS_VALUES.filter(function (hook) { return hasLifecycleHook(reflector, hook, token); });
|
---|
42 | }
|
---|
43 | exports.getAllLifecycleHooks = getAllLifecycleHooks;
|
---|
44 | function getHookName(hook) {
|
---|
45 | switch (hook) {
|
---|
46 | case LifecycleHooks.OnInit:
|
---|
47 | return 'ngOnInit';
|
---|
48 | case LifecycleHooks.OnDestroy:
|
---|
49 | return 'ngOnDestroy';
|
---|
50 | case LifecycleHooks.DoCheck:
|
---|
51 | return 'ngDoCheck';
|
---|
52 | case LifecycleHooks.OnChanges:
|
---|
53 | return 'ngOnChanges';
|
---|
54 | case LifecycleHooks.AfterContentInit:
|
---|
55 | return 'ngAfterContentInit';
|
---|
56 | case LifecycleHooks.AfterContentChecked:
|
---|
57 | return 'ngAfterContentChecked';
|
---|
58 | case LifecycleHooks.AfterViewInit:
|
---|
59 | return 'ngAfterViewInit';
|
---|
60 | case LifecycleHooks.AfterViewChecked:
|
---|
61 | return 'ngAfterViewChecked';
|
---|
62 | default:
|
---|
63 | // This default case is not needed by TypeScript compiler, as the switch is exhaustive.
|
---|
64 | // However Closure Compiler does not understand that and reports an error in typed mode.
|
---|
65 | // The `throw new Error` below works around the problem, and the unexpected: never variable
|
---|
66 | // makes sure tsc still checks this code is unreachable.
|
---|
67 | var unexpected = hook;
|
---|
68 | throw new Error("unexpected " + unexpected);
|
---|
69 | }
|
---|
70 | }
|
---|
71 | });
|
---|
72 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIj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