@angular-wave/angular.ts 0.0.37 → 0.0.39

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.
Files changed (191) hide show
  1. package/Makefile +6 -5
  2. package/dist/angular-ts.esm.js +2 -1
  3. package/dist/angular-ts.umd.js +1 -1
  4. package/package.json +2 -4
  5. package/rollup.config.js +5 -1
  6. package/src/binding.spec.js +4 -4
  7. package/src/core/location/location.js +1 -1
  8. package/src/core/scope/scope.js +4 -7
  9. package/src/exts/aria/aria.html +1 -4
  10. package/src/exts/messages/messages.html +1 -4
  11. package/src/index.js +307 -1
  12. package/src/loader.js +13 -6
  13. package/src/public.js +7 -2
  14. package/src/router/directives/directives.test.js +19 -0
  15. package/src/router/directives/state-directives.html +21 -0
  16. package/src/router/{state-directives.spec.js → directives/state-directives.spec.js} +2 -1
  17. package/src/router/{view-directive.spec.js → directives/view-directive.spec.js} +2 -1
  18. package/src/router/directives/view-directives.html +21 -0
  19. package/src/router/router.html +22 -0
  20. package/src/router/router.test.js +11 -0
  21. package/src/router/services.spec.js +2 -2
  22. package/src/router/{state-builder.spec.js → state/state-builder.spec.js} +9 -12
  23. package/src/router/state/state.html +22 -0
  24. package/src/router/{state.spec.js → state/state.spec.js} +1 -1
  25. package/src/router/state/state.test.js +11 -0
  26. package/src/router/state-filter.spec.js +2 -2
  27. package/src/router/template-factory.spec.js +4 -4
  28. package/src/router/url/url.html +18 -0
  29. package/src/router/url/url.test.js +11 -0
  30. package/src/router/view/view.html +18 -0
  31. package/src/router/{view.spec.js → view/view.spec.js} +1 -1
  32. package/src/router/view/view.test.js +11 -0
  33. package/src/router/view-hook.spec.js +4 -4
  34. package/src/router/view-scroll.spec.js +4 -4
  35. package/src/services/http/http.html +22 -0
  36. package/src/services/http/http.test.js +11 -0
  37. package/src/services/http-backend/http-backend.html +21 -0
  38. package/src/services/http-backend/http-backend.js +1 -1
  39. package/src/services/http-backend/http-backend.spec.js +1 -1
  40. package/src/services/http-backend/http-backend.test.js +11 -0
  41. package/src/shared/common.spec.js +4 -4
  42. package/src/shared/hof.spec.js +1 -1
  43. package/src/shared/min-err.spec.js +2 -2
  44. package/src/shared/shared.html +22 -0
  45. package/src/shared/shared.test.js +11 -0
  46. package/src/shared/test-utils.js +2 -2
  47. package/src/shared/utils.spec.js +1 -1
  48. package/src/src.html +22 -0
  49. package/src/src.test.js +10 -0
  50. package/tsconfig.json +1 -1
  51. package/tsconfig.types.json +11 -0
  52. package/types/animations/animate-cache.d.ts +7 -7
  53. package/types/animations/animate-children-directive.d.ts +3 -6
  54. package/types/animations/animate-swap.d.ts +7 -16
  55. package/types/animations/animation.d.ts +2 -11
  56. package/types/animations/raf-scheduler.d.ts +3 -3
  57. package/types/animations/shared.d.ts +8 -23
  58. package/types/core/{animate-css.d.ts → animate/animate-css.d.ts} +2 -8
  59. package/types/core/{cache.d.ts → cache/cache.d.ts} +5 -5
  60. package/types/core/compile/compile.d.ts +173 -0
  61. package/types/core/controller/controller.d.ts +32 -0
  62. package/types/core/exception-handler.d.ts +1 -1
  63. package/types/core/filter/filter.d.ts +9 -0
  64. package/types/core/{interpolate.d.ts → interpolate/interpolate.d.ts} +23 -39
  65. package/types/core/interval/interval-factory.d.ts +4 -0
  66. package/types/core/{interval.d.ts → interval/interval.d.ts} +1 -1
  67. package/types/core/location/location.d.ts +209 -0
  68. package/types/core/pubsub/pubsub.d.ts +156 -0
  69. package/types/core/q/q.d.ts +31 -0
  70. package/types/core/sanitize/sanitize-uri.d.ts +53 -0
  71. package/types/core/{sce.d.ts → sce/sce.d.ts} +80 -86
  72. package/types/core/scope/scope.d.ts +727 -0
  73. package/types/core/task-tracker-factory.d.ts +29 -29
  74. package/types/core/timeout/timeout.d.ts +20 -0
  75. package/types/core/{urlUtils.d.ts → url-utils/url-utils.d.ts} +2 -7
  76. package/types/directive/{bind.d.ts → bind/bind.d.ts} +4 -10
  77. package/types/directive/{class.d.ts → class/class.d.ts} +12 -21
  78. package/types/directive/controller/controller.d.ts +6 -0
  79. package/types/directive/events/events.d.ts +5 -0
  80. package/types/directive/form/form.d.ts +200 -0
  81. package/types/directive/if/if.d.ts +8 -0
  82. package/types/directive/include/include.d.ts +14 -0
  83. package/types/directive/{input.d.ts → input/input.d.ts} +20 -69
  84. package/types/directive/{model.d.ts → model/model.d.ts} +256 -279
  85. package/types/directive/options/options.d.ts +9 -0
  86. package/types/directive/ref/ref.d.ts +5 -0
  87. package/types/directive/repeat/repeat.d.ts +8 -0
  88. package/types/directive/{script.d.ts → script/script.d.ts} +5 -8
  89. package/types/directive/{show-hide.d.ts → show-hide/show-hide.d.ts} +10 -16
  90. package/types/directive/switch/switch.d.ts +17 -0
  91. package/types/directive/transclude/transclude.d.ts +4 -0
  92. package/types/directive/{validators.d.ts → validators/validators.d.ts} +20 -35
  93. package/types/filters/filters.d.ts +10 -16
  94. package/types/filters/order-by.d.ts +2 -4
  95. package/types/index.d.ts +117 -0
  96. package/types/injector.d.ts +12 -0
  97. package/types/public.d.ts +5 -0
  98. package/types/router/common/coreservices.d.ts +2 -2
  99. package/types/router/common/glob.d.ts +9 -9
  100. package/types/router/common/queue.d.ts +13 -13
  101. package/types/router/common/trace.d.ts +43 -43
  102. package/types/router/directives/view-directive.d.ts +13 -32
  103. package/types/router/globals.d.ts +20 -20
  104. package/types/router/hooks/lazy-load.d.ts +2 -11
  105. package/types/router/hooks/redirect-to.d.ts +1 -4
  106. package/types/router/hooks/url.d.ts +1 -5
  107. package/types/router/hooks/views.d.ts +1 -4
  108. package/types/router/params/param-factory.d.ts +5 -5
  109. package/types/router/params/param-type.d.ts +35 -35
  110. package/types/router/params/param-types.d.ts +11 -11
  111. package/types/router/params/param.d.ts +38 -38
  112. package/types/router/params/state-params.d.ts +10 -10
  113. package/types/router/path/path-node.d.ts +34 -34
  114. package/types/router/path/path-utils.d.ts +73 -77
  115. package/types/router/resolve/resolvable.d.ts +32 -32
  116. package/types/router/resolve/resolve-context.d.ts +84 -84
  117. package/types/router/services.d.ts +4 -9
  118. package/types/router/state/state-builder.d.ts +27 -27
  119. package/types/router/state/state-matcher.d.ts +5 -5
  120. package/types/router/state/state-object.d.ts +58 -58
  121. package/types/router/state/state-queue-manager.d.ts +10 -16
  122. package/types/router/state/state-registry.d.ts +100 -107
  123. package/types/router/state/state-service.d.ts +411 -411
  124. package/types/router/state/target-state.d.ts +64 -69
  125. package/types/router/state/views.d.ts +31 -37
  126. package/types/router/state-filters.d.ts +7 -7
  127. package/types/router/state-provider.d.ts +105 -105
  128. package/types/router/template-factory.d.ts +83 -112
  129. package/types/router/transition/hook-builder.d.ts +25 -25
  130. package/types/router/transition/hook-registry.d.ts +68 -83
  131. package/types/router/transition/interface.d.ts +7 -7
  132. package/types/router/transition/reject-factory.d.ts +34 -34
  133. package/types/router/transition/transition-event-type.d.ts +9 -18
  134. package/types/router/transition/transition-hook.d.ts +77 -82
  135. package/types/router/transition/transition-service.d.ts +82 -99
  136. package/types/router/transition/transition.d.ts +369 -377
  137. package/types/router/url/url-config.d.ts +84 -84
  138. package/types/router/url/url-matcher.d.ts +115 -119
  139. package/types/router/url/url-rule.d.ts +114 -124
  140. package/types/router/url/url-rules.d.ts +217 -217
  141. package/types/router/url/url-service.d.ts +264 -269
  142. package/types/router/view/view.d.ts +114 -117
  143. package/types/router/view-scroll.d.ts +2 -2
  144. package/types/services/anchor-scroll.d.ts +2 -8
  145. package/types/services/browser.d.ts +122 -130
  146. package/types/services/cache-factory.d.ts +25 -25
  147. package/types/services/cookie-reader.d.ts +2 -2
  148. package/types/services/document.d.ts +2 -2
  149. package/types/services/http/http.d.ts +145 -0
  150. package/types/services/{http-backend.d.ts → http-backend/http-backend.d.ts} +3 -35
  151. package/types/services/log.d.ts +49 -49
  152. package/types/services/template-request.d.ts +44 -53
  153. package/types/shared/common.d.ts +4 -19
  154. package/types/{constants.d.ts → shared/constants.d.ts} +6 -6
  155. package/types/shared/hof.d.ts +1 -1
  156. package/types/{jqLite.d.ts → shared/jqlite/jqlite.d.ts} +11 -11
  157. package/types/shared/test-utils.d.ts +11 -0
  158. package/types/shared/utils.d.ts +7 -24
  159. package/types-back/global.d.ts +3 -1
  160. package/types-back/index.d.ts +2 -221
  161. package/types/core/compile.d.ts +0 -206
  162. package/types/core/controller.d.ts +0 -42
  163. package/types/core/filter.d.ts +0 -9
  164. package/types/core/interval-factory.d.ts +0 -21
  165. package/types/core/location.d.ts +0 -234
  166. package/types/core/pubsub.d.ts +0 -164
  167. package/types/core/q.d.ts +0 -33
  168. package/types/core/root-scope.d.ts +0 -754
  169. package/types/core/sanitize-uri.d.ts +0 -57
  170. package/types/core/timeout.d.ts +0 -31
  171. package/types/directive/controller.d.ts +0 -6
  172. package/types/directive/events.d.ts +0 -12
  173. package/types/directive/form.d.ts +0 -230
  174. package/types/directive/if.d.ts +0 -17
  175. package/types/directive/include.d.ts +0 -33
  176. package/types/directive/options.d.ts +0 -16
  177. package/types/directive/ref.d.ts +0 -11
  178. package/types/directive/repeat.d.ts +0 -23
  179. package/types/directive/switch.d.ts +0 -23
  180. package/types/directive/transclude.d.ts +0 -15
  181. package/types/services/http.d.ts +0 -157
  182. /package/src/router/{url-service.spec.js → url/url-service.spec.js} +0 -0
  183. /package/types/directive/{attrs.d.ts → attrs/attrs.d.ts} +0 -0
  184. /package/types/directive/{change.d.ts → change/change.d.ts} +0 -0
  185. /package/types/directive/{cloak.d.ts → cloak/cloak.d.ts} +0 -0
  186. /package/types/directive/{init.d.ts → init/init.d.ts} +0 -0
  187. /package/types/directive/{list.d.ts → list/list.d.ts} +0 -0
  188. /package/types/directive/{non-bindable.d.ts → non-bindable/non-bindable.d.ts} +0 -0
  189. /package/types/directive/{style.d.ts → style/style.d.ts} +0 -0
  190. /package/types/exts/{aria.d.ts → aria/aria.d.ts} +0 -0
  191. /package/types/exts/{messages.d.ts → messages/messages.d.ts} +0 -0
@@ -1,754 +0,0 @@
1
- /**
2
- * Counts all the watchers of direct and indirect child scopes of the current scope.
3
- *
4
- * The watchers of the current scope are included in the count and so are all the watchers of
5
- * isolate child scopes.
6
- * @param {Scope} scope
7
- * @returns {number} Total number of watchers.
8
- */
9
- export function countWatchers(scope: Scope): number;
10
- /**
11
- * Counts all the direct and indirect child scopes of the current scope.
12
- *
13
- * The current scope is excluded from the count. The count includes all isolate child scopes.
14
- * @param {Scope} scope
15
- * @returns {number} Total number of child scopes.
16
- */
17
- export function countChildScopes(scope: Scope): number;
18
- export type ScopePhase = number;
19
- export namespace ScopePhase {
20
- let NONE: number;
21
- let APPLY: number;
22
- let DIGEST: number;
23
- }
24
- /**
25
- * The number of digest iterations
26
- */
27
- export type TTL = number;
28
- /**
29
- * @typedef {Object} AsyncQueueTask
30
- * @property {Scope} scope
31
- * @property {Function} fn
32
- * @property {Object} locals
33
- */
34
- /**
35
- *
36
- * The default number of `$digest` iterations the scope should attempt to execute before giving up and
37
- * assuming that the model is unstable. In complex applications it's possible that the dependencies between `$watch`s will result in
38
- * several digest iterations.
39
- *
40
- * @typedef {number} TTL The number of digest iterations
41
- *
42
- * @type {TTL}
43
- */
44
- export const TTL: TTL;
45
- /** @type {AsyncQueueTask[]} */
46
- export const $$asyncQueue: AsyncQueueTask[];
47
- export const $$postDigestQueue: any[];
48
- export const $$applyAsyncQueue: any[];
49
- /**
50
- * Provider responsible for instantiating the initial scope, aka - root scope.
51
- * Every application has a single root {@link ng.$rootScope.Scope scope}.
52
- * All other scopes are descendant scopes of the root scope. Scopes provide separation
53
- * between the model and the view, via a mechanism for watching the model for changes.
54
- * They also provide event emission/broadcast and subscription facility. See the
55
- * {@link guide/scope developer guide on scopes}.
56
- *
57
- * The provider also injects runtime services to make them available to all scopes.
58
- *
59
- */
60
- export class $RootScopeProvider {
61
- $get: (
62
- | string
63
- | ((
64
- exceptionHandler: angular.IExceptionHandlerService,
65
- parse: angular.IParseService,
66
- browser: import("../services/browser").Browser,
67
- ) => Scope)
68
- )[];
69
- }
70
- export type AsyncQueueTask = {
71
- scope: Scope;
72
- fn: Function;
73
- locals: any;
74
- };
75
- /**
76
- * DESIGN NOTES
77
- *
78
- * The design decisions behind the scope are heavily favored for speed and memory consumption.
79
- *
80
- * The typical use of scope is to watch the expressions, which most of the time return the same
81
- * value as last time so we optimize the operation.
82
- *
83
- * Closures construction is expensive in terms of speed as well as memory:
84
- * - No closures, instead use prototypical inheritance for API
85
- * - Internal state needs to be stored on scope directly, which means that private state is
86
- * exposed as $$____ properties
87
- *
88
- * Loop operations are optimized by using while(count--) { ... }
89
- * - This means that in order to keep the same order of execution as addition we have to add
90
- * items to the array at the beginning (unshift) instead of at the end (push)
91
- *
92
- * Child scopes are created and removed often
93
- * - Using an array would be slow since inserts in the middle are expensive; so we use linked lists
94
- *
95
- * There are fewer watches than observers. This is why you don't want the observer to be implemented
96
- * in the same way as watch. Watch requires return of the initialization function which is expensive
97
- * to construct.
98
- */
99
- /**
100
- * @type {angular.Scope}
101
- */
102
- declare class Scope {
103
- /**
104
- * @type {number} Unique scope ID (monotonically increasing) useful for debugging.
105
- */
106
- $id: number;
107
- /** @type {ScopePhase} */
108
- $$phase: ScopePhase;
109
- /**
110
- * @type {?Scope} Reference to the parent scope.
111
- */
112
- $parent: Scope | null;
113
- /**
114
- * @type {?angular.Scope}
115
- */
116
- $root: angular.Scope;
117
- /**
118
- * @type {[]}
119
- */
120
- $$watchers: [];
121
- /**
122
- * @type {number}
123
- */
124
- $$digestWatchIndex: number;
125
- /**
126
- * @type {?Scope}
127
- */
128
- $$nextSibling: Scope | null;
129
- /**
130
- * @type {?Scope}
131
- */
132
- $$prevSibling: Scope | null;
133
- /**
134
- * @type {?Scope}
135
- */
136
- $$childHead: Scope | null;
137
- /**
138
- * @type {?Scope}
139
- */
140
- $$childTail: Scope | null;
141
- /** @type {boolean} */
142
- $$destroyed: boolean;
143
- /** @type {boolean} */
144
- $$suspended: boolean;
145
- /** @type {object} */
146
- $$listeners: object;
147
- /** @type {object} */
148
- $$listenerCount: object;
149
- /** @type {number} */
150
- $$watchersCount: number;
151
- $$isolateBindings: any;
152
- /**
153
- * @type {?Scope}
154
- */
155
- $$ChildScope: Scope | null;
156
- /**
157
- * Creates a new child {@link Scope}.
158
- *
159
- * The parent scope will propagate the {@link ng.$rootScope.Scope#$digest $digest()} event.
160
- * The scope can be removed from the scope hierarchy using {@link ng.$rootScope.Scope#$destroy $destroy()}.
161
- *
162
- * {@link ng.$rootScope.Scope#$destroy $destroy()} must be called on a scope when it is
163
- * desired for the scope and its child scopes to be permanently detached from the parent and
164
- * thus stop participating in model change detection and listener notification by invoking.
165
- *
166
- * @param {?boolean} isolate If true, then the scope does not prototypically inherit from the
167
- * parent scope. The scope is isolated, as it can not see parent scope properties.
168
- * When creating widgets, it is useful for the widget to not accidentally read parent
169
- * state.
170
- *
171
- * @param {?Scope} [parent=this] The {@link ng.$rootScope.Scope `Scope`} that will be the `$parent`
172
- * of the newly created scope. Defaults to `this` scope if not provided.
173
- * This is used when creating a transclude scope to correctly place it
174
- * in the scope hierarchy while maintaining the correct prototypical
175
- * inheritance.
176
- *
177
- * @returns {Scope} The newly created child scope.
178
- *
179
- */
180
- $new(isolate: boolean | null, parent?: Scope | null): Scope;
181
- /**
182
- * @ngdoc method
183
- * @name $rootScope.Scope#$watch
184
- * @kind function
185
- *
186
- * @description
187
- * Registers a `listener` callback to be executed whenever the `watchExpression` changes.
188
- *
189
- * - The `watchExpression` is called on every call to {@link ng.$rootScope.Scope#$digest
190
- * $digest()} and should return the value that will be watched. (`watchExpression` should not change
191
- * its value when executed multiple times with the same input because it may be executed multiple
192
- * times by {@link ng.$rootScope.Scope#$digest $digest()}. That is, `watchExpression` should be
193
- * [idempotent](http://en.wikipedia.org/wiki/Idempotence).)
194
- * - The `listener` is called only when the value from the current `watchExpression` and the
195
- * previous call to `watchExpression` are not equal (with the exception of the initial run,
196
- * see below). Inequality is determined according to reference inequality,
197
- * [strict comparison](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators)
198
- * via the `!==` Javascript operator, unless `objectEquality == true`
199
- * (see next point)
200
- * - When `objectEquality == true`, inequality of the `watchExpression` is determined
201
- * according to the {@link angular.equals} function. To save the value of the object for
202
- * later comparison, the {@link structuredClone} function is used. This therefore means that
203
- * watching complex objects will have adverse memory and performance implications.
204
- * - This should not be used to watch for changes in objects that are (or contain)
205
- * [File](https://developer.mozilla.org/docs/Web/API/File) objects due to limitations with {@link structuredClone `structuredClone`}.
206
- * - The watch `listener` may change the model, which may trigger other `listener`s to fire.
207
- * This is achieved by rerunning the watchers until no changes are detected. The rerun
208
- * iteration limit is 10 to prevent an infinite loop deadlock.
209
- *
210
- *
211
- * If you want to be notified whenever {@link ng.$rootScope.Scope#$digest $digest} is called,
212
- * you can register a `watchExpression` function with no `listener`. (Be prepared for
213
- * multiple calls to your `watchExpression` because it will execute multiple times in a
214
- * single {@link ng.$rootScope.Scope#$digest $digest} cycle if a change is detected.)
215
- *
216
- * After a watcher is registered with the scope, the `listener` fn is called asynchronously
217
- * (via {@link ng.$rootScope.Scope#$evalAsync $evalAsync}) to initialize the
218
- * watcher. In rare cases, this is undesirable because the listener is called when the result
219
- * of `watchExpression` didn't change. To detect this scenario within the `listener` fn, you
220
- * can compare the `newVal` and `oldVal`. If these two values are identical (`===`) then the
221
- * listener was called due to initialization.
222
- *
223
- *
224
- *
225
- * @example
226
- * ```js
227
- // let's assume that scope was dependency injected as the $rootScope
228
- let scope = $rootScope;
229
- scope.name = 'misko';
230
- scope.counter = 0;
231
-
232
- expect(scope.counter).toEqual(0);
233
- scope.$watch('name', function(newValue, oldValue) {
234
- scope.counter = scope.counter + 1;
235
- });
236
- expect(scope.counter).toEqual(0);
237
-
238
- scope.$digest();
239
- // the listener is always called during the first $digest loop after it was registered
240
- expect(scope.counter).toEqual(1);
241
-
242
- scope.$digest();
243
- // but now it will not be called unless the value changes
244
- expect(scope.counter).toEqual(1);
245
-
246
- scope.name = 'adam';
247
- scope.$digest();
248
- expect(scope.counter).toEqual(2);
249
-
250
- // Using a function as a watchExpression
251
- let food;
252
- scope.foodCounter = 0;
253
- expect(scope.foodCounter).toEqual(0);
254
- scope.$watch(
255
- // This function returns the value being watched. It is called for each turn of the $digest loop
256
- function() { return food; },
257
- // This is the change listener, called when the value returned from the above function changes
258
- function(newValue, oldValue) {
259
- if ( newValue !== oldValue ) {
260
- // Only increment the counter if the value changed
261
- scope.foodCounter = scope.foodCounter + 1;
262
- }
263
- }
264
- );
265
- // No digest has been run so the counter will be zero
266
- expect(scope.foodCounter).toEqual(0);
267
-
268
- // Run the digest but since food has not changed count will still be zero
269
- scope.$digest();
270
- expect(scope.foodCounter).toEqual(0);
271
-
272
- // Update food and run digest. Now the counter will increment
273
- food = 'cheeseburger';
274
- scope.$digest();
275
- expect(scope.foodCounter).toEqual(1);
276
-
277
- * ```
278
- *
279
- *
280
- *
281
- * @param {string | ((scope: Scope) => any)} watchExp Expression that is evaluated on each
282
- * {@link ng.$rootScope.Scope#$digest $digest} cycle. A change in the return value triggers
283
- * a call to the `listener`.
284
- *
285
- * - `string`: Evaluated as {@link guide/expression expression}
286
- * - `function(scope)`: called with current `scope` as a parameter.
287
- * @param {(newVal: any, oldVal: any, scope: angular.Scope) => any} listener Callback called whenever the value
288
- * of `watchExpression` changes.
289
- *
290
- * - `newVal` contains the current value of the `watchExpression`
291
- * - `oldVal` contains the previous value of the `watchExpression`
292
- * - `scope` refers to the current scope
293
- * @param {boolean=} [objectEquality=false] Compare for object equality using {@link angular.equals} instead of
294
- * comparing for reference equality.
295
- * @returns {function()} Returns a deregistration function for this listener.
296
- */
297
- $watch(
298
- watchExp: string | ((scope: Scope) => any),
299
- listener: (newVal: any, oldVal: any, scope: angular.Scope) => any,
300
- objectEquality?: boolean | undefined,
301
- ): () => any;
302
- /**
303
- * @ngdoc method
304
- * @name $rootScope.Scope#$watchGroup
305
- * @kind function
306
- *
307
- * @description
308
- * A variant of {@link ng.$rootScope.Scope#$watch $watch()} where it watches an array of `watchExpressions`.
309
- * If any one expression in the collection changes the `listener` is executed.
310
- *
311
- * - The items in the `watchExpressions` array are observed via the standard `$watch` operation. Their return
312
- * values are examined for changes on every call to `$digest`.
313
- * - The `listener` is called whenever any expression in the `watchExpressions` array changes.
314
- *
315
- * @param {Array.<string|Function(scope)>} watchExpressions Array of expressions that will be individually
316
- * watched using {@link ng.$rootScope.Scope#$watch $watch()}
317
- *
318
- * @param {function(newValues, oldValues, scope)} listener Callback called whenever the return value of any
319
- * expression in `watchExpressions` changes
320
- * The `newValues` array contains the current values of the `watchExpressions`, with the indexes matching
321
- * those of `watchExpression`
322
- * and the `oldValues` array contains the previous values of the `watchExpressions`, with the indexes matching
323
- * those of `watchExpression`
324
- * The `scope` refers to the current scope.
325
- * @returns {function()} Returns a de-registration function for all listeners.
326
- */
327
- $watchGroup(
328
- watchExpressions: any,
329
- listener: (arg0: any[], arg1: any[], arg2: scope) => any,
330
- ): () => any;
331
- /**
332
- * @ngdoc method
333
- * @name $rootScope.Scope#$watchCollection
334
- * @kind function
335
- *
336
- * @description
337
- * Shallow watches the properties of an object and fires whenever any of the properties change
338
- * (for arrays, this implies watching the array items; for object maps, this implies watching
339
- * the properties). If a change is detected, the `listener` callback is fired.
340
- *
341
- * - The `obj` collection is observed via standard $watch operation and is examined on every
342
- * call to $digest() to see if any items have been added, removed, or moved.
343
- * - The `listener` is called whenever anything within the `obj` has changed. Examples include
344
- * adding, removing, and moving items belonging to an object or array.
345
- *
346
- *
347
- *
348
- *
349
- * @param {string|function(scope)} obj Evaluated as {@link guide/expression expression}. The
350
- * expression value should evaluate to an object or an array which is observed on each
351
- * {@link ng.$rootScope.Scope#$digest $digest} cycle. Any shallow change within the
352
- * collection will trigger a call to the `listener`.
353
- *
354
- * @param {function(newCollection, oldCollection, scope)} listener a callback function called
355
- * when a change is detected.
356
- * - The `newCollection` object is the newly modified data obtained from the `obj` expression
357
- * - The `oldCollection` object is a copy of the former collection data.
358
- * Due to performance considerations, the`oldCollection` value is computed only if the
359
- * `listener` function declares two or more arguments.
360
- * - The `scope` argument refers to the current scope.
361
- *
362
- * @returns {function()} Returns a de-registration function for this listener. When the
363
- * de-registration function is executed, the internal watch operation is terminated.
364
- */
365
- $watchCollection(
366
- obj: string | ((arg0: scope) => any),
367
- listener: (arg0: newCollection, arg1: oldCollection, arg2: scope) => any,
368
- ): () => any;
369
- /**
370
- * @ngdoc method
371
- * @name $rootScope.Scope#$digest
372
- * @kind function
373
- *
374
- * @description
375
- * Processes all of the {@link ng.$rootScope.Scope#$watch watchers} of the current scope and
376
- * its children. Because a {@link ng.$rootScope.Scope#$watch watcher}'s listener can change
377
- * the model, the `$digest()` keeps calling the {@link ng.$rootScope.Scope#$watch watchers}
378
- * until no more listeners are firing. This means that it is possible to get into an infinite
379
- * loop. This function will throw `'Maximum iteration limit exceeded.'` if the number of
380
- * iterations exceeds 10.
381
- *
382
- * Usually, you don't call `$digest()` directly in
383
- * {@link ng.directive:ngController controllers} or in
384
- * {@link ng.$compileProvider#directive directives}.
385
- * Instead, you should call {@link ng.$rootScope.Scope#$apply $apply()} (typically from within
386
- * a {@link ng.$compileProvider#directive directive}), which will force a `$digest()`.
387
- *
388
- * If you want to be notified whenever `$digest()` is called,
389
- * you can register a `watchExpression` function with
390
- * {@link ng.$rootScope.Scope#$watch $watch()} with no `listener`.
391
- *
392
- * In unit tests, you may need to call `$digest()` to simulate the scope life cycle.
393
- *
394
- * @example
395
- * ```js
396
- let scope = ...;
397
- scope.name = 'misko';
398
- scope.counter = 0;
399
-
400
- expect(scope.counter).toEqual(0);
401
- scope.$watch('name', function(newValue, oldValue) {
402
- scope.counter = scope.counter + 1;
403
- });
404
- expect(scope.counter).toEqual(0);
405
-
406
- scope.$digest();
407
- // the listener is always called during the first $digest loop after it was registered
408
- expect(scope.counter).toEqual(1);
409
-
410
- scope.$digest();
411
- // but now it will not be called unless the value changes
412
- expect(scope.counter).toEqual(1);
413
-
414
- scope.name = 'adam';
415
- scope.$digest();
416
- expect(scope.counter).toEqual(2);
417
- * ```
418
- *
419
- */
420
- $digest(): void;
421
- /**
422
- * @private
423
- * @param {ScopePhase} phase
424
- */
425
- private beginPhase;
426
- /**
427
- * @ngdoc method
428
- * @name $rootScope.Scope#$suspend
429
- * @kind function
430
- *
431
- * @description
432
- * Suspend watchers of this scope subtree so that they will not be invoked during digest.
433
- *
434
- * This can be used to optimize your application when you know that running those watchers
435
- * is redundant.
436
- *
437
- * **Warning**
438
- *
439
- * Suspending scopes from the digest cycle can have unwanted and difficult to debug results.
440
- * Only use this approach if you are confident that you know what you are doing and have
441
- * ample tests to ensure that bindings get updated as you expect.
442
- *
443
- * Some of the things to consider are:
444
- *
445
- * * Any external event on a directive/component will not trigger a digest while the hosting
446
- * scope is suspended - even if the event handler calls `$apply()` or `$rootScope.$digest()`.
447
- * * Transcluded content exists on a scope that inherits from outside a directive but exists
448
- * as a child of the directive's containing scope. If the containing scope is suspended the
449
- * transcluded scope will also be suspended, even if the scope from which the transcluded
450
- * scope inherits is not suspended.
451
- * * Multiple directives trying to manage the suspended status of a scope can confuse each other:
452
- * * A call to `$suspend()` on an already suspended scope is a no-op.
453
- * * A call to `$resume()` on a non-suspended scope is a no-op.
454
- * * If two directives suspend a scope, then one of them resumes the scope, the scope will no
455
- * longer be suspended. This could result in the other directive believing a scope to be
456
- * suspended when it is not.
457
- * * If a parent scope is suspended then all its descendants will be also excluded from future
458
- * digests whether or not they have been suspended themselves. Note that this also applies to
459
- * isolate child scopes.
460
- * * Calling `$digest()` directly on a descendant of a suspended scope will still run the watchers
461
- * for that scope and its descendants. When digesting we only check whether the current scope is
462
- * locally suspended, rather than checking whether it has a suspended ancestor.
463
- * * Calling `$resume()` on a scope that has a suspended ancestor will not cause the scope to be
464
- * included in future digests until all its ancestors have been resumed.
465
- * * Resolved promises, e.g. from explicit `$q` deferreds and `$http` calls, trigger `$apply()`
466
- * against the `$rootScope` and so will still trigger a global digest even if the promise was
467
- * initiated by a component that lives on a suspended scope.
468
- */
469
- $suspend(): void;
470
- /**
471
- * @ngdoc method
472
- * @name $rootScope.Scope#$isSuspended
473
- * @kind function
474
- *
475
- * @description
476
- * Call this method to determine if this scope has been explicitly suspended. It will not
477
- * tell you whether an ancestor has been suspended.
478
- * To determine if this scope will be excluded from a digest triggered at the $rootScope,
479
- * for example, you must check all its ancestors:
480
- *
481
- * ```
482
- * function isExcludedFromDigest(scope) {
483
- * while(scope) {
484
- * if (scope.$isSuspended()) return true;
485
- * scope = scope.$parent;
486
- * }
487
- * return false;
488
- * ```
489
- *
490
- * Be aware that a scope may not be included in digests if it has a suspended ancestor,
491
- * even if `$isSuspended()` returns false.
492
- *
493
- * @returns true if the current scope has been suspended.
494
- */
495
- $isSuspended(): boolean;
496
- /**
497
- * @ngdoc method
498
- * @name $rootScope.Scope#$resume
499
- * @kind function
500
- *
501
- * @description
502
- * Resume watchers of this scope subtree in case it was suspended.
503
- *
504
- * See {@link $rootScope.Scope#$suspend} for information about the dangers of using this approach.
505
- */
506
- $resume(): void;
507
- /**
508
- * @ngdoc event
509
- * @name $rootScope.Scope#$destroy
510
- * @eventType broadcast on scope being destroyed
511
- *
512
- * @description
513
- * Broadcasted when a scope and its children are being destroyed.
514
- *
515
- * Note that, in AngularTS, there is also a `$destroy` jQuery event, which can be used to
516
- * clean up DOM bindings before an element is removed from the DOM.
517
- */
518
- /**
519
- * @ngdoc method
520
- * @name $rootScope.Scope#$destroy
521
- * @kind function
522
- *
523
- * @description
524
- * Removes the current scope (and all of its children) from the parent scope. Removal implies
525
- * that calls to {@link ng.$rootScope.Scope#$digest $digest()} will no longer
526
- * propagate to the current scope and its children. Removal also implies that the current
527
- * scope is eligible for garbage collection.
528
- *
529
- * The `$destroy()` is usually used by directives such as
530
- * {@link ng.directive:ngRepeat ngRepeat} for managing the
531
- * unrolling of the loop.
532
- *
533
- * Just before a scope is destroyed, a `$destroy` event is broadcasted on this scope.
534
- * Application code can register a `$destroy` event handler that will give it a chance to
535
- * perform any necessary cleanup.
536
- *
537
- * Note that, in AngularTS, there is also a `$destroy` event, which can be used to
538
- * clean up DOM bindings before an element is removed from the DOM.
539
- */
540
- $destroy(): void;
541
- /**
542
- * @ngdoc method
543
- * @name $rootScope.Scope#$apply
544
- * @kind function
545
- *
546
- * @description
547
- * `$apply()` is used to execute an expression in AngularTS from outside of the AngularTS
548
- * framework. (For example from browser DOM events, setTimeout, XHR or third party libraries).
549
- * Because we are calling into the AngularTS framework we need to perform proper scope life
550
- * cycle of {@link ng.$exceptionHandler exception handling},
551
- * {@link ng.$rootScope.Scope#$digest executing watches}.
552
- *
553
- * **Life cycle: Pseudo-Code of `$apply()`**
554
- *
555
- * ```js
556
- function $apply(expr) {
557
- try {
558
- return $eval(expr);
559
- } catch (e) {
560
- $exceptionHandler(e);
561
- } finally {
562
- $root.$digest();
563
- }
564
- }
565
- * ```
566
- *
567
- *
568
- * Scope's `$apply()` method transitions through the following stages:
569
- *
570
- * 1. The {@link guide/expression expression} is executed using the
571
- * {@link ng.$rootScope.Scope#$eval $eval()} method.
572
- * 2. Any exceptions from the execution of the expression are forwarded to the
573
- * {@link ng.$exceptionHandler $exceptionHandler} service.
574
- * 3. The {@link ng.$rootScope.Scope#$watch watch} listeners are fired immediately after the
575
- * expression was executed using the {@link ng.$rootScope.Scope#$digest $digest()} method.
576
- *
577
- *
578
- * @param {string|function(Scope): any} [expr] An AngularTS expression to be executed.
579
- *
580
- * - `string`: execute using the rules as defined in {@link guide/expression expression}.
581
- * - `function(scope)`: execute the function with current `scope` parameter.
582
- *
583
- * @returns {*} The result of evaluating the expression.
584
- */
585
- $apply(expr?: string | ((arg0: Scope) => any)): any;
586
- /**
587
- * @ngdoc method
588
- * @name $rootScope.Scope#$evalAsync
589
- * @kind function
590
- *
591
- * @description
592
- * Executes the expression on the current scope at a later point in time.
593
- *
594
- * The `$evalAsync` makes no guarantees as to when the `expression` will be executed, only
595
- * that:
596
- *
597
- * - it will execute after the function that scheduled the evaluation (preferably before DOM
598
- * rendering).
599
- * - at least one {@link ng.$rootScope.Scope#$digest $digest cycle} will be performed after
600
- * `expression` execution.
601
- *
602
- * Any exceptions from the execution of the expression are forwarded to the
603
- * {@link ng.$exceptionHandler $exceptionHandler} service.
604
- *
605
- * __Note:__ if this function is called outside of a `$digest` cycle, a new `$digest` cycle
606
- * will be scheduled. However, it is encouraged to always call code that changes the model
607
- * from within an `$apply` call. That includes code evaluated via `$evalAsync`.
608
- *
609
- * @param {(string|function())=} expr An AngularTS expression to be executed.
610
- *
611
- * - `string`: execute using the rules as defined in {@link guide/expression expression}.
612
- * - `function(scope)`: execute the function with the current `scope` parameter.
613
- *
614
- * @param {(object)=} locals Local variables object, useful for overriding values in scope.
615
- */
616
- $evalAsync(
617
- expr?: (string | (() => any)) | undefined,
618
- locals?: object | undefined,
619
- ): any;
620
- /**
621
- * @ngdoc method
622
- * @name $rootScope.Scope#$applyAsync
623
- * @kind function
624
- *
625
- * @description
626
- * Schedule the invocation of $apply to occur at a later time. The actual time difference
627
- * varies across browsers, but is typically around ~10 milliseconds.
628
- *
629
- * This can be used to queue up multiple expressions which need to be evaluated in the same
630
- * digest.
631
- *
632
- * @param {(string|function())=} expr An AngularTS expression to be executed.
633
- *
634
- * - `string`: execute using the rules as defined in {@link guide/expression expression}.
635
- * - `function(scope)`: execute the function with current `scope` parameter.
636
- */
637
- $applyAsync(expr?: (string | (() => any)) | undefined): void;
638
- /**
639
- * @description
640
- * Listens on events of a given type. See {@link ng.$rootScope.Scope#$emit $emit} for
641
- * discussion of event life cycle.
642
- *
643
- * The event listener function format is: `function(event, args...)`. The `event` object
644
- * passed into the listener has the following attributes:
645
- *
646
- * - `targetScope` - `{Scope}`: the scope on which the event was `$emit`-ed or
647
- * `$broadcast`-ed.
648
- * - `currentScope` - `{Scope}`: the scope that is currently handling the event. Once the
649
- * event propagates through the scope hierarchy, this property is set to null.
650
- * - `name` - `{string}`: name of the event.
651
- * - `stopPropagation` - `{function=}`: calling `stopPropagation` function will cancel
652
- * further event propagation (available only for events that were `$emit`-ed).
653
- * - `preventDefault` - `{function}`: calling `preventDefault` sets `defaultPrevented` flag
654
- * to true.
655
- * - `defaultPrevented` - `{boolean}`: true if `preventDefault` was called.
656
- *
657
- * @param {string} name Event name to listen on.
658
- * @param {function(angular.IAngularEvent): any} listener Function to call when the event is emitted.
659
- * @returns {function()} Returns a deregistration function for this listener.
660
- */
661
- $on(name: string, listener: (arg0: angular.IAngularEvent) => any): () => any;
662
- /**
663
- * @ngdoc method
664
- * @name $rootScope.Scope#$eval
665
- * @kind function
666
- *
667
- * @description
668
- * Executes the `expression` on the current scope and returns the result. Any exceptions in
669
- * the expression are propagated (uncaught). This is useful when evaluating AngularTS
670
- * expressions.
671
- *
672
- * @example
673
- * ```js
674
- let scope = new Scope();
675
- scope.a = 1;
676
- scope.b = 2;
677
-
678
- expect(scope.$eval('a+b')).toEqual(3);
679
- expect(scope.$eval(function(scope){ return scope.a + scope.b; })).toEqual(3);
680
- * ```
681
- *
682
- * @param {string|function(Scope): any} [expr] An AngularTS expression to be executed.
683
- *
684
- * - `string`: execute using the rules as defined in {@link guide/expression expression}.
685
- * - `function(scope)`: execute the function with the current `scope` parameter.
686
- *
687
- * @param {(object)=} locals Local variables object, useful for overriding values in scope.
688
- * @returns {*} The result of evaluating the expression.
689
- */
690
- $eval(
691
- expr?: string | ((arg0: Scope) => any),
692
- locals?: object | undefined,
693
- ): any;
694
- /**
695
- * @private
696
- */
697
- private $$postDigest;
698
- clearPhase(): void;
699
- /**
700
- * @param {number} count
701
- */
702
- incrementWatchersCount(count: number): void;
703
- /**
704
- * @param {number} count
705
- * @param {string} name
706
- */
707
- decrementListenerCount(count: number, name: string): void;
708
- /**
709
- * @ngdoc method
710
- * @name $rootScope.Scope#$emit
711
- * @kind function
712
- *
713
- * @description
714
- * Dispatches an event `name` upwards through the scope hierarchy notifying the
715
- * registered {@link ng.$rootScope.Scope#$on} listeners.
716
- *
717
- * The event life cycle starts at the scope on which `$emit` was called. All
718
- * {@link ng.$rootScope.Scope#$on listeners} listening for `name` event on this scope get
719
- * notified. Afterwards, the event traverses upwards toward the root scope and calls all
720
- * registered listeners along the way. The event will stop propagating if one of the listeners
721
- * cancels it.
722
- *
723
- * Any exception emitted from the {@link ng.$rootScope.Scope#$on listeners} will be passed
724
- * onto the {@link ng.$exceptionHandler $exceptionHandler} service.
725
- *
726
- * @param {string} name Event name to emit.
727
- * @param {...*} args Optional one or more arguments which will be passed onto the event listeners.
728
- * @return {Object} Event object (see {@link ng.$rootScope.Scope#$on}).
729
- */
730
- $emit(name: string, ...args: any[]): any;
731
- /**
732
- * @ngdoc method
733
- * @name $rootScope.Scope#$broadcast
734
- * @kind function
735
- *
736
- * @description
737
- * Dispatches an event `name` downwards to all child scopes (and their children) notifying the
738
- * registered {@link ng.$rootScope.Scope#$on} listeners.
739
- *
740
- * The event life cycle starts at the scope on which `$broadcast` was called. All
741
- * {@link ng.$rootScope.Scope#$on listeners} listening for `name` event on this scope get
742
- * notified. Afterwards, the event propagates to all direct and indirect scopes of the current
743
- * scope and calls all registered listeners along the way. The event cannot be canceled.
744
- *
745
- * Any exception emitted from the {@link ng.$rootScope.Scope#$on listeners} will be passed
746
- * onto the {@link ng.$exceptionHandler $exceptionHandler} service.
747
- *
748
- * @param {string} name Event name to broadcast.
749
- * @param {...*} args Optional one or more arguments which will be passed onto the event listeners.
750
- * @return {Object} Event object, see {@link ng.$rootScope.Scope#$on}
751
- */
752
- $broadcast(name: string, ...args: any[]): any;
753
- }
754
- export {};