@angular-wave/angular.ts 0.0.26 → 0.0.27

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.
@@ -1,67 +0,0 @@
1
- import { isDefined, isObject } from "../shared/utils";
2
- import { val } from "../shared/hof";
3
- import { createProxyFunctions, removeFrom } from "../shared/common";
4
-
5
- /**
6
- * Implements UI-Router LocationServices and LocationConfig using Angular 1's $location service
7
- * @internalapi
8
- */
9
- export class Ng1LocationServices {
10
- /**
11
- *
12
- * @param {angular.ILocationProvider} $locationProvider
13
- */
14
- constructor($locationProvider) {
15
- // .onChange() registry
16
- this._urlListeners = [];
17
- /** @type {angular.ILocationProvider} */
18
- this.$locationProvider = $locationProvider;
19
- const _lp = val($locationProvider);
20
- createProxyFunctions(_lp, this, _lp, ["hashPrefix"]);
21
- }
22
-
23
- dispose() {}
24
-
25
- onChange(callback) {
26
- this._urlListeners.push(callback);
27
- return () => removeFrom(this._urlListeners)(callback);
28
- }
29
- html5Mode() {
30
- let html5Mode = this.$locationProvider.html5Mode();
31
- html5Mode = isObject(html5Mode) ? html5Mode.enabled : html5Mode;
32
- return html5Mode && typeof history !== "undefined";
33
- }
34
- baseHref() {
35
- return (
36
- this._baseHref ||
37
- (this._baseHref =
38
- this.$browser.baseHref() || this.$window.location.pathname)
39
- );
40
- }
41
- url(newUrl, replace = false, state) {
42
- if (isDefined(newUrl)) this.$location.url(newUrl);
43
- if (replace) this.$location.replace();
44
- if (state) this.$location.state(state);
45
- return this.$location.url();
46
- }
47
-
48
- _runtimeServices($rootScope, $location, $browser) {
49
- /** @type {angular.ILocationService} */ this.$location = $location;
50
- this.$browser = $browser;
51
- this.$window = window;
52
- // Bind $locationChangeSuccess to the listeners registered in LocationService.onChange
53
- $rootScope.$on("$locationChangeSuccess", (evt) =>
54
- this._urlListeners.forEach((fn) => fn(evt)),
55
- );
56
- const _loc = val($location);
57
- // Bind these LocationService functions to $location
58
- createProxyFunctions(_loc, this, _loc, [
59
- "replace",
60
- "path",
61
- "search",
62
- "hash",
63
- ]);
64
- // Bind these LocationConfig functions to $location
65
- createProxyFunctions(_loc, this, _loc, ["port", "protocol", "host"]);
66
- }
67
- }