@angular-wave/angular.ts 0.1.3 → 0.1.4
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.
- package/dist/angular-ts.esm.js +2 -2
- package/dist/angular-ts.umd.js +2 -2
- package/package.json +1 -1
- package/src/angular.spec.js +0 -1
- package/src/animations/animate-css.html +1 -7
- package/src/animations/animate-css.js +4 -9
- package/src/core/compile/compile.js +1 -1
- package/src/core/location/location.js +3 -5
- package/src/core/task-tracker-factory.js +94 -78
- package/src/router/common/coreservices.js +1 -2
- package/src/router/resolve/resolve-context.js +3 -5
- package/src/router/state/state-service.js +1 -0
- package/src/services/anchor-scroll.js +9 -7
- package/src/services/browser.js +146 -194
- package/src/services/http/http.spec.js +1 -0
- package/src/services/http-backend/http-backend.js +3 -4
- package/src/shared/hof.js +0 -14
- package/types/core/task-tracker-factory.d.ts +44 -33
- package/types/loader.d.ts +1 -1
- package/types/router/url/url-service.d.ts +2 -2
- package/types/services/browser.d.ts +41 -103
- package/types/services/http-backend/http-backend.d.ts +1 -2
- package/types/shared/predicates.d.ts +1 -1
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@angular-wave/angular.ts",
|
|
3
3
|
"description": "A modern, optimized and typesafe version of AngularJS",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "0.1.
|
|
5
|
+
"version": "0.1.4",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/angular-ts.esm.js",
|
|
8
8
|
"browser": "dist/angular-ts.umd.js",
|
package/src/angular.spec.js
CHANGED
|
@@ -49,13 +49,7 @@
|
|
|
49
49
|
</style>
|
|
50
50
|
</head>
|
|
51
51
|
<body ng-app="test">
|
|
52
|
-
<div
|
|
53
|
-
Fade me in out
|
|
54
|
-
</div>
|
|
55
|
-
<div ng-if="bool" id="animate" class="fade" animate="true">
|
|
56
|
-
Fade me in out
|
|
57
|
-
</div>
|
|
58
|
-
<div ng-if="bool" id="no-animate" class="fade">Fade me in out</div>
|
|
52
|
+
<div class="{{bool}}">{{bool}}</div>
|
|
59
53
|
<button ng-click="bool=true">Fade In!</button>
|
|
60
54
|
<button ng-click="bool=false">Fade Out!</button>
|
|
61
55
|
</body>
|
|
@@ -392,7 +392,7 @@ export function $AnimateCssProvider() {
|
|
|
392
392
|
|
|
393
393
|
if (!options.$$skipPreparationClasses) {
|
|
394
394
|
element[0].classList.add(
|
|
395
|
-
preparationClasses.split(" ").filter((x) => x !== ""),
|
|
395
|
+
...preparationClasses.split(" ").filter((x) => x !== ""),
|
|
396
396
|
);
|
|
397
397
|
}
|
|
398
398
|
|
|
@@ -589,15 +589,11 @@ export function $AnimateCssProvider() {
|
|
|
589
589
|
animationPaused = false;
|
|
590
590
|
|
|
591
591
|
if (preparationClasses && !options.$$skipPreparationClasses) {
|
|
592
|
-
preparationClasses.split(" ")
|
|
593
|
-
element[0].classList.remove(cls);
|
|
594
|
-
});
|
|
592
|
+
element[0].classList.remove(...preparationClasses.split(" "));
|
|
595
593
|
}
|
|
596
594
|
activeClasses = pendClasses(preparationClasses, ACTIVE_CLASS_SUFFIX);
|
|
597
595
|
if (activeClasses) {
|
|
598
|
-
activeClasses.split(" ")
|
|
599
|
-
element[0].classList.remove(cls);
|
|
600
|
-
});
|
|
596
|
+
element[0].classList.remove(...activeClasses.split(" "));
|
|
601
597
|
}
|
|
602
598
|
|
|
603
599
|
blockKeyframeAnimations(node, false);
|
|
@@ -786,9 +782,8 @@ export function $AnimateCssProvider() {
|
|
|
786
782
|
});
|
|
787
783
|
|
|
788
784
|
applyAnimationClasses(element, options);
|
|
789
|
-
|
|
790
785
|
element[0].classList.add(
|
|
791
|
-
activeClasses.split(" ").filter((x) => x !== ""),
|
|
786
|
+
...activeClasses.split(" ").filter((x) => x !== ""),
|
|
792
787
|
);
|
|
793
788
|
if (flags.recalculateTimingStyles) {
|
|
794
789
|
cacheKey = $$animateCache.cacheKey(
|
|
@@ -2352,7 +2352,7 @@ export function $CompileProvider($provide, $$sanitizeUriProvider) {
|
|
|
2352
2352
|
// Copy in CSS classes from original node
|
|
2353
2353
|
try {
|
|
2354
2354
|
if (oldClasses !== "") {
|
|
2355
|
-
linkNode.classList.add(oldClasses);
|
|
2355
|
+
linkNode.classList.add(...oldClasses.trim().split(" "));
|
|
2356
2356
|
}
|
|
2357
2357
|
} catch (e) {
|
|
2358
2358
|
// ignore, since it means that we are trying to set class on
|
|
@@ -649,11 +649,11 @@ export function $LocationProvider() {
|
|
|
649
649
|
|
|
650
650
|
const IGNORE_URI_REGEXP = /^\s*(javascript|mailto):/i;
|
|
651
651
|
|
|
652
|
-
function setBrowserUrlWithFallback(url,
|
|
652
|
+
function setBrowserUrlWithFallback(url, state) {
|
|
653
653
|
const oldUrl = $location.url();
|
|
654
654
|
const oldState = $location.$$state;
|
|
655
655
|
try {
|
|
656
|
-
$browser.url(url,
|
|
656
|
+
$browser.url(url, state);
|
|
657
657
|
|
|
658
658
|
// Make sure $location.state() returns referentially identical (not just deeply equal)
|
|
659
659
|
// state object; this makes possible quick checking if the state changed in the digest
|
|
@@ -762,7 +762,7 @@ export function $LocationProvider() {
|
|
|
762
762
|
if (defaultPrevented) {
|
|
763
763
|
$location.$$parse(oldUrl);
|
|
764
764
|
$location.$$state = oldState;
|
|
765
|
-
setBrowserUrlWithFallback(oldUrl,
|
|
765
|
+
setBrowserUrlWithFallback(oldUrl, oldState);
|
|
766
766
|
} else {
|
|
767
767
|
initializing = false;
|
|
768
768
|
afterLocationChange(oldUrl, oldState);
|
|
@@ -779,7 +779,6 @@ export function $LocationProvider() {
|
|
|
779
779
|
const oldUrl = /** @type {string} */ ($browser.url());
|
|
780
780
|
const newUrl = $location.absUrl();
|
|
781
781
|
const oldState = $browser.state();
|
|
782
|
-
const currentReplace = $location.$$replace;
|
|
783
782
|
const urlOrStateChanged =
|
|
784
783
|
!urlsEqual(oldUrl, newUrl) ||
|
|
785
784
|
($location.$$html5 && oldState !== $location.$$state);
|
|
@@ -808,7 +807,6 @@ export function $LocationProvider() {
|
|
|
808
807
|
if (urlOrStateChanged) {
|
|
809
808
|
setBrowserUrlWithFallback(
|
|
810
809
|
newUrl,
|
|
811
|
-
currentReplace,
|
|
812
810
|
oldState === $location.$$state ? null : $location.$$state,
|
|
813
811
|
);
|
|
814
812
|
}
|
|
@@ -1,122 +1,138 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
1
|
+
export class $$TaskTrackerFactoryProvider {
|
|
2
|
+
$get = [
|
|
3
3
|
"$log",
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Creates a new `TaskTracker` instance.
|
|
6
|
+
*
|
|
7
|
+
* @param {import('../services/log').LogService} log - The logging service.
|
|
8
|
+
* @returns {TaskTracker} A new `TaskTracker` instance.
|
|
9
|
+
*/
|
|
5
10
|
(log) => new TaskTracker(log),
|
|
6
11
|
];
|
|
7
12
|
}
|
|
8
13
|
|
|
9
14
|
/**
|
|
10
|
-
*
|
|
15
|
+
* A factory function to create `TaskTracker` instances.
|
|
11
16
|
*
|
|
12
|
-
*
|
|
13
|
-
* @description
|
|
14
|
-
* A function to create `TaskTracker` instances.
|
|
15
|
-
*
|
|
16
|
-
* A `TaskTracker` can keep track of pending tasks (grouped by type) and can notify interested
|
|
17
|
+
* A `TaskTracker` tracks pending tasks (grouped by type) and notifies interested
|
|
17
18
|
* parties when all pending tasks (or tasks of a specific type) have been completed.
|
|
18
|
-
* @param {import('../services/log').LogService} log
|
|
19
19
|
*/
|
|
20
|
-
export
|
|
21
|
-
const self = this;
|
|
22
|
-
const taskCounts = {};
|
|
23
|
-
const taskCallbacks = [];
|
|
24
|
-
|
|
25
|
-
const ALL_TASKS_TYPE = (self.ALL_TASKS_TYPE = "$$all$$");
|
|
26
|
-
const DEFAULT_TASK_TYPE = (self.DEFAULT_TASK_TYPE = "$$default$$");
|
|
27
|
-
|
|
20
|
+
export class TaskTracker {
|
|
28
21
|
/**
|
|
29
|
-
*
|
|
30
|
-
* If the counter reaches 0, all corresponding `taskCallbacks` are executed.
|
|
31
|
-
*
|
|
32
|
-
* @param {Function} fn - The function to execute.
|
|
33
|
-
* @param {string=} [taskType=DEFAULT_TASK_TYPE] - The type of task that is being completed.
|
|
22
|
+
* @param {import('../services/log').LogService} log - The logging service.
|
|
34
23
|
*/
|
|
35
|
-
|
|
24
|
+
constructor(log) {
|
|
25
|
+
/** @private */
|
|
26
|
+
this.log = log;
|
|
36
27
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
28
|
+
/** @private */
|
|
29
|
+
this.taskCounts = {};
|
|
30
|
+
|
|
31
|
+
/** @private */
|
|
32
|
+
this.taskCallbacks = [];
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Special task types used for tracking all tasks and default tasks.
|
|
36
|
+
* @type {string}
|
|
37
|
+
*/
|
|
38
|
+
this.ALL_TASKS_TYPE = "$$all$$";
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Default task type.
|
|
42
|
+
* @type {string}
|
|
43
|
+
*/
|
|
44
|
+
this.DEFAULT_TASK_TYPE = "$$default$$";
|
|
45
|
+
}
|
|
44
46
|
|
|
45
47
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* If there are no pending tasks, the callback is executed immediately. You can optionally limit
|
|
49
|
-
* the tasks that will be waited for to a specific type, by passing a `taskType`.
|
|
48
|
+
* Completes a task and decrements the associated task counter.
|
|
49
|
+
* If the counter reaches 0, all corresponding callbacks are executed.
|
|
50
50
|
*
|
|
51
|
-
* @param {
|
|
52
|
-
* @param {string
|
|
51
|
+
* @param {Function} fn - The function to execute when completing the task.
|
|
52
|
+
* @param {string} [taskType=this.DEFAULT_TASK_TYPE] - The type of task being completed.
|
|
53
53
|
*/
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
function completeTask(fn, taskType) {
|
|
57
|
-
taskType = taskType || DEFAULT_TASK_TYPE;
|
|
58
|
-
|
|
54
|
+
completeTask(fn, taskType = this.DEFAULT_TASK_TYPE) {
|
|
59
55
|
try {
|
|
60
56
|
fn();
|
|
61
57
|
} finally {
|
|
62
|
-
|
|
58
|
+
if (this.taskCounts[taskType]) {
|
|
59
|
+
this.taskCounts[taskType]--;
|
|
60
|
+
this.taskCounts[this.ALL_TASKS_TYPE]--;
|
|
61
|
+
}
|
|
63
62
|
|
|
64
|
-
const countForType = taskCounts[taskType];
|
|
65
|
-
const countForAll = taskCounts[ALL_TASKS_TYPE];
|
|
63
|
+
const countForType = this.taskCounts[taskType];
|
|
64
|
+
const countForAll = this.taskCounts[this.ALL_TASKS_TYPE];
|
|
66
65
|
|
|
67
|
-
// If
|
|
66
|
+
// If either the overall task queue or the specific task type queue is empty, run callbacks.
|
|
68
67
|
if (!countForAll || !countForType) {
|
|
69
68
|
const getNextCallback = !countForAll
|
|
70
|
-
? getLastCallback
|
|
71
|
-
: getLastCallbackForType;
|
|
72
|
-
let nextCb;
|
|
69
|
+
? this.getLastCallback.bind(this)
|
|
70
|
+
: () => this.getLastCallbackForType(taskType);
|
|
73
71
|
|
|
74
|
-
|
|
72
|
+
let nextCb;
|
|
73
|
+
while ((nextCb = getNextCallback())) {
|
|
75
74
|
try {
|
|
76
75
|
nextCb();
|
|
77
76
|
} catch (e) {
|
|
78
|
-
log.error(e);
|
|
77
|
+
this.log.error(e);
|
|
79
78
|
}
|
|
80
79
|
}
|
|
81
80
|
}
|
|
82
81
|
}
|
|
83
82
|
}
|
|
84
83
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
84
|
+
/**
|
|
85
|
+
* Increments the task count for the specified task type.
|
|
86
|
+
*
|
|
87
|
+
* @param {string} [taskType=this.DEFAULT_TASK_TYPE] - The type of task whose count will be increased.
|
|
88
|
+
*/
|
|
89
|
+
incTaskCount(taskType = this.DEFAULT_TASK_TYPE) {
|
|
90
|
+
this.taskCounts[taskType] = (this.taskCounts[taskType] || 0) + 1;
|
|
91
|
+
this.taskCounts[this.ALL_TASKS_TYPE] =
|
|
92
|
+
(this.taskCounts[this.ALL_TASKS_TYPE] || 0) + 1;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Registers a callback to be executed when all pending tasks of the specified type are completed.
|
|
97
|
+
* If there are no pending tasks of the specified type, the callback is executed immediately.
|
|
98
|
+
*
|
|
99
|
+
* @param {Function} callback - The function to execute when no pending tasks remain.
|
|
100
|
+
* @param {string} [taskType=this.ALL_TASKS_TYPE] - The type of tasks to wait for completion.
|
|
101
|
+
*/
|
|
102
|
+
notifyWhenNoPendingTasks(callback, taskType = this.ALL_TASKS_TYPE) {
|
|
103
|
+
if (!this.taskCounts[taskType]) {
|
|
104
|
+
callback();
|
|
105
|
+
} else {
|
|
106
|
+
this.taskCallbacks.push({ type: taskType, cb: callback });
|
|
90
107
|
}
|
|
91
108
|
}
|
|
92
109
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
110
|
+
/**
|
|
111
|
+
* Retrieves and removes the last registered callback from the queue.
|
|
112
|
+
*
|
|
113
|
+
* @private
|
|
114
|
+
* @returns {Function|undefined} The last callback function or undefined if none exist.
|
|
115
|
+
*/
|
|
116
|
+
getLastCallback() {
|
|
117
|
+
const cbInfo = this.taskCallbacks.pop();
|
|
118
|
+
return cbInfo ? cbInfo.cb : undefined;
|
|
96
119
|
}
|
|
97
120
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
121
|
+
/**
|
|
122
|
+
* Retrieves and removes the last registered callback for the specified task type.
|
|
123
|
+
*
|
|
124
|
+
* @private
|
|
125
|
+
* @param {string} taskType - The type of task for which the callback was registered.
|
|
126
|
+
* @returns {Function|undefined} The last callback function for the task type, or undefined if none exist.
|
|
127
|
+
*/
|
|
128
|
+
getLastCallbackForType(taskType) {
|
|
129
|
+
for (let i = this.taskCallbacks.length - 1; i >= 0; --i) {
|
|
130
|
+
const cbInfo = this.taskCallbacks[i];
|
|
101
131
|
if (cbInfo.type === taskType) {
|
|
102
|
-
taskCallbacks.splice(i, 1);
|
|
132
|
+
this.taskCallbacks.splice(i, 1);
|
|
103
133
|
return cbInfo.cb;
|
|
104
134
|
}
|
|
105
135
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
function incTaskCount(taskType) {
|
|
109
|
-
taskType = taskType || DEFAULT_TASK_TYPE;
|
|
110
|
-
taskCounts[taskType] = (taskCounts[taskType] || 0) + 1;
|
|
111
|
-
taskCounts[ALL_TASKS_TYPE] = (taskCounts[ALL_TASKS_TYPE] || 0) + 1;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function notifyWhenNoPendingTasks(callback, taskType) {
|
|
115
|
-
taskType = taskType || ALL_TASKS_TYPE;
|
|
116
|
-
if (!taskCounts[taskType]) {
|
|
117
|
-
callback();
|
|
118
|
-
} else {
|
|
119
|
-
taskCallbacks.push({ type: taskType, cb: callback });
|
|
120
|
-
}
|
|
136
|
+
return undefined;
|
|
121
137
|
}
|
|
122
138
|
}
|
|
@@ -7,7 +7,7 @@ import { PathUtils } from "../path/path-utils";
|
|
|
7
7
|
import { stringify } from "../../shared/strings";
|
|
8
8
|
import { isUndefined } from "../../shared/utils";
|
|
9
9
|
|
|
10
|
-
export
|
|
10
|
+
export const resolvePolicies = {
|
|
11
11
|
when: {
|
|
12
12
|
LAZY: "LAZY",
|
|
13
13
|
EAGER: "EAGER",
|
|
@@ -18,10 +18,8 @@ export let resolvePolicies = {
|
|
|
18
18
|
},
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const EAGER_WHENS = [whens.EAGER];
|
|
24
|
-
export const NATIVE_INJECTOR_TOKEN = "Native Injector";
|
|
21
|
+
const ALL_WHENS = [resolvePolicies.when.EAGER, resolvePolicies.when.LAZY];
|
|
22
|
+
const EAGER_WHENS = [resolvePolicies.when.EAGER];
|
|
25
23
|
/**
|
|
26
24
|
* Encapsulates Dependency Injection for a path of nodes
|
|
27
25
|
*
|
|
@@ -667,6 +667,7 @@ export class StateService {
|
|
|
667
667
|
defaultErrorHandler(handler) {
|
|
668
668
|
return (this._defaultErrorHandler = handler || this._defaultErrorHandler);
|
|
669
669
|
}
|
|
670
|
+
|
|
670
671
|
get(stateOrName, base) {
|
|
671
672
|
const reg = this.stateRegistry;
|
|
672
673
|
if (arguments.length === 0) return reg.get();
|
|
@@ -19,14 +19,16 @@ import {
|
|
|
19
19
|
* @typedef {AnchorScrollFunction | AnchorScrollObject} AnchorScrollService
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
export
|
|
23
|
-
|
|
22
|
+
export class AnchorScrollProvider {
|
|
23
|
+
constructor() {
|
|
24
|
+
this.autoScrollingEnabled = true;
|
|
25
|
+
}
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
autoScrollingEnabled = false;
|
|
27
|
-
}
|
|
27
|
+
disableAutoScrolling() {
|
|
28
|
+
this.autoScrollingEnabled = false;
|
|
29
|
+
}
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
$get = [
|
|
30
32
|
"$location",
|
|
31
33
|
"$rootScope",
|
|
32
34
|
/**
|
|
@@ -124,7 +126,7 @@ export function AnchorScrollProvider() {
|
|
|
124
126
|
|
|
125
127
|
// does not scroll when user clicks on anchor link that is currently on
|
|
126
128
|
// (no url change, no $location.hash() change), browser native does scroll
|
|
127
|
-
if (autoScrollingEnabled) {
|
|
129
|
+
if (this.autoScrollingEnabled) {
|
|
128
130
|
$rootScope.$watch(
|
|
129
131
|
() => $location.hash(),
|
|
130
132
|
(newVal, oldVal) => {
|