@angular-wave/angular.ts 0.0.29 → 0.0.31

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 (63) hide show
  1. package/dist/angular-ts.esm.js +1 -1
  2. package/dist/angular-ts.umd.js +1 -1
  3. package/index.html +5 -6
  4. package/package.json +1 -1
  5. package/src/core/controller.js +3 -0
  6. package/src/directive/controller.js +0 -56
  7. package/src/directive/controller.md +46 -0
  8. package/src/router/common/trace.js +1 -1
  9. package/src/router/directives/state-directives.js +1 -1
  10. package/src/router/hooks/update-globals.js +1 -1
  11. package/src/router/hooks/url.js +4 -4
  12. package/src/router/index.js +0 -6
  13. package/src/router/injectables.js +9 -60
  14. package/src/router/resolve/resolve-context.js +1 -1
  15. package/src/router/router.js +3 -95
  16. package/src/router/services.js +2 -58
  17. package/src/router/state/state-builder.js +7 -6
  18. package/src/router/state/state-object.js +1 -1
  19. package/src/router/state/state-registry.js +6 -5
  20. package/src/router/state/state-service.js +4 -5
  21. package/src/router/state/target-state.js +1 -1
  22. package/src/router/state/views.js +1 -1
  23. package/src/router/url/url-config.js +25 -2
  24. package/src/router/url/url-matcher.js +0 -8
  25. package/src/router/url/url-service.js +138 -8
  26. package/src/router/view/view.js +3 -1
  27. package/src/shared/common.js +2 -2
  28. package/test/router/services.spec.js +8 -17
  29. package/test/router/{url-matcher-factory.spec.js → url-service.spec.js} +126 -130
  30. package/test/router/view.spec.js +4 -11
  31. package/types/router/core/common/coreservices.d.ts +2 -2
  32. package/types/router/core/common/trace.d.ts +7 -7
  33. package/types/router/core/globals.d.ts +2 -1
  34. package/types/router/core/interface.d.ts +3 -10
  35. package/types/router/core/params/interface.d.ts +5 -5
  36. package/types/router/core/resolve/resolveContext.d.ts +4 -4
  37. package/types/router/core/router.d.ts +5 -51
  38. package/types/router/core/state/interface.d.ts +6 -6
  39. package/types/router/core/state/stateObject.d.ts +1 -1
  40. package/types/router/core/state/stateQueueManager.d.ts +2 -2
  41. package/types/router/core/state/stateRegistry.d.ts +4 -4
  42. package/types/router/core/state/stateService.d.ts +9 -9
  43. package/types/router/core/state/targetState.d.ts +1 -1
  44. package/types/router/core/transition/interface.d.ts +1 -1
  45. package/types/router/core/transition/transition.d.ts +12 -12
  46. package/types/router/core/transition/transitionService.d.ts +5 -5
  47. package/types/router/core/url/interface.d.ts +3 -3
  48. package/types/router/core/url/urlConfig.d.ts +3 -3
  49. package/types/router/core/url/urlMatcherFactory.d.ts +4 -4
  50. package/types/router/core/url/urlRouter.d.ts +2 -2
  51. package/types/router/core/url/urlRule.d.ts +6 -6
  52. package/types/router/core/url/urlRules.d.ts +6 -6
  53. package/types/router/core/url/urlService.d.ts +8 -8
  54. package/types/router/core/view/interface.d.ts +1 -1
  55. package/types/router/core/view/view.d.ts +15 -15
  56. package/types/router/directives/viewDirective.d.ts +4 -4
  57. package/types/router/interface.d.ts +4 -4
  58. package/types/router/locationServices.d.ts +3 -3
  59. package/types/router/services.d.ts +1 -1
  60. package/types/router/stateProvider.d.ts +2 -2
  61. package/types/router/viewScroll.d.ts +1 -1
  62. package/src/router/url/url-matcher-factory.js +0 -77
  63. package/src/router/url/url-router.js +0 -101
@@ -1,4 +1,4 @@
1
- import { UIRouter } from "../router";
1
+ import { Router } from "../router";
2
2
  import { ParamTypeDefinition, ParamTypes } from "../params";
3
3
  /**
4
4
  * An API to customize the URL behavior and retrieve URL configuration
@@ -11,7 +11,7 @@ import { ParamTypeDefinition, ParamTypes } from "../params";
11
11
  * This information can be used to build absolute URLs, such as
12
12
  * `https://example.com:443/basepath/state/substate?param1=a#hashvalue`;
13
13
  *
14
- * This API is found at `router.urlService.config` (see: [[UIRouter.urlService]], [[URLService.config]])
14
+ * This API is found at `router.urlService.config` (see: [[Router.urlService]], [[URLService.config]])
15
15
  */
16
16
  export declare class UrlConfig {
17
17
  private router;
@@ -20,7 +20,7 @@ export declare class UrlConfig {
20
20
  /** @internal */ _isCaseInsensitive: boolean;
21
21
  /** @internal */ _isStrictMode: boolean;
22
22
  /** @internal */ _defaultSquashPolicy: boolean | string;
23
- /** @internal */ constructor(/** @internal */ router: UIRouter);
23
+ /** @internal */ constructor(/** @internal */ router: Router);
24
24
  /** @internal */ dispose: () => void;
25
25
  /**
26
26
  * Gets the base Href, e.g., `http://localhost/approot/`
@@ -2,19 +2,19 @@ import { UrlMatcher } from "./urlMatcher";
2
2
  import { Param, ParamType, ParamTypeDefinition } from "../params";
3
3
  import { UrlMatcherCompileConfig } from "./interface";
4
4
  import { StateDeclaration } from "../state";
5
- import { UIRouter } from "../router";
5
+ import { Router } from "../router";
6
6
  export declare class ParamFactory {
7
7
  private router;
8
8
  fromConfig(id: string, type: ParamType, state: StateDeclaration): Param;
9
9
  fromPath(id: string, type: ParamType, state: StateDeclaration): Param;
10
10
  fromSearch(id: string, type: ParamType, state: StateDeclaration): Param;
11
- constructor(router: UIRouter);
11
+ constructor(router: Router);
12
12
  }
13
13
  /**
14
14
  * Factory for [[UrlMatcher]] instances.
15
15
  *
16
16
  * The factory is available to ng1 services as
17
- * `$urlMatcherFactory` or ng1 providers as `$urlMatcherFactoryProvider`.
17
+ * `$urlMatcherFactory` or ng1 providers as `$urlServiceProvider`.
18
18
  */
19
19
  export declare class UrlMatcherFactory {
20
20
  private router;
@@ -22,7 +22,7 @@ export declare class UrlMatcherFactory {
22
22
  paramFactory: ParamFactory;
23
23
  UrlMatcher: typeof UrlMatcher;
24
24
  Param: typeof Param;
25
- constructor(/** @internal */ router: UIRouter);
25
+ constructor(/** @internal */ router: Router);
26
26
  /**
27
27
  * Creates a [[UrlMatcher]] for the specified pattern.
28
28
  *
@@ -1,6 +1,6 @@
1
1
  import { UrlMatcher } from "./urlMatcher";
2
2
  import { RawParams } from "../params";
3
- import { UIRouter } from "../router";
3
+ import { Router } from "../router";
4
4
  import { UrlRuleFactory } from "./urlRule";
5
5
  import { MatchResult, UrlParts, UrlRule, UrlRuleHandlerFn } from "./interface";
6
6
  import { TargetState, TargetStateDef } from "../state";
@@ -18,7 +18,7 @@ export declare class UrlRouter {
18
18
  urlRuleFactory: UrlRuleFactory;
19
19
  /** @internal */ private location;
20
20
  /** @internal */
21
- constructor(/** @internal */ router: UIRouter);
21
+ constructor(/** @internal */ router: Router);
22
22
  /** Internal API. */
23
23
  update(read?: boolean): void;
24
24
  /**
@@ -1,6 +1,6 @@
1
1
  import { StateDeclaration } from "../state";
2
2
  import { UrlMatcher } from "./urlMatcher";
3
- import { UIRouter } from "../router";
3
+ import { Router } from "../router";
4
4
  import { StateObject } from "../state/stateObject";
5
5
  import {
6
6
  UrlRule,
@@ -22,9 +22,9 @@ import {
22
22
  * - [[StateObject]]
23
23
  */
24
24
  export declare class UrlRuleFactory {
25
- router: UIRouter;
25
+ router: Router;
26
26
  static isUrlRule: (obj: any) => boolean;
27
- constructor(router: UIRouter);
27
+ constructor(router: Router);
28
28
  compile(str: string): UrlMatcher;
29
29
  create(
30
30
  what:
@@ -47,7 +47,7 @@ export declare class UrlRuleFactory {
47
47
  *
48
48
  * - matched parameter values ([[RawParams]] from [[UrlMatcher.exec]])
49
49
  * - url: the current Url ([[UrlParts]])
50
- * - router: the router object ([[UIRouter]])
50
+ * - router: the router object ([[Router]])
51
51
  *
52
52
  * #### Example:
53
53
  * ```js
@@ -89,7 +89,7 @@ export declare class UrlRuleFactory {
89
89
  */
90
90
  fromState(
91
91
  stateOrDecl: StateObject | StateDeclaration,
92
- router: UIRouter,
92
+ router: Router,
93
93
  ): StateRule;
94
94
  /**
95
95
  * A UrlRule which matches based on a regular expression
@@ -102,7 +102,7 @@ export declare class UrlRuleFactory {
102
102
  *
103
103
  * - regexp match array (from `regexp`)
104
104
  * - url: the current Url ([[UrlParts]])
105
- * - router: the router object ([[UIRouter]])
105
+ * - router: the router object ([[Router]])
106
106
  *
107
107
  * #### Example:
108
108
  * ```js
@@ -1,4 +1,4 @@
1
- import { UIRouter } from "../router";
1
+ import { Router } from "../router";
2
2
  import { UrlRule, UrlRuleHandlerFn } from "./interface";
3
3
  import { TargetState, TargetStateDef } from "../state";
4
4
  import { UrlMatcher } from "./urlMatcher";
@@ -11,7 +11,7 @@ import { UrlRuleFactory } from "./urlRule";
11
11
  *
12
12
  * The most commonly used methods are [[otherwise]] and [[when]].
13
13
  *
14
- * This API is found at `router.urlService.rules` (see: [[UIRouter.urlService]], [[URLService.rules]])
14
+ * This API is found at `router.urlService.rules` (see: [[Router.urlService]], [[URLService.rules]])
15
15
  */
16
16
  export declare class UrlRules {
17
17
  private router;
@@ -23,9 +23,9 @@ export declare class UrlRules {
23
23
  /** @internal */ private _rules;
24
24
  /** @internal */ private _id;
25
25
  /** @internal */
26
- constructor(/** @internal */ router: UIRouter);
26
+ constructor(/** @internal */ router: Router);
27
27
  /** @internal */
28
- dispose(router?: UIRouter): void;
28
+ dispose(router?: Router): void;
29
29
  /**
30
30
  * Defines the initial state, path, or behavior to use when the app starts.
31
31
  *
@@ -86,7 +86,7 @@ export declare class UrlRules {
86
86
  * .otherwise({ state: 'home', params: { dashboard: 'default' } });
87
87
  * ```
88
88
  *
89
- * - If `handler` is a function, the function receives the current url ([[UrlParts]]) and the [[UIRouter]] object.
89
+ * - If `handler` is a function, the function receives the current url ([[UrlParts]]) and the [[Router]] object.
90
90
  * The function can perform actions, and/or return a value.
91
91
  *
92
92
  * #### Example:
@@ -220,7 +220,7 @@ export declare class UrlRules {
220
220
  *
221
221
  * ---
222
222
  *
223
- * When the handler is a function, it receives the matched value, the current URL, and the `UIRouter` object (See [[UrlRuleHandlerFn]]).
223
+ * When the handler is a function, it receives the matched value, the current URL, and the `Router` object (See [[UrlRuleHandlerFn]]).
224
224
  * The "matched value" differs based on the `matcher`.
225
225
  * For [[UrlMatcher]]s, it will be the matched state params.
226
226
  * For `RegExp`, it will be the match array from `regexp.exec()`.
@@ -1,4 +1,4 @@
1
- import { UIRouter } from "../router";
1
+ import { Router } from "../router";
2
2
  import { LocationServices } from "../common";
3
3
  import { MatchResult, UrlParts, UrlSyncApi } from "./interface";
4
4
  import { UrlRules } from "./urlRules";
@@ -23,7 +23,7 @@ export declare class UrlService implements LocationServices, UrlSyncApi {
23
23
  */
24
24
  config: UrlConfig;
25
25
  /** @internal */
26
- constructor(/** @internal */ router: UIRouter);
26
+ constructor(/** @internal */ router: Router);
27
27
 
28
28
  /**
29
29
  * Gets the current URL parts
@@ -56,9 +56,9 @@ export declare class UrlService implements LocationServices, UrlSyncApi {
56
56
  * Starts or stops listening for URL changes
57
57
  *
58
58
  * Call this sometime after calling [[deferIntercept]] to start monitoring the url.
59
- * This causes UI-Router to start listening for changes to the URL, if it wasn't already listening.
59
+ * This causes Router to start listening for changes to the URL, if it wasn't already listening.
60
60
  *
61
- * If called with `false`, UI-Router will stop listening (call listen(true) to start listening again).
61
+ * If called with `false`, Router will stop listening (call listen(true) to start listening again).
62
62
  *
63
63
  * #### Example:
64
64
  * ```js
@@ -78,15 +78,15 @@ export declare class UrlService implements LocationServices, UrlSyncApi {
78
78
  /**
79
79
  * Disables monitoring of the URL.
80
80
  *
81
- * Call this method before UI-Router has bootstrapped.
82
- * It will stop UI-Router from performing the initial url sync.
81
+ * Call this method before Router has bootstrapped.
82
+ * It will stop Router from performing the initial url sync.
83
83
  *
84
84
  * This can be useful to perform some asynchronous initialization before the router starts.
85
- * Once the initialization is complete, call [[listen]] to tell UI-Router to start watching and synchronizing the URL.
85
+ * Once the initialization is complete, call [[listen]] to tell Router to start watching and synchronizing the URL.
86
86
  *
87
87
  * #### Example:
88
88
  * ```js
89
- * // Prevent UI-Router from automatically intercepting URL changes when it starts;
89
+ * // Prevent Router from automatically intercepting URL changes when it starts;
90
90
  * urlService.deferIntercept();
91
91
  *
92
92
  * fetch('/states.json').then(resp => resp.json()).then(data => {
@@ -5,7 +5,7 @@ export interface ViewContext {
5
5
  name: string;
6
6
  parent: ViewContext;
7
7
  }
8
- export interface ActiveUIView {
8
+ export interface ActiveNGView {
9
9
  /** type of framework, e.g., "ng1" or "ng2" */
10
10
  $type: string;
11
11
  /** An auto-incremented id */
@@ -1,8 +1,8 @@
1
1
  import { TypedMap } from "../common/common";
2
2
  import { PathNode } from "../path/pathNode";
3
- import { ActiveUIView, ViewContext, ViewConfig } from "./interface";
3
+ import { ActiveNGView, ViewContext, ViewConfig } from "./interface";
4
4
  import { _ViewDeclaration } from "../state/interface";
5
- import { UIRouter } from "../router";
5
+ import { Router } from "../router";
6
6
  export declare type ViewConfigFactory = (
7
7
  path: PathNode[],
8
8
  decl: _ViewDeclaration,
@@ -11,13 +11,13 @@ export interface ViewServicePluginAPI {
11
11
  _rootViewContext(context?: ViewContext): ViewContext;
12
12
  _viewConfigFactory(viewType: string, factory: ViewConfigFactory): any;
13
13
  /** @param id router.$id + "." + ngView.id */
14
- _registeredUIView(id: string): ActiveUIView;
15
- _registeredUIViews(): ActiveUIView[];
14
+ _registeredNGView(id: string): ActiveNGView;
15
+ _registeredNGViews(): ActiveNGView[];
16
16
  _activeViewConfigs(): ViewConfig[];
17
17
  _onSync(listener: ViewSyncListener): Function;
18
18
  }
19
19
  export interface ViewTuple {
20
- ngView: ActiveUIView;
20
+ ngView: ActiveNGView;
21
21
  viewConfig: ViewConfig;
22
22
  }
23
23
  export interface ViewSyncListener {
@@ -33,9 +33,9 @@ export interface ViewSyncListener {
33
33
  * The views from exited states are deactivated via [[deactivateViewConfig]].
34
34
  * (See: the [[registerActivateViews]] Transition Hook)
35
35
  *
36
- * - As `ui-view` components pop in and out of existence, they register themselves using [[registerUIView]].
36
+ * - As `ui-view` components pop in and out of existence, they register themselves using [[registerNGView]].
37
37
  *
38
- * - When the [[sync]] function is called, the registered `ui-view`(s) ([[ActiveUIView]])
38
+ * - When the [[sync]] function is called, the registered `ui-view`(s) ([[ActiveNGView]])
39
39
  * are configured with the matching [[ViewConfig]](s)
40
40
  *
41
41
  */
@@ -106,8 +106,8 @@ export declare class ViewService {
106
106
  * @internal
107
107
  */
108
108
  static matches: (
109
- ngViewsByFqn: TypedMap<ActiveUIView>,
110
- ngView: ActiveUIView,
109
+ ngViewsByFqn: TypedMap<ActiveNGView>,
110
+ ngView: ActiveNGView,
111
111
  ) => (viewConfig: ViewConfig) => boolean;
112
112
  /**
113
113
  * Normalizes a view's name from a state.views configuration block.
@@ -120,7 +120,7 @@ export declare class ViewService {
120
120
  *
121
121
  * @returns the normalized ngViewName and ngViewContextAnchor that the view targets
122
122
  */
123
- static normalizeUIViewTarget(
123
+ static normalizeNGViewTarget(
124
124
  context: ViewContext,
125
125
  rawViewName?: string,
126
126
  ): {
@@ -128,7 +128,7 @@ export declare class ViewService {
128
128
  ngViewContextAnchor: string;
129
129
  };
130
130
  /** @internal */
131
- constructor(/** @internal */ router: UIRouter);
131
+ constructor(/** @internal */ router: Router);
132
132
  /** @internal */
133
133
  private _rootViewContext;
134
134
  /** @internal */
@@ -154,13 +154,13 @@ export declare class ViewService {
154
154
  * Note: the `ui-view` component uses the `ViewConfig` to determine what view should be loaded inside the `ui-view`,
155
155
  * and what the view's state context is.
156
156
  *
157
- * Note: There is no corresponding `deregisterUIView`.
158
- * A `ui-view` should hang on to the return value of `registerUIView` and invoke it to deregister itself.
157
+ * Note: There is no corresponding `deregisterNGView`.
158
+ * A `ui-view` should hang on to the return value of `registerNGView` and invoke it to deregister itself.
159
159
  *
160
- * @param ngView The metadata for a UIView
160
+ * @param ngView The metadata for a NGView
161
161
  * @return a de-registration function used when the view is destroyed.
162
162
  */
163
- registerUIView(ngView: ActiveUIView): () => void;
163
+ registerNGView(ngView: ActiveNGView): () => void;
164
164
  /**
165
165
  * Returns the list of views currently available on the page, by fully-qualified name.
166
166
  *
@@ -1,15 +1,15 @@
1
1
  /** @publicapi @module directives */ /** */
2
2
  import { IDirective } from "../..";
3
- import { ActiveUIView } from "../core";
3
+ import { ActiveNGView } from "../core";
4
4
  import { Ng1ViewConfig } from "../statebuilders/views";
5
5
 
6
6
  /** @hidden */
7
- export declare type UIViewData = {
7
+ export declare type NGViewData = {
8
8
  $cfg: Ng1ViewConfig;
9
- $ngView: ActiveUIView;
9
+ $ngView: ActiveNGView;
10
10
  };
11
11
  /** @hidden */
12
- export declare type UIViewAnimData = {
12
+ export declare type NGViewAnimData = {
13
13
  $animEnter: Promise<any>;
14
14
  $animLeave: Promise<any>;
15
15
  $$animLeave: {
@@ -372,14 +372,14 @@ export interface Ng1ViewDeclaration extends _ViewDeclaration {
372
372
  /**
373
373
  * The shape of a controller for a view (and/or component), defining the controller callbacks.
374
374
  *
375
- * A view in UI-Router is comprised of either a `component` ([[Ng1ViewDeclaration.component]]) or a combination of a
375
+ * A view in Router is comprised of either a `component` ([[Ng1ViewDeclaration.component]]) or a combination of a
376
376
  * `template` (or `templateProvider`) and a `controller` (or `controllerProvider`).
377
377
  *
378
378
  * The `controller` object (or the `component`'s controller object) can define component-level controller callbacks,
379
- * which UI-Router will call at the appropriate times. These callbacks are similar to Transition Hooks
379
+ * which Router will call at the appropriate times. These callbacks are similar to Transition Hooks
380
380
  * ([[IHookRegistry]]), but are only called if the view is currently active.
381
381
  *
382
- * This interface defines the UI-Router component callbacks.
382
+ * This interface defines the Router component callbacks.
383
383
  *
384
384
  */
385
385
  export interface Ng1Controller {
@@ -468,7 +468,7 @@ export interface TemplateFactoryProvider {
468
468
  /**
469
469
  * Forces $templateFactory to use $http instead of $templateRequest.
470
470
  *
471
- * UI-Router uses `$templateRequest` by default on angular 1.3+.
471
+ * Router uses `$templateRequest` by default on angular 1.3+.
472
472
  * Use this method to choose to use `$http` instead.
473
473
  *
474
474
  * ---
@@ -1,8 +1,8 @@
1
1
  /** @publicapi @module ng1 */ /** */
2
- import { LocationConfig, LocationServices, UIRouter } from "./core";
2
+ import { LocationConfig, LocationServices, Router } from "./core";
3
3
  import { ILocationService, ILocationProvider, IWindowService } from "../index";
4
4
  /**
5
- * Implements UI-Router LocationServices and LocationConfig using Angular 1's $location service
5
+ * Implements Router LocationServices and LocationConfig using Angular 1's $location service
6
6
  * @internalapi
7
7
  */
8
8
  export declare class Ng1LocationServices
@@ -34,7 +34,7 @@ export declare class Ng1LocationServices
34
34
  *
35
35
  * @param router
36
36
  */
37
- static monkeyPatchPathParameterType(router: UIRouter): void;
37
+ static monkeyPatchPathParameterType(router: Router): void;
38
38
  constructor($locationProvider: ILocationProvider);
39
39
  onChange(callback: Function): () => Function[];
40
40
  html5Mode(): any;
@@ -2,7 +2,7 @@ import { IRootScopeService } from "../";
2
2
  import { ResolveContext, TypedMap } from "./core";
3
3
  import { StateProvider } from "./stateProvider";
4
4
  declare module "./core/lib/router" {
5
- interface UIRouter {
5
+ interface Router {
6
6
  /** @hidden */
7
7
  stateProvider: StateProvider;
8
8
  }
@@ -12,9 +12,9 @@ import { Ng1StateDeclaration } from "./interface";
12
12
  * The `$stateProvider` works similar to Angular's v1 router, but it focuses purely
13
13
  * on state.
14
14
  *
15
- * A state corresponds to a "place" in the application in terms of the overall UI and
15
+ * A state corresponds to a "place" in the application in terms of the overall NG and
16
16
  * navigation. A state describes (via the controller / template / view properties) what
17
- * the UI looks like and does at that place.
17
+ * the NG looks like and does at that place.
18
18
  *
19
19
  * States often have things in common, and the primary way of factoring out these
20
20
  * commonalities in this model is via the state hierarchy, i.e. parent/child states aka
@@ -1,4 +1,4 @@
1
- export interface UIViewScrollProvider {
1
+ export interface NGViewScrollProvider {
2
2
  /**
3
3
  * Uses standard anchorScroll behavior
4
4
  *
@@ -1,77 +0,0 @@
1
- import { forEach, isDefined, isFunction, isObject } from "../../shared/utils";
2
- import { UrlMatcher } from "./url-matcher";
3
- import { ParamFactory } from "../params/param-factory";
4
-
5
- /**
6
- * Factory for [[UrlMatcher]] instances.
7
- *
8
- * The factory is available to ng1 services as
9
- * `$urlMatcherFactory` or ng1 providers as `$urlMatcherFactoryProvider`.
10
- */
11
- export class UrlMatcherFactory {
12
- // TODO: move implementations to UrlConfig (urlService.config)
13
- constructor(urlServiceConfig) {
14
- this.urlServiceConfig = urlServiceConfig;
15
- /** Creates a new [[Param]] for a given location (DefType) */
16
- this.paramFactory = new ParamFactory(urlServiceConfig);
17
- /** @deprecated use [[UrlConfig.caseInsensitive]] */
18
- this.caseInsensitive = (value) => urlServiceConfig.caseInsensitive(value);
19
- /** @deprecated use [[UrlConfig.defaultSquashPolicy]] */
20
- this.defaultSquashPolicy = (value) =>
21
- urlServiceConfig.defaultSquashPolicy(value);
22
- /** @deprecated use [[UrlConfig.strictMode]] */
23
- this.strictMode = (value) => urlServiceConfig.strictMode(value);
24
- /** @deprecated use [[UrlConfig.type]] */
25
- this.type = (name, definition, definitionFn) => {
26
- return urlServiceConfig.type(name, definition, definitionFn) || this;
27
- };
28
- }
29
- /**
30
- * Creates a [[UrlMatcher]] for the specified pattern.
31
- *
32
- * @param pattern The URL pattern.
33
- * @param config The config object hash.
34
- * @returns The UrlMatcher.
35
- */
36
- compile(pattern, config) {
37
- const urlConfig = this.urlServiceConfig;
38
- // backward-compatible support for config.params -> config.state.params
39
- const params = config && !config.state && config.params;
40
- config = params ? Object.assign({ state: { params } }, config) : config;
41
- const globalConfig = {
42
- strict: urlConfig._isStrictMode,
43
- caseInsensitive: urlConfig._isCaseInsensitive,
44
- decodeParams: urlConfig._decodeParams,
45
- };
46
- return new UrlMatcher(
47
- pattern,
48
- urlConfig.paramTypes,
49
- this.paramFactory,
50
- Object.assign(globalConfig, config),
51
- );
52
- }
53
- /**
54
- * Returns true if the specified object is a [[UrlMatcher]], or false otherwise.
55
- *
56
- * @param object The object to perform the type check against.
57
- * @returns `true` if the object matches the `UrlMatcher` interface, by
58
- * implementing all the same methods.
59
- */
60
- isMatcher(object) {
61
- // TODO: typeof?
62
- if (!isObject(object)) return false;
63
- let result = true;
64
- forEach(UrlMatcher.prototype, (val, name) => {
65
- if (isFunction(val))
66
- result = result && isDefined(object[name]) && isFunction(object[name]);
67
- });
68
- return result;
69
- }
70
-
71
- $get() {
72
- const urlConfig = this.urlServiceConfig;
73
- urlConfig.paramTypes.enqueue = false;
74
- urlConfig.paramTypes._flushTypeQueue();
75
- return this;
76
- }
77
- }
@@ -1,101 +0,0 @@
1
- import { EventBus } from "../../core/pubsub";
2
- import { stripLastPathElement } from "../../shared/strings";
3
-
4
- function appendBasePath(url, isHtml5, absolute, baseHref) {
5
- if (baseHref === "/") return url;
6
- if (isHtml5) return stripLastPathElement(baseHref) + url;
7
- if (absolute) return baseHref.slice(1) + url;
8
- return url;
9
- }
10
- /**
11
- * Updates URL and responds to URL changes
12
- *
13
- * ### Deprecation warning:
14
- * This class is now considered to be an internal API
15
- * Use the [[UrlService]] instead.
16
- * For configuring URL rules, use the [[UrlRules]] which can be found as [[UrlService.rules]].
17
- */
18
- export class UrlRouter {
19
- /**
20
- * @param {angular.UrlService} urlService
21
- */
22
- constructor(urlService, urlRuleFactory, $locationProvider) {
23
- this.urlService = urlService;
24
- this.urlRuleFactory = urlRuleFactory;
25
- this.$locationProvider = $locationProvider;
26
- EventBus.subscribe("$urlRouter:update", () => {
27
- this.update();
28
- });
29
- }
30
-
31
- update(read) {
32
- const $url = this.urlService;
33
- if (read) {
34
- this.location = $url.url();
35
- return;
36
- }
37
- if ($url.url() === this.location) return;
38
- $url.url(this.location, true);
39
- }
40
- /**
41
- * Pushes a new location to the browser history.
42
- *
43
- * @internal
44
- * @param urlMatcher
45
- * @param params
46
- * @param options
47
- */
48
- push(urlMatcher, params, options) {
49
- const replace = options && !!options.replace;
50
- this.urlService.url(urlMatcher.format(params || {}), replace);
51
- }
52
- /**
53
- * Builds and returns a URL with interpolated parameters
54
- *
55
- * #### Example:
56
- * ```js
57
- * matcher = $umf.compile("/about/:person");
58
- * params = { person: "bob" };
59
- * $bob = $urlRouter.href(matcher, params);
60
- * // $bob == "/about/bob";
61
- * ```
62
- *
63
- * @param urlMatcher The [[UrlMatcher]] object which is used as the template of the URL to generate.
64
- * @param params An object of parameter values to fill the matcher's required parameters.
65
- * @param options Options object. The options are:
66
- *
67
- * - **`absolute`** - {boolean=false}, If true will generate an absolute url, e.g. "http://www.example.com/fullurl".
68
- *
69
- * @returns Returns the fully compiled URL, or `null` if `params` fail validation against `urlMatcher`
70
- */
71
- href(urlMatcher, params, options) {
72
- let url = urlMatcher.format(params);
73
- if (url == null) return null;
74
- options = options || { absolute: false };
75
- const cfg = this.urlService.config;
76
- const isHtml5 = this.urlService.html5Mode();
77
- if (!isHtml5 && url !== null) {
78
- url = "#" + this.$locationProvider.hashPrefix() + url;
79
- }
80
- url = appendBasePath(
81
- url,
82
- isHtml5,
83
- options.absolute,
84
- this.urlService.baseHref(),
85
- );
86
- if (!options.absolute || !url) {
87
- return url;
88
- }
89
- const slash = !isHtml5 && url ? "/" : "";
90
- const cfgPort = this.urlService.$location.port();
91
- const port = cfgPort === 80 || cfgPort === 443 ? "" : ":" + cfgPort;
92
- return [
93
- cfg.protocol(),
94
- "://",
95
- this.urlService.$location.host(),
96
- port,
97
- slash,
98
- url,
99
- ].join("");
100
- }
101
- }