@angular-wave/angular.ts 0.0.71 → 0.0.73
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/animations/animate-children-directive.md +1 -1
- package/src/animations/animate-css-driver.js +1 -1
- package/src/animations/animate-css.html +2 -2
- package/src/animations/animate-js.html +5 -2
- package/src/animations/animate-queue.js +5 -5
- package/src/animations/animate-swap.md +1 -1
- package/src/{core/animate → animations}/animate.html +1 -1
- package/src/{core/animate → animations}/animate.js +4 -138
- package/src/animations/raf-scheduler.js +7 -3
- package/src/animations/raf-scheduler.spec.js +3 -3
- package/src/animations/shared.js +2 -2
- package/src/binding.spec.js +4 -3
- package/src/core/compile/attributes.js +8 -1
- package/src/core/compile/compile.spec.js +44 -28
- package/src/core/controller/controller.js +9 -3
- package/src/core/di/injector.md +1 -1
- package/src/core/di/ng-module.js +46 -3
- package/src/core/prop.spec.js +15 -11
- package/src/core/q/q.js +2 -1
- package/src/directive/bind/bind.spec.js +80 -44
- package/src/directive/change/change.js +3 -1
- package/src/directive/class/class.js +43 -14
- package/src/directive/class/class.spec.js +7 -4
- package/src/directive/form/form.js +5 -4
- package/src/directive/form/form.spec.js +3 -4
- package/src/directive/if/if-animate-css.html +5 -7
- package/src/directive/if/if.js +1 -1
- package/src/directive/if/if.spec.js +3 -2
- package/src/directive/include/include.js +1 -1
- package/src/directive/input/input.spec.js +6 -4
- package/src/directive/list/list.js +3 -3
- package/src/directive/list/list.spec.js +4 -2
- package/src/directive/messages/messages.js +177 -172
- package/src/directive/messages/messages.spec.js +4 -4
- package/src/directive/model/model.js +261 -471
- package/src/directive/model/model.spec.js +4 -3
- package/src/directive/model-options/model-options.spec.js +3 -1
- package/src/directive/repeat/repeat.md +1 -1
- package/src/directive/repeat/repeat.spec.js +1 -1
- package/src/directive/select/select.spec.js +3 -3
- package/src/directive/show-hide/show-hide.js +36 -6
- package/src/directive/switch/switch.js +4 -4
- package/src/directive/switch/switch.spec.js +5 -2
- package/src/directive/validators/validators.spec.js +6 -4
- package/src/loader.js +1 -2
- package/src/public.js +22 -10
- package/src/router/directives/state-directives.js +2 -9
- package/src/router/hooks/core-resolvables.js +5 -3
- package/src/router/path/path-utils.js +1 -2
- package/src/router/resolve/resolve-context.js +14 -29
- package/src/router/state/state-queue-manager.js +1 -2
- package/src/router/state/state-service.js +2 -3
- package/src/router/transition/transition.js +2 -2
- package/src/router/view/view.js +2 -8
- package/src/services/anchor-scroll.html +1 -1
- package/src/shared/common.js +3 -8
- package/src/shared/common.spec.js +1 -19
- package/src/shared/hof.js +1 -8
- package/src/shared/jqlite/jqlite.js +2 -2
- package/src/shared/predicates.js +3 -2
- package/src/types.js +2 -3
- package/types/animations/animate-css-driver.d.ts +1 -1
- package/types/animations/animate-queue.d.ts +1 -2
- package/types/{core/animate → animations}/animate.d.ts +2 -12
- package/types/animations/raf-scheduler.d.ts +7 -2
- package/types/core/compile/attributes.d.ts +10 -1
- package/types/core/di/ng-module.d.ts +55 -12
- package/types/core/q/q.d.ts +4 -2
- package/types/directive/form/form.d.ts +3 -1
- package/types/directive/messages/messages.d.ts +76 -0
- package/types/directive/model/model.d.ts +101 -239
- package/types/router/resolve/resolve-context.d.ts +0 -2
- package/types/router/transition/transition.d.ts +0 -1
- package/types/shared/common.d.ts +0 -3
- package/types/shared/hof.d.ts +0 -1
- package/types/shared/jqlite/jqlite.d.ts +4 -4
- package/types/types.d.ts +4 -2
- package/src/animations/module.js +0 -25
- package/src/core/animate/animate-css.js +0 -88
- package/src/core/animate/anomate.md +0 -13
- package/types/animations/module.d.ts +0 -1
- package/types/core/animate/animate-css.d.ts +0 -19
- /package/src/{core/animate → animations}/animate-runner.js +0 -0
- /package/src/{core/animate → animations}/animate.spec.js +0 -0
- /package/src/{core/animate → animations}/helpers.js +0 -0
- /package/types/{core/animate → animations}/animate-runner.d.ts +0 -0
- /package/types/{core/animate → animations}/helpers.d.ts +0 -0
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { JQLite, dealoc } from "../../shared/jqlite/jqlite";
|
|
2
2
|
import { Angular } from "../../loader";
|
|
3
|
-
import { createInjector } from "../../core/di/injector";
|
|
4
3
|
import { NgModelController } from "./model";
|
|
5
4
|
import { isDefined, valueFn, isObject } from "../../shared/utils";
|
|
6
5
|
import { browserTrigger } from "../../shared/test-utils";
|
|
@@ -20,11 +19,13 @@ describe("ngModel", () => {
|
|
|
20
19
|
window.angular
|
|
21
20
|
.module("myModule", ["ng"])
|
|
22
21
|
.decorator("$exceptionHandler", function () {
|
|
23
|
-
return (exception
|
|
22
|
+
return (exception) => {
|
|
24
23
|
throw new Error(exception.message);
|
|
25
24
|
};
|
|
26
25
|
});
|
|
27
|
-
injector =
|
|
26
|
+
injector = window.angular.bootstrap(document.getElementById("dummy"), [
|
|
27
|
+
"myModule",
|
|
28
|
+
]);
|
|
28
29
|
$compile = injector.get("$compile");
|
|
29
30
|
|
|
30
31
|
const attrs = { name: "testAlias", ngModel: "value" };
|
|
@@ -44,7 +44,9 @@ describe("ngModelOptions", () => {
|
|
|
44
44
|
throw new Error(exception.message);
|
|
45
45
|
};
|
|
46
46
|
});
|
|
47
|
-
injector =
|
|
47
|
+
injector = window.angular.bootstrap(document.getElementById("dummy"), [
|
|
48
|
+
"myModule",
|
|
49
|
+
]);
|
|
48
50
|
$compile = injector.get("$compile");
|
|
49
51
|
$rootScope = injector.get("$rootScope");
|
|
50
52
|
$q = injector.get("$q");
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
|
|
108
108
|
<example module="ngRepeat" name="ngRepeat-tracking" deps="angular-animate.js" animations="true">
|
|
109
109
|
<file name="script.js">
|
|
110
|
-
angular.module('ngRepeat', [
|
|
110
|
+
angular.module('ngRepeat', []).controller('repeatController', function($scope) {
|
|
111
111
|
let friends = [
|
|
112
112
|
{name:'John', age:25},
|
|
113
113
|
{name:'Mary', age:40},
|
|
@@ -61,7 +61,7 @@ describe("select", () => {
|
|
|
61
61
|
throw new Error(exception);
|
|
62
62
|
};
|
|
63
63
|
});
|
|
64
|
-
|
|
64
|
+
let injector = window.angular.bootstrap(document.getElementById("dummy"), [
|
|
65
65
|
"myModule",
|
|
66
66
|
($compileProvider) => {
|
|
67
67
|
$compileProvider.directive("spyOnWriteValue", () => ({
|
|
@@ -77,7 +77,6 @@ describe("select", () => {
|
|
|
77
77
|
},
|
|
78
78
|
},
|
|
79
79
|
}));
|
|
80
|
-
|
|
81
80
|
$compileProvider.directive("myOptions", () => ({
|
|
82
81
|
scope: { myOptions: "=" },
|
|
83
82
|
replace: true,
|
|
@@ -96,7 +95,8 @@ describe("select", () => {
|
|
|
96
95
|
},
|
|
97
96
|
}));
|
|
98
97
|
},
|
|
99
|
-
])
|
|
98
|
+
]);
|
|
99
|
+
injector.invoke((_$rootScope_, _$compile_) => {
|
|
100
100
|
scope = _$rootScope_.$new(); // create a child scope because the root scope can't be $destroy-ed
|
|
101
101
|
$rootScope = _$rootScope_;
|
|
102
102
|
$compile = _$compile_;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { hasAnimate } from "../../shared/utils";
|
|
2
|
+
|
|
1
3
|
const NG_HIDE_CLASS = "ng-hide";
|
|
2
4
|
const NG_HIDE_IN_PROGRESS_CLASS = "ng-hide-animate";
|
|
3
5
|
|
|
@@ -15,9 +17,23 @@ export function ngShowDirective($animate) {
|
|
|
15
17
|
// we can control when the element is actually displayed on screen without having
|
|
16
18
|
// to have a global/greedy CSS selector that breaks when other animations are run.
|
|
17
19
|
// Read: https://github.com/angular/angular.js/issues/9103#issuecomment-58335845
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
if (hasAnimate(element[0])) {
|
|
21
|
+
$animate[value ? "removeClass" : "addClass"](element, NG_HIDE_CLASS, {
|
|
22
|
+
tempClasses: NG_HIDE_IN_PROGRESS_CLASS,
|
|
23
|
+
});
|
|
24
|
+
} else {
|
|
25
|
+
scope.$$postDigest(() => {
|
|
26
|
+
if (value) {
|
|
27
|
+
element
|
|
28
|
+
.elements()
|
|
29
|
+
.forEach((element) => element.classList.remove(NG_HIDE_CLASS));
|
|
30
|
+
} else {
|
|
31
|
+
element
|
|
32
|
+
.elements()
|
|
33
|
+
.forEach((element) => element.classList.add(NG_HIDE_CLASS));
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
21
37
|
});
|
|
22
38
|
},
|
|
23
39
|
};
|
|
@@ -35,9 +51,23 @@ export function ngHideDirective($animate) {
|
|
|
35
51
|
scope.$watch(attr.ngHide, (value) => {
|
|
36
52
|
// The comment inside of the ngShowDirective explains why we add and
|
|
37
53
|
// remove a temporary class for the show/hide animation
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
54
|
+
if (hasAnimate(element[0])) {
|
|
55
|
+
$animate[value ? "addClass" : "removeClass"](element, NG_HIDE_CLASS, {
|
|
56
|
+
tempClasses: NG_HIDE_IN_PROGRESS_CLASS,
|
|
57
|
+
});
|
|
58
|
+
} else {
|
|
59
|
+
scope.$$postDigest(() => {
|
|
60
|
+
if (value) {
|
|
61
|
+
element
|
|
62
|
+
.elements()
|
|
63
|
+
.forEach((element) => element.classList.add(NG_HIDE_CLASS));
|
|
64
|
+
} else {
|
|
65
|
+
element
|
|
66
|
+
.elements()
|
|
67
|
+
.forEach((element) => element.classList.remove(NG_HIDE_CLASS));
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
41
71
|
});
|
|
42
72
|
},
|
|
43
73
|
};
|
|
@@ -90,8 +90,8 @@ export function ngSwitchWhenDirective() {
|
|
|
90
90
|
);
|
|
91
91
|
|
|
92
92
|
cases.forEach((whenCase) => {
|
|
93
|
-
ctrl
|
|
94
|
-
ctrl
|
|
93
|
+
ctrl["cases"][`!${whenCase}`] = ctrl["cases"][`!${whenCase}`] || [];
|
|
94
|
+
ctrl["cases"][`!${whenCase}`].push({
|
|
95
95
|
transclude: $transclude,
|
|
96
96
|
element,
|
|
97
97
|
});
|
|
@@ -111,8 +111,8 @@ export function ngSwitchDefaultDirective() {
|
|
|
111
111
|
require: "^ngSwitch",
|
|
112
112
|
multiElement: true,
|
|
113
113
|
link(_scope, element, _attr, ctrl, $transclude) {
|
|
114
|
-
ctrl
|
|
115
|
-
ctrl
|
|
114
|
+
ctrl["cases"]["?"] = ctrl["cases"]["?"] || [];
|
|
115
|
+
ctrl["cases"]["?"].push({ transclude: $transclude, element });
|
|
116
116
|
},
|
|
117
117
|
};
|
|
118
118
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Angular } from "../../loader";
|
|
2
|
-
import { createInjector } from "../../core/di/injector";
|
|
3
2
|
import { dealoc } from "../../shared/jqlite/jqlite";
|
|
4
3
|
|
|
5
4
|
describe("ngSwitch", () => {
|
|
@@ -10,7 +9,11 @@ describe("ngSwitch", () => {
|
|
|
10
9
|
|
|
11
10
|
beforeEach(() => {
|
|
12
11
|
window.angular = new Angular();
|
|
13
|
-
|
|
12
|
+
window.angular.module("test", []);
|
|
13
|
+
let injector = window.angular.bootstrap(
|
|
14
|
+
document.getElementById("dummy", ["test"]),
|
|
15
|
+
);
|
|
16
|
+
injector.invoke(($rootScope, _$compile_, _$timeout_) => {
|
|
14
17
|
$scope = $rootScope.$new();
|
|
15
18
|
$compile = _$compile_;
|
|
16
19
|
$timeout = _$timeout_;
|
|
@@ -17,10 +17,12 @@ describe("validators", () => {
|
|
|
17
17
|
throw new Error(exception);
|
|
18
18
|
};
|
|
19
19
|
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
$
|
|
23
|
-
|
|
20
|
+
window.angular
|
|
21
|
+
.bootstrap(document.getElementById("dummy"), ["myModule"])
|
|
22
|
+
.invoke((_$compile_, _$rootScope_) => {
|
|
23
|
+
$compile = _$compile_;
|
|
24
|
+
$rootScope = _$rootScope_;
|
|
25
|
+
});
|
|
24
26
|
});
|
|
25
27
|
|
|
26
28
|
afterEach(() => {
|
package/src/loader.js
CHANGED
|
@@ -140,8 +140,7 @@ export class Angular {
|
|
|
140
140
|
"$compile",
|
|
141
141
|
"$injector",
|
|
142
142
|
/**
|
|
143
|
-
*
|
|
144
|
-
* @param {*} scope
|
|
143
|
+
* @param {import('./core/scope/scope').Scope} scope
|
|
145
144
|
* @param {JQLite} el
|
|
146
145
|
* @param {*} compile
|
|
147
146
|
* @param {import("./core/di/internal-injector").InjectorService} $injector
|
package/src/public.js
CHANGED
|
@@ -53,16 +53,12 @@ import { ngModelOptionsDirective } from "./directive/model-options/model-options
|
|
|
53
53
|
import { ngAttributeAliasDirectives } from "./directive/attrs/attrs";
|
|
54
54
|
import { ngEventDirectives } from "./directive/events/events";
|
|
55
55
|
import { AnchorScrollProvider } from "./services/anchor-scroll";
|
|
56
|
-
import {
|
|
57
|
-
AnimateProvider,
|
|
58
|
-
CoreAnimateQueueProvider,
|
|
59
|
-
} from "./core/animate/animate";
|
|
56
|
+
import { AnimateProvider } from "./animations/animate";
|
|
60
57
|
import { BrowserProvider } from "./services/browser";
|
|
61
|
-
import { CoreAnimateCssProvider } from "./core/animate/animate-css";
|
|
62
58
|
import {
|
|
63
59
|
AnimateAsyncRunFactoryProvider,
|
|
64
60
|
AnimateRunnerFactoryProvider,
|
|
65
|
-
} from "./
|
|
61
|
+
} from "./animations/animate-runner";
|
|
66
62
|
import {
|
|
67
63
|
CacheFactoryProvider,
|
|
68
64
|
TemplateCacheProvider,
|
|
@@ -89,7 +85,6 @@ import { $$TaskTrackerFactoryProvider } from "./core/task-tracker-factory";
|
|
|
89
85
|
import { TemplateRequestProvider } from "./services/template-request";
|
|
90
86
|
import { $TimeoutProvider } from "./core/timeout/timeout";
|
|
91
87
|
import { SanitizeUriProvider } from "./core/sanitize/sanitize-uri";
|
|
92
|
-
import { initAnimateModule } from "./animations/module";
|
|
93
88
|
import {
|
|
94
89
|
ngMessageDefaultDirective,
|
|
95
90
|
ngMessageDirective,
|
|
@@ -112,6 +107,16 @@ import {
|
|
|
112
107
|
ngShowAriaDirective,
|
|
113
108
|
ngValueAriaDirective,
|
|
114
109
|
} from "./directive/aria/aria";
|
|
110
|
+
import { $AnimateCssProvider } from "./animations/animate-css";
|
|
111
|
+
import { $$AnimateQueueProvider } from "./animations/animate-queue";
|
|
112
|
+
import { $$AnimateJsProvider } from "./animations/animate-js";
|
|
113
|
+
import { $$AnimationProvider } from "./animations/animation";
|
|
114
|
+
import { RafSchedulerProvider } from "./animations/raf-scheduler";
|
|
115
|
+
import { $$AnimateCacheProvider } from "./animations/animate-cache";
|
|
116
|
+
import { $$AnimateCssDriverProvider } from "./animations/animate-css-driver";
|
|
117
|
+
import { $$AnimateJsDriverProvider } from "./animations/animate-js-driver";
|
|
118
|
+
import { ngAnimateSwapDirective } from "./animations/animate-swap";
|
|
119
|
+
import { $$AnimateChildrenDirective } from "./animations/animate-children-directive";
|
|
115
120
|
|
|
116
121
|
/**
|
|
117
122
|
* @type {string} `version` from `package.json`, injected by Rollup plugin
|
|
@@ -190,6 +195,8 @@ export function publishExternalAPI(angular) {
|
|
|
190
195
|
})
|
|
191
196
|
.directive({
|
|
192
197
|
input: hiddenInputBrowserCacheDirective,
|
|
198
|
+
ngAnimateSwap: ngAnimateSwapDirective,
|
|
199
|
+
ngAnimateChildren: $$AnimateChildrenDirective,
|
|
193
200
|
ngChecked: ngCheckedAriaDirective,
|
|
194
201
|
ngClick: ngClickAriaDirective,
|
|
195
202
|
ngDblclick: ngDblclickAriaDirective,
|
|
@@ -208,8 +215,13 @@ export function publishExternalAPI(angular) {
|
|
|
208
215
|
$aria: AriaProvider,
|
|
209
216
|
$anchorScroll: AnchorScrollProvider,
|
|
210
217
|
$animate: AnimateProvider,
|
|
211
|
-
|
|
212
|
-
|
|
218
|
+
$$animation: $$AnimationProvider,
|
|
219
|
+
$animateCss: $AnimateCssProvider,
|
|
220
|
+
$$animateCssDriver: $$AnimateCssDriverProvider,
|
|
221
|
+
$$animateJs: $$AnimateJsProvider,
|
|
222
|
+
$$animateJsDriver: $$AnimateJsDriverProvider,
|
|
223
|
+
$$animateCache: $$AnimateCacheProvider,
|
|
224
|
+
$$animateQueue: $$AnimateQueueProvider,
|
|
213
225
|
$$AnimateRunner: AnimateRunnerFactoryProvider,
|
|
214
226
|
$$animateAsyncRun: AnimateAsyncRunFactoryProvider,
|
|
215
227
|
$browser: BrowserProvider,
|
|
@@ -227,6 +239,7 @@ export function publishExternalAPI(angular) {
|
|
|
227
239
|
$location: $LocationProvider,
|
|
228
240
|
$log: $LogProvider,
|
|
229
241
|
$parse: $ParseProvider,
|
|
242
|
+
$$rAFScheduler: RafSchedulerProvider,
|
|
230
243
|
$rootScope: $RootScopeProvider,
|
|
231
244
|
$q: $QProvider,
|
|
232
245
|
$$q: $$QProvider,
|
|
@@ -242,7 +255,6 @@ export function publishExternalAPI(angular) {
|
|
|
242
255
|
)
|
|
243
256
|
.info({ version: VERSION });
|
|
244
257
|
|
|
245
|
-
initAnimateModule(angular);
|
|
246
258
|
initRouter(angular);
|
|
247
259
|
return ng;
|
|
248
260
|
}
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
forEach,
|
|
3
|
-
tail,
|
|
4
|
-
unnestR,
|
|
5
|
-
uniqR,
|
|
6
|
-
inArray,
|
|
7
|
-
removeFrom,
|
|
8
|
-
} from "../../shared/common";
|
|
1
|
+
import { forEach, tail, unnestR, uniqR, removeFrom } from "../../shared/common";
|
|
9
2
|
import { isString, isObject } from "../../shared/utils";
|
|
10
3
|
|
|
11
4
|
import { parse } from "../../shared/hof";
|
|
@@ -362,7 +355,7 @@ export function $StateRefActiveDirective(
|
|
|
362
355
|
: [];
|
|
363
356
|
const addClasses = fuzzyClasses.concat(exactClasses).reduce(uniqR, []);
|
|
364
357
|
const removeClasses = allClasses.filter(
|
|
365
|
-
(cls) => !
|
|
358
|
+
(cls) => !addClasses.includes(cls),
|
|
366
359
|
);
|
|
367
360
|
$scope.$evalAsync(() => {
|
|
368
361
|
addClasses.forEach((className) =>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Transition } from "../transition/transition";
|
|
2
2
|
import { Resolvable } from "../resolve/resolvable";
|
|
3
|
-
import {
|
|
3
|
+
import { uniqR, unnestR } from "../../shared/common";
|
|
4
4
|
|
|
5
5
|
export function registerAddCoreResolvables(transitionService) {
|
|
6
6
|
transitionService.onCreate({}, function addCoreResolvables(trans) {
|
|
@@ -17,7 +17,7 @@ export function registerAddCoreResolvables(transitionService) {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
const TRANSITION_TOKENS = ["$transition$", Transition];
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
// References to Transition in the treeChanges pathnodes makes all
|
|
22
22
|
// previous Transitions reachable in memory, causing a memory leak
|
|
23
23
|
// This function removes resolves for '$transition$' and `Transition` from the treeChanges.
|
|
@@ -28,7 +28,9 @@ export function treeChangesCleanup(trans) {
|
|
|
28
28
|
.reduce(uniqR, []);
|
|
29
29
|
// If the resolvable is a Transition, return a new resolvable with null data
|
|
30
30
|
const replaceTransitionWithNull = (r) => {
|
|
31
|
-
return
|
|
31
|
+
return TRANSITION_TOKENS.includes(r.token)
|
|
32
|
+
? Resolvable.fromData(r.token, null)
|
|
33
|
+
: r;
|
|
32
34
|
};
|
|
33
35
|
nodes.forEach((node) => {
|
|
34
36
|
node.resolvables = node.resolvables.map(replaceTransitionWithNull);
|
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
tail,
|
|
6
6
|
mergeR,
|
|
7
7
|
unnestR,
|
|
8
|
-
inArray,
|
|
9
8
|
arrayTuples,
|
|
10
9
|
} from "../../shared/common";
|
|
11
10
|
import { prop, propEq } from "../../shared/hof";
|
|
@@ -51,7 +50,7 @@ export class PathUtils {
|
|
|
51
50
|
static applyViewConfigs($view, path, states) {
|
|
52
51
|
// Only apply the viewConfigs to the nodes for the given states
|
|
53
52
|
path
|
|
54
|
-
.filter((node) =>
|
|
53
|
+
.filter((node) => states.includes(node.state))
|
|
55
54
|
.forEach((node) => {
|
|
56
55
|
const viewDecls = Object.values(node.state.views || {});
|
|
57
56
|
const subPath = PathUtils.subPath(path, (n) => n === node);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { find, tail, uniqR, unnestR
|
|
2
|
-
import { propEq
|
|
1
|
+
import { find, tail, uniqR, unnestR } from "../../shared/common";
|
|
2
|
+
import { propEq } from "../../shared/hof";
|
|
3
3
|
import { trace } from "../common/trace";
|
|
4
4
|
import { services } from "../common/coreservices";
|
|
5
5
|
import { Resolvable } from "./resolvable";
|
|
@@ -61,7 +61,7 @@ export class ResolveContext {
|
|
|
61
61
|
/** Returns the [[ResolvePolicy]] for the given [[Resolvable]] */
|
|
62
62
|
getPolicy(resolvable) {
|
|
63
63
|
const node = this.findNode(resolvable);
|
|
64
|
-
return resolvable.getPolicy(node
|
|
64
|
+
return resolvable.getPolicy(node);
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
67
|
* Returns a ResolveContext that includes a portion of this one
|
|
@@ -122,7 +122,7 @@ export class ResolveContext {
|
|
|
122
122
|
*/
|
|
123
123
|
resolvePath(when = "LAZY", trans) {
|
|
124
124
|
// This option determines which 'when' policy Resolvables we are about to fetch.
|
|
125
|
-
const whenOption =
|
|
125
|
+
const whenOption = ALL_WHENS.includes(when) ? when : "LAZY";
|
|
126
126
|
// If the caller specified EAGER, only the EAGER Resolvables are fetched.
|
|
127
127
|
// if the caller specified LAZY, both EAGER and LAZY Resolvables are fetched.`
|
|
128
128
|
const matchedWhens =
|
|
@@ -130,7 +130,7 @@ export class ResolveContext {
|
|
|
130
130
|
// get the subpath to the state argument, if provided
|
|
131
131
|
trace.traceResolvePath(this._path, when, trans);
|
|
132
132
|
const matchesPolicy = (acceptedVals, whenOrAsync) => (resolvable) =>
|
|
133
|
-
|
|
133
|
+
acceptedVals.includes(this.getPolicy(resolvable)[whenOrAsync]);
|
|
134
134
|
// Trigger all the (matching) Resolvables in the path
|
|
135
135
|
// Reduce all the "WAIT" Resolvables into an array
|
|
136
136
|
const promises = this._path.reduce((acc, node) => {
|
|
@@ -139,7 +139,7 @@ export class ResolveContext {
|
|
|
139
139
|
);
|
|
140
140
|
const nowait = nodeResolvables.filter(matchesPolicy(["NOWAIT"], "async"));
|
|
141
141
|
const wait = nodeResolvables.filter(
|
|
142
|
-
|
|
142
|
+
(x) => !matchesPolicy(["NOWAIT"], "async")(x),
|
|
143
143
|
);
|
|
144
144
|
// For the matching Resolvables, start their async fetch process.
|
|
145
145
|
const subContext = this.subContext(node.state);
|
|
@@ -155,10 +155,10 @@ export class ResolveContext {
|
|
|
155
155
|
return services.$q.all(promises);
|
|
156
156
|
}
|
|
157
157
|
injector() {
|
|
158
|
-
return this._injector || (this._injector = new UIInjectorImpl(
|
|
158
|
+
return this._injector || (this._injector = new UIInjectorImpl());
|
|
159
159
|
}
|
|
160
160
|
findNode(resolvable) {
|
|
161
|
-
return find(this._path, (node) =>
|
|
161
|
+
return find(this._path, (node) => node.resolvables.includes(resolvable));
|
|
162
162
|
}
|
|
163
163
|
/**
|
|
164
164
|
* Gets the async dependencies of a Resolvable
|
|
@@ -177,7 +177,7 @@ export class ResolveContext {
|
|
|
177
177
|
const getDependency = (token) => {
|
|
178
178
|
const matching = availableResolvables.filter((r) => r.token === token);
|
|
179
179
|
if (matching.length) return tail(matching);
|
|
180
|
-
const fromInjector =
|
|
180
|
+
const fromInjector = services.$injector.get(token);
|
|
181
181
|
if (isUndefined(fromInjector)) {
|
|
182
182
|
throw new Error(
|
|
183
183
|
"Could not find Dependency Injection token: " + stringify(token),
|
|
@@ -190,31 +190,16 @@ export class ResolveContext {
|
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
class UIInjectorImpl {
|
|
193
|
-
constructor(
|
|
194
|
-
this.
|
|
195
|
-
this.native = this.get(NATIVE_INJECTOR_TOKEN) || services.$injector;
|
|
193
|
+
constructor() {
|
|
194
|
+
this.native = services.$injector;
|
|
196
195
|
}
|
|
197
196
|
get(token) {
|
|
198
|
-
|
|
199
|
-
if (resolvable) {
|
|
200
|
-
if (this.context.getPolicy(resolvable).async === "NOWAIT") {
|
|
201
|
-
return resolvable.get(this.context);
|
|
202
|
-
}
|
|
203
|
-
if (!resolvable.resolved) {
|
|
204
|
-
throw new Error(
|
|
205
|
-
"Resolvable async .get() not complete:" + stringify(resolvable.token),
|
|
206
|
-
);
|
|
207
|
-
}
|
|
208
|
-
return resolvable.data;
|
|
209
|
-
}
|
|
210
|
-
return this.getNative(token);
|
|
197
|
+
return services.$injector.get(token);
|
|
211
198
|
}
|
|
212
199
|
getAsync(token) {
|
|
213
|
-
|
|
214
|
-
if (resolvable) return resolvable.get(this.context);
|
|
215
|
-
return services.$q.when(this.native.get(token));
|
|
200
|
+
return services.$q.when(services.$injector.get(token));
|
|
216
201
|
}
|
|
217
202
|
getNative(token) {
|
|
218
|
-
return
|
|
203
|
+
return services.$injector.get(token);
|
|
219
204
|
}
|
|
220
205
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { inArray } from "../../shared/common";
|
|
2
1
|
import { prop } from "../../shared/hof";
|
|
3
2
|
import { isString } from "../../shared/utils";
|
|
4
3
|
import { StateObject } from "./state-object";
|
|
@@ -19,7 +18,7 @@ export class StateQueueManager {
|
|
|
19
18
|
if (!isString(name)) throw new Error("State must have a valid name");
|
|
20
19
|
if (
|
|
21
20
|
Object.prototype.hasOwnProperty.call(this.states, name) ||
|
|
22
|
-
|
|
21
|
+
queue.map(prop("name")).includes(name)
|
|
23
22
|
)
|
|
24
23
|
throw new Error(`State '${name}' is already defined`);
|
|
25
24
|
queue.push(state);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createProxyFunctions,
|
|
3
3
|
defaults,
|
|
4
|
-
inArray,
|
|
5
4
|
removeFrom,
|
|
6
5
|
silenceUncaughtInPromise,
|
|
7
6
|
silentRejection,
|
|
@@ -18,7 +17,7 @@ import { Param } from "../params/param";
|
|
|
18
17
|
import { Glob } from "../common/glob";
|
|
19
18
|
import { ResolveContext } from "../resolve/resolve-context";
|
|
20
19
|
import { lazyLoadState } from "../hooks/lazy-load";
|
|
21
|
-
import {
|
|
20
|
+
import { val } from "../../shared/hof";
|
|
22
21
|
import { EventBus } from "../../core/pubsub/pubsub";
|
|
23
22
|
|
|
24
23
|
const err = minErr("$stateProvider");
|
|
@@ -75,7 +74,7 @@ export class StateService {
|
|
|
75
74
|
};
|
|
76
75
|
const getters = ["current", "$current", "params", "transition"];
|
|
77
76
|
const boundFns = Object.keys(StateService.prototype).filter(
|
|
78
|
-
|
|
77
|
+
(x) => !getters.includes(x),
|
|
79
78
|
);
|
|
80
79
|
createProxyFunctions(
|
|
81
80
|
val(StateService.prototype),
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
uniqR,
|
|
15
15
|
} from "../../shared/common";
|
|
16
16
|
import { isUndefined, isObject } from "../../shared/utils";
|
|
17
|
-
import { prop, propEq, val,
|
|
17
|
+
import { prop, propEq, val, is } from "../../shared/hof";
|
|
18
18
|
import { TransitionHookPhase } from "./interface"; // has or is using
|
|
19
19
|
import { TransitionHook } from "./transition-hook";
|
|
20
20
|
import { matchState, makeEvent } from "./hook-registry";
|
|
@@ -500,7 +500,7 @@ export class Transition {
|
|
|
500
500
|
redirectEnteringNodes,
|
|
501
501
|
originalEnteringNodes,
|
|
502
502
|
PathUtils.nonDynamicParams,
|
|
503
|
-
).filter(
|
|
503
|
+
).filter((x) => !nodeIsReloading(targetState.options().reloadState)(x));
|
|
504
504
|
// Use the existing (possibly pre-resolved) resolvables for the matching entering nodes.
|
|
505
505
|
matchingEnteringNodes.forEach((node, idx) => {
|
|
506
506
|
node.resolvables = originalEnteringNodes[idx].resolvables;
|
package/src/router/view/view.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
equals,
|
|
3
|
-
applyPairs,
|
|
4
|
-
removeFrom,
|
|
5
|
-
inArray,
|
|
6
|
-
find,
|
|
7
|
-
} from "../../shared/common";
|
|
1
|
+
import { equals, applyPairs, removeFrom, find } from "../../shared/common";
|
|
8
2
|
import { curry, prop } from "../../shared/hof";
|
|
9
3
|
import { trace } from "../common/trace";
|
|
10
4
|
import { getNg1ViewConfigFactory } from "../state/views";
|
|
@@ -133,7 +127,7 @@ export class ViewService {
|
|
|
133
127
|
.map(matchingConfigPair);
|
|
134
128
|
const matchedViewConfigs = ngViewTuples.map((tuple) => tuple.viewConfig);
|
|
135
129
|
const unmatchedConfigTuples = this._viewConfigs
|
|
136
|
-
.filter((config) => !
|
|
130
|
+
.filter((config) => !matchedViewConfigs.includes(config))
|
|
137
131
|
.map((viewConfig) => ({ ngView: undefined, viewConfig }));
|
|
138
132
|
ngViewTuples.forEach(configureUIView);
|
|
139
133
|
const allTuples = ngViewTuples.concat(unmatchedConfigTuples);
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<!--
|
|
10
10
|
<script src="https://cdn.jsdelivr.net/npm/angular@1.8.3/angular.js"></script>
|
|
11
11
|
<script src="https://cdn.jsdelivr.net/npm/angular-animate@1.8.3/angular-animate.js"></script>
|
|
12
|
-
<script>window.angular.module("test", [
|
|
12
|
+
<script>window.angular.module("test", [])</script> -->
|
|
13
13
|
|
|
14
14
|
<script type="module" src="/src/index.js"></script>
|
|
15
15
|
<script>
|
package/src/shared/common.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isDate, isFunction, isRegExp, isString } from "./utils";
|
|
2
|
-
import { all, any, prop, curry
|
|
2
|
+
import { all, any, prop, curry } from "./hof";
|
|
3
3
|
import { services } from "../router/common/coreservices";
|
|
4
4
|
export const fromJson = JSON.parse.bind(JSON);
|
|
5
5
|
export const toJson = JSON.stringify.bind(JSON);
|
|
@@ -101,11 +101,6 @@ export function inherit(parent, extra) {
|
|
|
101
101
|
return newObj;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
/** Given an array, returns true if the object is found in the array, (using includes) */
|
|
105
|
-
export const inArray = curry(_inArray);
|
|
106
|
-
export function _inArray(array, obj) {
|
|
107
|
-
return array.includes(obj);
|
|
108
|
-
}
|
|
109
104
|
/**
|
|
110
105
|
* Given an array, and an item, if the item is found in the array, it removes it (in-place).
|
|
111
106
|
* The same array is returned
|
|
@@ -188,7 +183,7 @@ export function pick(obj, propNames) {
|
|
|
188
183
|
*/
|
|
189
184
|
export function omit(obj, propNames) {
|
|
190
185
|
return Object.keys(obj)
|
|
191
|
-
.filter(
|
|
186
|
+
.filter((x) => !propNames.includes(x))
|
|
192
187
|
.reduce((acc, key) => ((acc[key] = obj[key]), acc), {});
|
|
193
188
|
}
|
|
194
189
|
/**
|
|
@@ -287,7 +282,7 @@ export function pushR(arr, obj) {
|
|
|
287
282
|
}
|
|
288
283
|
/** Reduce function that filters out duplicates */
|
|
289
284
|
export const uniqR = (acc, token) =>
|
|
290
|
-
|
|
285
|
+
acc.includes(token) ? acc : pushR(acc, token);
|
|
291
286
|
/**
|
|
292
287
|
* Return a new array with a single level of arrays unnested.
|
|
293
288
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defaults, filter, map, mapObj, pick } from "./common";
|
|
2
|
-
import { is, eq,
|
|
2
|
+
import { is, eq, pattern, val } from "./hof";
|
|
3
3
|
import { isInjectable } from "./predicates";
|
|
4
4
|
import { Queue } from "../router/common/queue";
|
|
5
5
|
|
|
@@ -58,24 +58,6 @@ describe("common", function () {
|
|
|
58
58
|
});
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
-
describe("not", function () {
|
|
62
|
-
it("should allow double-negatives", function () {
|
|
63
|
-
function T() {
|
|
64
|
-
return true;
|
|
65
|
-
}
|
|
66
|
-
function F() {
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
function empty() {
|
|
70
|
-
return "";
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
expect(not(not(T))()).toBe(true);
|
|
74
|
-
expect(not(not(F))()).toBe(false);
|
|
75
|
-
expect(not(not(empty))()).toBe(false);
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
|
|
79
61
|
describe("val", function () {
|
|
80
62
|
it("should return identity", function () {
|
|
81
63
|
const f = function () {},
|
package/src/shared/hof.js
CHANGED
|
@@ -104,14 +104,7 @@ export const propEq = curry((name, _val, obj) => obj && obj[name] === _val);
|
|
|
104
104
|
* propNotFound(obj) === undefined
|
|
105
105
|
*/
|
|
106
106
|
export const parse = (name) => pipe.apply(null, name.split(".").map(prop));
|
|
107
|
-
|
|
108
|
-
* Given a function that returns a truthy or falsey value, returns a
|
|
109
|
-
* function that returns the opposite (falsey or truthy) value given the same inputs
|
|
110
|
-
*/
|
|
111
|
-
export const not =
|
|
112
|
-
(fn) =>
|
|
113
|
-
(...args) =>
|
|
114
|
-
!fn.apply(null, args);
|
|
107
|
+
|
|
115
108
|
/**
|
|
116
109
|
* Given two functions that return truthy or falsey values, returns a function that returns truthy
|
|
117
110
|
* if both functions return truthy for the given arguments
|