@angular-wave/angular.ts 0.0.11 → 0.0.13

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 (79) hide show
  1. package/dist/angular-ts.esm.js +1 -1
  2. package/dist/angular-ts.umd.js +1 -1
  3. package/package.json +4 -1
  4. package/src/exts/messages.md +30 -30
  5. package/src/index.js +1 -0
  6. package/src/public.js +2 -0
  7. package/src/router/adapter/directives/stateDirectives.js +695 -0
  8. package/src/router/adapter/directives/viewDirective.js +514 -0
  9. package/src/router/adapter/injectables.js +314 -0
  10. package/src/router/adapter/interface.js +1 -0
  11. package/src/router/adapter/locationServices.js +84 -0
  12. package/src/router/adapter/services.js +126 -0
  13. package/src/router/adapter/stateFilters.js +43 -0
  14. package/src/router/adapter/stateProvider.js +137 -0
  15. package/src/router/adapter/statebuilders/onEnterExitRetain.js +30 -0
  16. package/src/router/adapter/statebuilders/views.js +146 -0
  17. package/src/router/adapter/templateFactory.js +218 -0
  18. package/src/router/adapter/viewScroll.js +31 -0
  19. package/src/router/core/common/common.js +496 -0
  20. package/src/router/core/common/coreservices.js +15 -0
  21. package/src/router/core/common/glob.js +75 -0
  22. package/src/router/core/common/hof.js +194 -0
  23. package/src/router/core/common/predicates.js +44 -0
  24. package/src/router/core/common/queue.js +41 -0
  25. package/src/router/core/common/safeConsole.js +38 -0
  26. package/src/router/core/common/strings.js +141 -0
  27. package/src/router/core/common/trace.js +232 -0
  28. package/src/router/core/globals.js +29 -0
  29. package/src/router/core/hooks/coreResolvables.js +33 -0
  30. package/src/router/core/hooks/ignoredTransition.js +25 -0
  31. package/src/router/core/hooks/invalidTransition.js +14 -0
  32. package/src/router/core/hooks/lazyLoad.js +102 -0
  33. package/src/router/core/hooks/onEnterExitRetain.js +55 -0
  34. package/src/router/core/hooks/redirectTo.js +36 -0
  35. package/src/router/core/hooks/resolve.js +57 -0
  36. package/src/router/core/hooks/updateGlobals.js +30 -0
  37. package/src/router/core/hooks/url.js +25 -0
  38. package/src/router/core/hooks/views.js +39 -0
  39. package/src/router/core/interface.js +3 -0
  40. package/src/router/core/params/README.md +8 -0
  41. package/src/router/core/params/param.js +232 -0
  42. package/src/router/core/params/paramType.js +139 -0
  43. package/src/router/core/params/paramTypes.js +163 -0
  44. package/src/router/core/params/stateParams.js +35 -0
  45. package/src/router/core/path/pathNode.js +77 -0
  46. package/src/router/core/path/pathUtils.js +199 -0
  47. package/src/router/core/resolve/interface.js +10 -0
  48. package/src/router/core/resolve/resolvable.js +124 -0
  49. package/src/router/core/resolve/resolveContext.js +211 -0
  50. package/src/router/core/router.js +203 -0
  51. package/src/router/core/state/README.md +21 -0
  52. package/src/router/core/state/stateBuilder.js +332 -0
  53. package/src/router/core/state/stateMatcher.js +65 -0
  54. package/src/router/core/state/stateObject.js +117 -0
  55. package/src/router/core/state/stateQueueManager.js +89 -0
  56. package/src/router/core/state/stateRegistry.js +175 -0
  57. package/src/router/core/state/stateService.js +592 -0
  58. package/src/router/core/state/targetState.js +159 -0
  59. package/src/router/core/transition/hookBuilder.js +127 -0
  60. package/src/router/core/transition/hookRegistry.js +175 -0
  61. package/src/router/core/transition/interface.js +14 -0
  62. package/src/router/core/transition/rejectFactory.js +122 -0
  63. package/src/router/core/transition/transition.js +739 -0
  64. package/src/router/core/transition/transitionEventType.js +27 -0
  65. package/src/router/core/transition/transitionHook.js +199 -0
  66. package/src/router/core/transition/transitionService.js +311 -0
  67. package/src/router/core/url/interface.js +1 -0
  68. package/src/router/core/url/urlConfig.js +165 -0
  69. package/src/router/core/url/urlMatcher.js +548 -0
  70. package/src/router/core/url/urlMatcherFactory.js +123 -0
  71. package/src/router/core/url/urlRouter.js +115 -0
  72. package/src/router/core/url/urlRule.js +202 -0
  73. package/src/router/core/url/urlRules.js +348 -0
  74. package/src/router/core/url/urlService.js +268 -0
  75. package/src/router/core/view/interface.js +1 -0
  76. package/src/router/core/view/view.js +312 -0
  77. package/src/router/router.js +58 -0
  78. package/test/module-test.html +6 -2
  79. package/test/module-test.js +0 -0
@@ -0,0 +1,314 @@
1
+ /**
2
+ * The current (or pending) State Parameters
3
+ *
4
+ * An injectable global **Service Object** which holds the state parameters for the latest **SUCCESSFUL** transition.
5
+ *
6
+ * The values are not updated until *after* a `Transition` successfully completes.
7
+ *
8
+ * **Also:** an injectable **Per-Transition Object** object which holds the pending state parameters for the pending `Transition` currently running.
9
+ *
10
+ * ### Deprecation warning:
11
+ *
12
+ * The value injected for `$stateParams` is different depending on where it is injected.
13
+ *
14
+ * - When injected into an angular service, the object injected is the global **Service Object** with the parameter values for the latest successful `Transition`.
15
+ * - When injected into transition hooks, resolves, or view controllers, the object is the **Per-Transition Object** with the parameter values for the running `Transition`.
16
+ *
17
+ * Because of these confusing details, this service is deprecated.
18
+ *
19
+ * ### Instead of using the global `$stateParams` service object,
20
+ * inject [[$uiRouterGlobals]] and use [[UIRouterGlobals.params]]
21
+ *
22
+ * ```js
23
+ * MyService.$inject = ['$uiRouterGlobals'];
24
+ * function MyService($uiRouterGlobals) {
25
+ * return {
26
+ * paramValues: function () {
27
+ * return $uiRouterGlobals.params;
28
+ * }
29
+ * }
30
+ * }
31
+ * ```
32
+ *
33
+ * ### Instead of using the per-transition `$stateParams` object,
34
+ * inject the current `Transition` (as [[$transition$]]) and use [[Transition.params]]
35
+ *
36
+ * ```js
37
+ * MyController.$inject = ['$transition$'];
38
+ * function MyController($transition$) {
39
+ * var username = $transition$.params().username;
40
+ * // .. do something with username
41
+ * }
42
+ * ```
43
+ *
44
+ * ---
45
+ *
46
+ * This object can be injected into other services.
47
+ *
48
+ * #### Deprecated Example:
49
+ * ```js
50
+ * SomeService.$inject = ['$http', '$stateParams'];
51
+ * function SomeService($http, $stateParams) {
52
+ * return {
53
+ * getUser: function() {
54
+ * return $http.get('/api/users/' + $stateParams.username);
55
+ * }
56
+ * }
57
+ * };
58
+ * angular.service('SomeService', SomeService);
59
+ * ```
60
+ * @deprecated
61
+ */
62
+ let $stateParams;
63
+ /**
64
+ * Global UI-Router variables
65
+ *
66
+ * The router global state as a **Service Object** (injectable during runtime).
67
+ *
68
+ * This object contains globals such as the current state and current parameter values.
69
+ */
70
+ let $uiRouterGlobals;
71
+ /**
72
+ * The UI-Router instance
73
+ *
74
+ * The [[UIRouter]] singleton (the router instance) as a **Service Object** (injectable during runtime).
75
+ *
76
+ * This object is the UI-Router singleton instance, created by angular dependency injection during application bootstrap.
77
+ * It has references to the other UI-Router services
78
+ *
79
+ * #### Note: This object is also exposed as [[$uiRouterProvider]] for injection during angular config time.
80
+ */
81
+ let $uiRouter;
82
+ /**
83
+ * The UI-Router instance
84
+ *
85
+ * The [[UIRouter]] singleton (the router instance) as a **Provider Object** (injectable during config phase).
86
+ *
87
+ * This object is the UI-Router singleton instance, created by angular dependency injection during application bootstrap.
88
+ * It has references to the other UI-Router services
89
+ *
90
+ * #### Note: This object is also exposed as [[$uiRouter]] for injection during runtime.
91
+ */
92
+ let $uiRouterProvider;
93
+ /**
94
+ * Transition debug/tracing
95
+ *
96
+ * The [[Trace]] singleton as a **Service Object** (injectable during runtime).
97
+ *
98
+ * Enables or disables Transition tracing which can help to debug issues.
99
+ */
100
+ let $trace;
101
+ /**
102
+ * The Transition Service
103
+ *
104
+ * The [[TransitionService]] singleton as a **Service Object** (injectable during runtime).
105
+ *
106
+ * This angular service exposes the [[TransitionService]] singleton, which is primarily
107
+ * used to register global transition hooks.
108
+ *
109
+ * #### Note: This object is also exposed as [[$transitionsProvider]] for injection during the config phase.
110
+ */
111
+ let $transitions;
112
+ /**
113
+ * The Transition Service
114
+ *
115
+ * The [[TransitionService]] singleton as a **Provider Object** (injectable during config phase)
116
+ *
117
+ * This angular service exposes the [[TransitionService]] singleton, which is primarily
118
+ * used to register global transition hooks.
119
+ *
120
+ * #### Note: This object is also exposed as [[$transitions]] for injection during runtime.
121
+ */
122
+ let $transitionsProvider;
123
+ /**
124
+ * The current [[Transition]] object
125
+ *
126
+ * The current [[Transition]] object as a **Per-Transition Object** (injectable into Resolve, Hooks, Controllers)
127
+ *
128
+ * This object returns information about the current transition, including:
129
+ *
130
+ * - To/from states
131
+ * - To/from parameters
132
+ * - Transition options
133
+ * - States being entered, exited, and retained
134
+ * - Resolve data
135
+ * - A Promise for the transition
136
+ * - Any transition failure information
137
+ * - An injector for both Service and Per-Transition Objects
138
+ */
139
+ let $transition$;
140
+ /**
141
+ * The State Service
142
+ *
143
+ * The [[StateService]] singleton as a **Service Object** (injectable during runtime).
144
+ *
145
+ * This service used to manage and query information on registered states.
146
+ * It exposes state related APIs including:
147
+ *
148
+ * - Start a [[Transition]]
149
+ * - Imperatively lazy load states
150
+ * - Check if a state is currently active
151
+ * - Look up states by name
152
+ * - Build URLs for a state+parameters
153
+ * - Configure the global Transition error handler
154
+ *
155
+ * This angular service exposes the [[StateService]] singleton.
156
+ */
157
+ let $state;
158
+ /**
159
+ * The State Registry
160
+ *
161
+ * The [[StateRegistry]] singleton as a **Service Object** (injectable during runtime).
162
+ *
163
+ * This service is used to register/deregister states.
164
+ * It has state registration related APIs including:
165
+ *
166
+ * - Register/deregister states
167
+ * - Listen for state registration/deregistration
168
+ * - Get states by name
169
+ * - Add state decorators (to customize the state creation process)
170
+ *
171
+ * #### Note: This object is also exposed as [[$stateRegistryProvider]] for injection during the config phase.
172
+ */
173
+ let $stateRegistry;
174
+ /**
175
+ * The State Registry
176
+ *
177
+ * The [[StateRegistry]] singleton as a **Provider Object** (injectable during config time).
178
+ *
179
+ * This service is used to register/deregister states.
180
+ * It has state registration related APIs including:
181
+ *
182
+ * - Register/deregister states
183
+ * - Listen for state registration/deregistration
184
+ * - Get states by name
185
+ * - Add state decorators (to customize the state creation process)
186
+ *
187
+ * #### Note: This object is also exposed as [[$stateRegistry]] for injection during runtime.
188
+ */
189
+ let $stateRegistryProvider;
190
+ /**
191
+ * The View Scroll provider
192
+ *
193
+ * The [[UIViewScrollProvider]] as a **Provider Object** (injectable during config time).
194
+ *
195
+ * This angular service exposes the [[UIViewScrollProvider]] singleton and is
196
+ * used to disable UI-Router's scroll behavior.
197
+ */
198
+ let $uiViewScrollProvider;
199
+ /**
200
+ * The View Scroll function
201
+ *
202
+ * The View Scroll function as a **Service Object** (injectable during runtime).
203
+ *
204
+ * This is a function that scrolls an element into view.
205
+ * The element is scrolled after a `$timeout` so the DOM has time to refresh.
206
+ *
207
+ * If you prefer to rely on `$anchorScroll` to scroll the view to the anchor,
208
+ * this can be enabled by calling [[UIViewScrollProvider.useAnchorScroll]].
209
+ *
210
+ * Note: this function is used by the [[directives.uiView]] when the `autoscroll` expression evaluates to true.
211
+ */
212
+ let $uiViewScroll;
213
+ /**
214
+ * The StateProvider
215
+ *
216
+ * An angular1-only [[StateProvider]] as a **Provider Object** (injectable during config time).
217
+ *
218
+ * This angular service exposes the [[StateProvider]] singleton.
219
+ *
220
+ * The `StateProvider` is primarily used to register states or add custom state decorators.
221
+ *
222
+ * ##### Note: This provider is a ng1 vestige.
223
+ * It is a passthrough to [[$stateRegistry]] and [[$state]].
224
+ */
225
+ let $stateProvider;
226
+ /**
227
+ * The URL Service Provider
228
+ *
229
+ * The [[UrlService]] singleton as a **Provider Object** (injectable during the angular config phase).
230
+ *
231
+ * A service used to configure and interact with the URL.
232
+ * It has URL related APIs including:
233
+ *
234
+ * - register custom Parameter types `UrlService.config.type` ([[UrlConfigApi.type]])
235
+ * - add URL rules: `UrlService.rules.when` ([[UrlRulesApi.when]])
236
+ * - configure behavior when no url matches: `UrlService.rules.otherwise` ([[UrlRulesApi.otherwise]])
237
+ * - delay initial URL synchronization [[UrlService.deferIntercept]].
238
+ * - get or set the current url: [[UrlService.url]]
239
+ *
240
+ * ##### Note: This service can also be injected during runtime as [[$urlService]].
241
+ */
242
+ let $urlServiceProvider;
243
+ /**
244
+ * The URL Service
245
+ *
246
+ * The [[UrlService]] singleton as a **Service Object** (injectable during runtime).
247
+ *
248
+ * Note: This service can also be injected during the config phase as [[$urlServiceProvider]].
249
+ *
250
+ * Used to configure the URL.
251
+ * It has URL related APIs including:
252
+ *
253
+ * - register custom Parameter types `UrlService.config.type` ([[UrlConfigApi.type]])
254
+ * - add URL rules: `UrlService.rules.when` ([[UrlRulesApi.when]])
255
+ * - configure behavior when no url matches: `UrlService.rules.otherwise` ([[UrlRulesApi.otherwise]])
256
+ * - delay initial URL synchronization [[UrlService.deferIntercept]].
257
+ * - get or set the current url: [[UrlService.url]]
258
+ *
259
+ * ##### Note: This service can also be injected during the config phase as [[$urlServiceProvider]].
260
+ */
261
+ let $urlService;
262
+ /**
263
+ * The URL Router Provider
264
+ *
265
+ * ### Deprecation warning: This object is now considered internal. Use [[$urlServiceProvider]] instead.
266
+ *
267
+ * The [[UrlRouter]] singleton as a **Provider Object** (injectable during config time).
268
+ *
269
+ * #### Note: This object is also exposed as [[$urlRouter]] for injection during runtime.
270
+ *
271
+ * @deprecated
272
+ */
273
+ let $urlRouterProvider;
274
+ /**
275
+ * The Url Router
276
+ *
277
+ * ### Deprecation warning: This object is now considered internal. Use [[$urlService]] instead.
278
+ *
279
+ * The [[UrlRouter]] singleton as a **Service Object** (injectable during runtime).
280
+ *
281
+ * #### Note: This object is also exposed as [[$urlRouterProvider]] for injection during angular config time.
282
+ *
283
+ * @deprecated
284
+ */
285
+ let $urlRouter;
286
+ /**
287
+ * The URL Matcher Factory
288
+ *
289
+ * ### Deprecation warning: This object is now considered internal. Use [[$urlService]] instead.
290
+ *
291
+ * The [[UrlMatcherFactory]] singleton as a **Service Object** (injectable during runtime).
292
+ *
293
+ * This service is used to set url mapping options, define custom parameter types, and create [[UrlMatcher]] objects.
294
+ *
295
+ * #### Note: This object is also exposed as [[$urlMatcherFactoryProvider]] for injection during angular config time.
296
+ *
297
+ * @deprecated
298
+ */
299
+ let $urlMatcherFactory;
300
+ /**
301
+ * The URL Matcher Factory
302
+ *
303
+ * ### Deprecation warning: This object is now considered internal. Use [[$urlService]] instead.
304
+ *
305
+ * The [[UrlMatcherFactory]] singleton as a **Provider Object** (injectable during config time).
306
+ *
307
+ * This service is used to set url mapping options, define custom parameter types, and create [[UrlMatcher]] objects.
308
+ *
309
+ * #### Note: This object is also exposed as [[$urlMatcherFactory]] for injection during runtime.
310
+ *
311
+ * @deprecated
312
+ */
313
+ let $urlMatcherFactoryProvider;
314
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,84 @@
1
+ /** @publicapi @module ng1 */ /** */
2
+ import { isDefined, isObject } from "../../core/utils";
3
+ import { val } from "../core/common/hof";
4
+ import { createProxyFunctions, removeFrom } from "../core/common/common";
5
+ /**
6
+ * Implements UI-Router LocationServices and LocationConfig using Angular 1's $location service
7
+ * @internalapi
8
+ */
9
+ export class Ng1LocationServices {
10
+ /**
11
+ * Applys ng1-specific path parameter encoding
12
+ *
13
+ * The Angular 1 `$location` service is a bit weird.
14
+ * It doesn't allow slashes to be encoded/decoded bi-directionally.
15
+ *
16
+ * See the writeup at https://github.com/angular-ui/ui-router/issues/2598
17
+ *
18
+ * This code patches the `path` parameter type so it encoded/decodes slashes as ~2F
19
+ *
20
+ * @param router
21
+ */
22
+ static monkeyPatchPathParameterType(router) {
23
+ const pathType = router.urlMatcherFactory.type("path");
24
+ pathType.encode = (x) =>
25
+ x != null
26
+ ? x.toString().replace(/(~|\/)/g, (m) => ({ "~": "~~", "/": "~2F" })[m])
27
+ : x;
28
+ pathType.decode = (x) =>
29
+ x != null
30
+ ? x
31
+ .toString()
32
+ .replace(/(~~|~2F)/g, (m) => ({ "~~": "~", "~2F": "/" })[m])
33
+ : x;
34
+ }
35
+ dispose() {}
36
+ constructor($locationProvider) {
37
+ // .onChange() registry
38
+ this._urlListeners = [];
39
+ this.$locationProvider = $locationProvider;
40
+ const _lp = val($locationProvider);
41
+ createProxyFunctions(_lp, this, _lp, ["hashPrefix"]);
42
+ }
43
+ onChange(callback) {
44
+ this._urlListeners.push(callback);
45
+ return () => removeFrom(this._urlListeners)(callback);
46
+ }
47
+ html5Mode() {
48
+ let html5Mode = this.$locationProvider.html5Mode();
49
+ html5Mode = isObject(html5Mode) ? html5Mode.enabled : html5Mode;
50
+ return html5Mode && typeof history !== "undefined";
51
+ }
52
+ baseHref() {
53
+ return (
54
+ this._baseHref ||
55
+ (this._baseHref =
56
+ this.$browser.baseHref() || this.$window.location.pathname)
57
+ );
58
+ }
59
+ url(newUrl, replace = false, state) {
60
+ if (isDefined(newUrl)) this.$location.url(newUrl);
61
+ if (replace) this.$location.replace();
62
+ if (state) this.$location.state(state);
63
+ return this.$location.url();
64
+ }
65
+ _runtimeServices($rootScope, $location, $browser) {
66
+ this.$location = $location;
67
+ this.$browser = $browser;
68
+ this.$window = window;
69
+ // Bind $locationChangeSuccess to the listeners registered in LocationService.onChange
70
+ $rootScope.$on("$locationChangeSuccess", (evt) =>
71
+ this._urlListeners.forEach((fn) => fn(evt)),
72
+ );
73
+ const _loc = val($location);
74
+ // Bind these LocationService functions to $location
75
+ createProxyFunctions(_loc, this, _loc, [
76
+ "replace",
77
+ "path",
78
+ "search",
79
+ "hash",
80
+ ]);
81
+ // Bind these LocationConfig functions to $location
82
+ createProxyFunctions(_loc, this, _loc, ["port", "protocol", "host"]);
83
+ }
84
+ }
@@ -0,0 +1,126 @@
1
+ /**
2
+ * # Angular 1 types
3
+ *
4
+ * UI-Router core provides various Typescript types which you can use for code completion and validating parameter values, etc.
5
+ * The customizations to the core types for Angular UI-Router are documented here.
6
+ *
7
+ * The optional [[$resolve]] service is also documented here.
8
+ *
9
+ * @preferred @publicapi @module ng1
10
+ */
11
+ import { services } from "../core/common/coreservices";
12
+ import { applyPairs, unnestR } from "../core/common/common";
13
+ import { isString, extend } from "../../core/utils";
14
+ import { trace } from "../core/common/trace";
15
+ import { UIRouter } from "../core/router";
16
+ import {
17
+ ng1ViewsBuilder,
18
+ getNg1ViewConfigFactory,
19
+ } from "./statebuilders/views";
20
+
21
+ import { StateProvider } from "./stateProvider";
22
+ import { getStateHookBuilder } from "./statebuilders/onEnterExitRetain";
23
+ import { Ng1LocationServices } from "./locationServices";
24
+
25
+ export let router = null;
26
+ $uiRouterProvider.$inject = ["$locationProvider"];
27
+ /** This angular 1 provider instantiates a Router and exposes its services via the angular injector */
28
+ export function $uiRouterProvider($locationProvider) {
29
+ // Create a new instance of the Router when the $uiRouterProvider is initialized
30
+ router = this.router = new UIRouter();
31
+ router.stateProvider = new StateProvider(
32
+ router.stateRegistry,
33
+ router.stateService,
34
+ );
35
+ // Apply ng1 specific StateBuilder code for `views`, `resolve`, and `onExit/Retain/Enter` properties
36
+ router.stateRegistry.decorator("views", ng1ViewsBuilder);
37
+ router.stateRegistry.decorator("onExit", getStateHookBuilder("onExit"));
38
+ router.stateRegistry.decorator("onRetain", getStateHookBuilder("onRetain"));
39
+ router.stateRegistry.decorator("onEnter", getStateHookBuilder("onEnter"));
40
+ router.viewService._pluginapi._viewConfigFactory(
41
+ "ng1",
42
+ getNg1ViewConfigFactory(),
43
+ );
44
+ // Disable decoding of params by UrlMatcherFactory because $location already handles this
45
+ router.urlService.config._decodeParams = false;
46
+ const ng1LocationService =
47
+ (router.locationService =
48
+ router.locationConfig =
49
+ new Ng1LocationServices($locationProvider));
50
+ Ng1LocationServices.monkeyPatchPathParameterType(router);
51
+ // backwards compat: also expose router instance as $uiRouterProvider.router
52
+ router["router"] = router;
53
+ router["$get"] = $get;
54
+ $get.$inject = ["$location", "$browser", "$rootScope"];
55
+ function $get($location, $browser, $rootScope) {
56
+ ng1LocationService._runtimeServices($rootScope, $location, $browser);
57
+ delete router["router"];
58
+ delete router["$get"];
59
+ return router;
60
+ }
61
+ return router;
62
+ }
63
+ export const getProviderFor = (serviceName) => [
64
+ "$uiRouterProvider",
65
+ function UrlServiceProvider($urp) {
66
+ const service = $urp.router[serviceName];
67
+ service["$get"] = () => service;
68
+ return service;
69
+ },
70
+ ];
71
+ // This effectively calls $get() on `$uiRouterProvider` to trigger init (when ng enters runtime)
72
+ runBlock.$inject = ["$injector", "$q", "$uiRouter"];
73
+ export function runBlock($injector, $q, $uiRouter) {
74
+ services.$injector = $injector;
75
+ services.$q = $q;
76
+ // https://github.com/angular-ui/ui-router/issues/3678
77
+ if (!Object.prototype.hasOwnProperty.call($injector, "strictDi")) {
78
+ try {
79
+ $injector.invoke(function (checkStrictDi) {});
80
+ } catch (error) {
81
+ $injector.strictDi = !!/strict mode/.exec(error && error.toString());
82
+ }
83
+ }
84
+ // The $injector is now available.
85
+ // Find any resolvables that had dependency annotation deferred
86
+ $uiRouter.stateRegistry
87
+ .get()
88
+ .map((x) => x.$$state().resolvables)
89
+ .reduce(unnestR, [])
90
+ .filter((x) => x.deps === "deferred")
91
+ .forEach(
92
+ (resolvable) =>
93
+ (resolvable.deps = $injector.annotate(
94
+ resolvable.resolveFn,
95
+ $injector.strictDi,
96
+ )),
97
+ );
98
+ }
99
+
100
+ // $state service and $stateProvider
101
+ // $urlRouter service and $urlRouterProvider
102
+ export function getStateProvider() {
103
+ debugger;
104
+ return extend(router.stateProvider, { $get: () => router.stateService });
105
+ }
106
+
107
+ watchDigests.$inject = ["$rootScope"];
108
+ export function watchDigests($rootScope) {
109
+ $rootScope.$watch(function () {
110
+ trace.approximateDigests++;
111
+ });
112
+ }
113
+
114
+ /** @hidden TODO: find a place to move this */
115
+ export const getLocals = (ctx) => {
116
+ const tokens = ctx.getTokens().filter(isString);
117
+ const tuples = tokens.map((key) => {
118
+ const resolvable = ctx.getResolvable(key);
119
+ const waitPolicy = ctx.getPolicy(resolvable).async;
120
+ return [
121
+ key,
122
+ waitPolicy === "NOWAIT" ? resolvable.promise : resolvable.data,
123
+ ];
124
+ });
125
+ return tuples.reduce(applyPairs, {});
126
+ };
@@ -0,0 +1,43 @@
1
+ /** @publicapi @module ng1 */ /** */
2
+
3
+ /**
4
+ * `isState` Filter: truthy if the current state is the parameter
5
+ *
6
+ * Translates to [[StateService.is]] `$state.is("stateName")`.
7
+ *
8
+ * #### Example:
9
+ * ```html
10
+ * <div ng-if="'stateName' | isState">show if state is 'stateName'</div>
11
+ * ```
12
+ */
13
+ $IsStateFilter.$inject = ["$state"];
14
+ function $IsStateFilter($state) {
15
+ const isFilter = function (state, params, options) {
16
+ return $state.is(state, params, options);
17
+ };
18
+ isFilter.$stateful = true;
19
+ return isFilter;
20
+ }
21
+ /**
22
+ * `includedByState` Filter: truthy if the current state includes the parameter
23
+ *
24
+ * Translates to [[StateService.includes]]` $state.is("fullOrPartialStateName")`.
25
+ *
26
+ * #### Example:
27
+ * ```html
28
+ * <div ng-if="'fullOrPartialStateName' | includedByState">show if state includes 'fullOrPartialStateName'</div>
29
+ * ```
30
+ */
31
+ $IncludedByStateFilter.$inject = ["$state"];
32
+ function $IncludedByStateFilter($state) {
33
+ const includesFilter = function (state, params, options) {
34
+ return $state.includes(state, params, options);
35
+ };
36
+ includesFilter.$stateful = true;
37
+ return includesFilter;
38
+ }
39
+ window.angular
40
+ .module("ui.router.state")
41
+ .filter("isState", $IsStateFilter)
42
+ .filter("includedByState", $IncludedByStateFilter);
43
+ export { $IsStateFilter, $IncludedByStateFilter };