@angular-wave/angular.ts 0.0.30 → 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.
@@ -21,7 +21,7 @@ describe("view", () => {
21
21
  $injector,
22
22
  elem,
23
23
  $controllerProvider,
24
- $urlMatcherFactoryProvider,
24
+ $urlServiceProvider,
25
25
  $view,
26
26
  $q;
27
27
  let root, states;
@@ -34,16 +34,12 @@ describe("view", () => {
34
34
  window.angular
35
35
  .module("defaultModule", ["ng.router"])
36
36
  .config(
37
- function (
38
- _$provide_,
39
- _$controllerProvider_,
40
- _$urlMatcherFactoryProvider_,
41
- ) {
37
+ function (_$provide_, _$controllerProvider_, _$urlServiceProvider_) {
42
38
  _$provide_.factory("foo", () => {
43
39
  return "Foo";
44
40
  });
45
41
  $controllerProvider = _$controllerProvider_;
46
- $urlMatcherFactoryProvider = _$urlMatcherFactoryProvider_;
42
+ $urlServiceProvider = _$urlServiceProvider_;
47
43
  },
48
44
  );
49
45
  $injector = window.angular.bootstrap(document.getElementById("dummy"), [
@@ -58,10 +54,7 @@ describe("view", () => {
58
54
 
59
55
  states = {};
60
56
  const matcher = new StateMatcher(states);
61
- const stateBuilder = new StateBuilder(
62
- matcher,
63
- $urlMatcherFactoryProvider,
64
- );
57
+ const stateBuilder = new StateBuilder(matcher, $urlServiceProvider);
65
58
  stateBuilder.builder("views", ng1ViewsBuilder);
66
59
  register = registerState(states, stateBuilder);
67
60
  root = register({ name: "" });
@@ -395,7 +395,7 @@ export interface Replace {
395
395
  * @example
396
396
  * ```
397
397
  *
398
- * $urlMatcherFactoryProvider.type('intarray', {
398
+ * $urlServiceProvider.type('intarray', {
399
399
  * // Take an array of ints [1,2,3] and return a string "1-2-3"
400
400
  * encode: (array) => array.join("-"),
401
401
  *
@@ -432,7 +432,7 @@ export interface Replace {
432
432
  *
433
433
  * var list = ['John', 'Paul', 'George', 'Ringo'];
434
434
  *
435
- * $urlMatcherFactoryProvider.type('listItem', {
435
+ * $urlServiceProvider.type('listItem', {
436
436
  * encode: function(item) {
437
437
  * // Represent the list item in the URL using its corresponding index
438
438
  * return list.indexOf(item);
@@ -14,7 +14,7 @@ export declare class ParamFactory {
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;
@@ -1,76 +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
- };
45
- return new UrlMatcher(
46
- pattern,
47
- urlConfig.paramTypes,
48
- this.paramFactory,
49
- Object.assign(globalConfig, config),
50
- );
51
- }
52
- /**
53
- * Returns true if the specified object is a [[UrlMatcher]], or false otherwise.
54
- *
55
- * @param object The object to perform the type check against.
56
- * @returns `true` if the object matches the `UrlMatcher` interface, by
57
- * implementing all the same methods.
58
- */
59
- isMatcher(object) {
60
- // TODO: typeof?
61
- if (!isObject(object)) return false;
62
- let result = true;
63
- forEach(UrlMatcher.prototype, (val, name) => {
64
- if (isFunction(val))
65
- result = result && isDefined(object[name]) && isFunction(object[name]);
66
- });
67
- return result;
68
- }
69
-
70
- $get() {
71
- const urlConfig = this.urlServiceConfig;
72
- urlConfig.paramTypes.enqueue = false;
73
- urlConfig.paramTypes._flushTypeQueue();
74
- return this;
75
- }
76
- }
@@ -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
- }