@angular-wave/angular.ts 0.3.0 → 0.4.0
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/.github/workflows/ci.yml +57 -0
- package/README.md +1 -1
- 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-cache.js +1 -1
- package/src/animations/animate-css-driver.js +2 -2
- package/src/animations/animate-css.js +1 -1
- package/src/animations/animate-js-driver.js +2 -2
- package/src/animations/animate-js.js +2 -2
- package/src/animations/animate-queue.js +2 -2
- package/src/animations/animation.js +1 -1
- package/src/core/cache/cache-factory.js +18 -2
- package/src/core/compile/attributes.js +1 -1
- package/src/core/compile/compile.js +10 -12
- package/src/core/compile/compile.spec.js +0 -1
- package/src/core/compile/compile.test.js +1 -1
- package/src/core/controller/controller.js +1 -1
- package/src/core/exception-handler.js +2 -6
- package/src/core/filter/filter.js +2 -2
- package/src/core/interpolate/interpolate.js +3 -3
- package/src/core/interval/interval-factory.js +7 -23
- package/src/core/interval/interval.js +1 -1
- package/src/core/interval/interval.spec.js +0 -25
- package/src/core/location/location.js +1 -1
- package/src/core/location/location.spec.js +3 -3
- package/src/core/parser/parse.js +2 -2
- package/src/core/q/q.js +0 -27
- package/src/core/q/q.spec.js +0 -44
- package/src/core/sce/sce.js +2 -2
- package/src/core/scope/scope.js +35 -41
- package/src/core/scope/scope.spec.js +71 -13
- package/src/core/task-tracker-factory.js +1 -1
- package/src/core/timeout/timeout.js +4 -8
- package/src/directive/attrs/attrs.js +1 -1
- package/src/directive/if/if.js +5 -5
- package/src/directive/input/input.spec.js +0 -1
- package/src/directive/observe/observe.html +18 -0
- package/src/directive/observe/observe.js +37 -0
- package/src/directive/observe/observe.spec.js +92 -0
- package/src/directive/observe/observe.test.js +9 -0
- package/src/directive/observe/test.html +197 -0
- package/src/directive/script/script.js +11 -9
- package/src/directive/validators/validators.js +70 -42
- package/src/public.js +63 -66
- package/src/router/params/param.js +1 -2
- package/src/router/path/path-node.js +5 -5
- package/src/router/path/path-utils.js +19 -21
- package/src/router/state/state-builder.js +17 -11
- package/src/router/state/state-queue-manager.js +16 -7
- package/src/router/state/state-registry.js +9 -5
- package/src/router/state/state-service.js +7 -11
- package/src/router/template-factory.js +2 -2
- package/src/router/transition/transition-service.js +1 -1
- package/src/router/transition/transition.js +13 -11
- package/src/router/url/url-matcher.js +2 -2
- package/src/router/url/url-service.js +1 -1
- package/src/router/view/view.js +3 -3
- package/src/router/view-scroll.js +13 -8
- package/src/services/http/http.js +2 -82
- package/src/services/http/http.spec.js +0 -118
- package/src/services/http/template-request.spec.js +10 -12
- package/src/services/http-backend/http-backend.js +1 -1
- package/src/services/log.js +1 -7
- package/src/services/template-request.js +3 -3
- package/src/shared/common.js +3 -9
- package/src/shared/hof.js +6 -8
- package/src/types.js +0 -14
- package/types/animations/animate-cache.d.ts +2 -2
- package/types/animations/animate-css-driver.d.ts +3 -3
- package/types/animations/animate-css.d.ts +2 -2
- package/types/animations/animate-js-driver.d.ts +3 -3
- package/types/animations/animate-js.d.ts +3 -3
- package/types/animations/animate-queue.d.ts +3 -3
- package/types/animations/animation.d.ts +2 -2
- package/types/core/cache/cache-factory.d.ts +20 -2
- package/types/core/compile/attributes.d.ts +3 -3
- package/types/core/compile/compile.d.ts +12 -12
- package/types/core/controller/controller.d.ts +1 -1
- package/types/core/exception-handler.d.ts +3 -4
- package/types/core/filter/filter.d.ts +3 -3
- package/types/core/interpolate/interpolate.d.ts +6 -6
- package/types/core/interval/interval-factory.d.ts +3 -3
- package/types/core/interval/interval.d.ts +2 -2
- package/types/core/location/location.d.ts +2 -2
- package/types/core/parser/parse.d.ts +4 -4
- package/types/core/q/q.d.ts +0 -5
- package/types/core/sce/sce.d.ts +4 -4
- package/types/core/scope/scope.d.ts +12 -3
- package/types/core/task-tracker-factory.d.ts +1 -1
- package/types/core/timeout/timeout.d.ts +3 -4
- package/types/directive/observe/observe.d.ts +4 -0
- package/types/directive/script/script.d.ts +8 -5
- package/types/directive/validators/validators.d.ts +3 -15
- package/types/router/path/path-node.d.ts +0 -7
- package/types/router/path/path-utils.d.ts +7 -2
- package/types/router/state/state-queue-manager.d.ts +13 -3
- package/types/router/state/state-registry.d.ts +5 -2
- package/types/router/state/state-service.d.ts +2 -2
- package/types/router/template-factory.d.ts +3 -3
- package/types/router/transition/transition-service.d.ts +1 -1
- package/types/router/transition/transition.d.ts +3 -3
- package/types/router/url/url-service.d.ts +3 -3
- package/types/router/view-scroll.d.ts +3 -3
- package/types/services/http/http.d.ts +4 -48
- package/types/services/http-backend/http-backend.d.ts +2 -2
- package/types/services/log.d.ts +2 -8
- package/types/services/template-request.d.ts +1 -1
- package/types/shared/common.d.ts +0 -5
- package/types/shared/hof.d.ts +0 -1
- package/types/types.d.ts +1 -1
- package/.github/workflows/lint.yml +0 -19
- package/.github/workflows/playwright.yml +0 -27
- package/.github/workflows/types.yml +0 -19
- package/src/directive/csp.md +0 -63
|
@@ -1,29 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
pick,
|
|
4
|
-
omit,
|
|
5
|
-
tail,
|
|
6
|
-
mergeR,
|
|
7
|
-
unnestR,
|
|
8
|
-
arrayTuples,
|
|
9
|
-
} from "../../shared/common";
|
|
10
|
-
import { prop, propEq } from "../../shared/hof";
|
|
1
|
+
import { find, pick, omit, unnestR, arrayTuples } from "../../shared/common";
|
|
2
|
+
import { propEq } from "../../shared/hof";
|
|
11
3
|
import { TargetState } from "../state/target-state";
|
|
12
4
|
import { PathNode } from "./path-node";
|
|
13
5
|
/**
|
|
14
6
|
* This class contains functions which convert TargetStates, Nodes and paths from one type to another.
|
|
15
7
|
*/
|
|
16
8
|
export class PathUtils {
|
|
17
|
-
/** Given a PathNode[], create an TargetState */
|
|
18
|
-
static makeTargetState(registry, path) {
|
|
19
|
-
const state = tail(path).state;
|
|
20
|
-
return new TargetState(
|
|
21
|
-
registry,
|
|
22
|
-
state,
|
|
23
|
-
path.map(prop("paramValues")).reduce(mergeR, {}),
|
|
24
|
-
{},
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
9
|
static buildPath(targetState) {
|
|
28
10
|
const toParams = targetState.params();
|
|
29
11
|
return targetState
|
|
@@ -81,7 +63,7 @@ export class PathUtils {
|
|
|
81
63
|
.map((node) => node.paramSchema)
|
|
82
64
|
.reduce(unnestR, [])
|
|
83
65
|
.filter((param) => !param.inherit)
|
|
84
|
-
.map(
|
|
66
|
+
.map((x) => x.id);
|
|
85
67
|
/**
|
|
86
68
|
* Given an [[PathNode]] "toNode", return a new [[PathNode]] with param values inherited from the
|
|
87
69
|
* matching node in fromPath. Only inherit keys that aren't found in "toKeys" from the node in "fromPath""
|
|
@@ -202,3 +184,19 @@ export class PathUtils {
|
|
|
202
184
|
return path.reduce((acc, node) => Object.assign(acc, node.paramValues), {});
|
|
203
185
|
}
|
|
204
186
|
}
|
|
187
|
+
|
|
188
|
+
/** Given a PathNode[], create an TargetState
|
|
189
|
+
* @param {import("../state/state-registry.js").StateRegistryProvider} registry
|
|
190
|
+
* @param {Array<PathNode>} path
|
|
191
|
+
* @returns
|
|
192
|
+
*/
|
|
193
|
+
export function makeTargetState(registry, path) {
|
|
194
|
+
return new TargetState(
|
|
195
|
+
registry,
|
|
196
|
+
path.at(-1).state,
|
|
197
|
+
path
|
|
198
|
+
.map((x) => x.paramValues)
|
|
199
|
+
.reduce((acc, obj) => ({ ...acc, ...obj }), {}),
|
|
200
|
+
{},
|
|
201
|
+
);
|
|
202
|
+
}
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from "../../shared/common";
|
|
9
9
|
import { isDefined, isFunction, isString } from "../../shared/utils";
|
|
10
10
|
import { stringify } from "../../shared/strings";
|
|
11
|
-
import { is, pattern, pipe,
|
|
11
|
+
import { is, pattern, pipe, val } from "../../shared/hof";
|
|
12
12
|
import { Resolvable } from "../resolve/resolvable";
|
|
13
13
|
import { services } from "../common/coreservices";
|
|
14
14
|
import { annotate } from "../../core/di/injector";
|
|
@@ -73,12 +73,18 @@ function getNavigableBuilder(isRoot) {
|
|
|
73
73
|
|
|
74
74
|
function getParamsBuilder(paramFactory) {
|
|
75
75
|
return function (state) {
|
|
76
|
-
const makeConfigParam = (
|
|
76
|
+
const makeConfigParam = (_config, id) =>
|
|
77
77
|
paramFactory.fromConfig(id, null, state.self);
|
|
78
78
|
const urlParams =
|
|
79
79
|
(state.url && state.url.parameters({ inherit: false })) || [];
|
|
80
80
|
const nonUrlParams = Object.values(
|
|
81
|
-
map(
|
|
81
|
+
map(
|
|
82
|
+
omit(
|
|
83
|
+
state.params || {},
|
|
84
|
+
urlParams.map((x) => x.id),
|
|
85
|
+
),
|
|
86
|
+
makeConfigParam,
|
|
87
|
+
),
|
|
82
88
|
);
|
|
83
89
|
return urlParams
|
|
84
90
|
.concat(nonUrlParams)
|
|
@@ -176,11 +182,11 @@ export function resolvablesBuilder(state) {
|
|
|
176
182
|
// Given a literal resolve or provider object, returns a Resolvable
|
|
177
183
|
const literal2Resolvable = pattern([
|
|
178
184
|
[
|
|
179
|
-
|
|
185
|
+
(x) => x.resolveFn,
|
|
180
186
|
(p) => new Resolvable(getToken(p), p.resolveFn, p.deps, p.policy),
|
|
181
187
|
],
|
|
182
188
|
[
|
|
183
|
-
|
|
189
|
+
(x) => x.useFactory,
|
|
184
190
|
(p) =>
|
|
185
191
|
new Resolvable(
|
|
186
192
|
getToken(p),
|
|
@@ -190,27 +196,27 @@ export function resolvablesBuilder(state) {
|
|
|
190
196
|
),
|
|
191
197
|
],
|
|
192
198
|
[
|
|
193
|
-
|
|
199
|
+
(x) => x.useClass,
|
|
194
200
|
(p) => new Resolvable(getToken(p), () => new p.useClass(), [], p.policy),
|
|
195
201
|
],
|
|
196
202
|
[
|
|
197
|
-
|
|
203
|
+
(x) => x.useValue,
|
|
198
204
|
(p) =>
|
|
199
205
|
new Resolvable(getToken(p), () => p.useValue, [], p.policy, p.useValue),
|
|
200
206
|
],
|
|
201
207
|
[
|
|
202
|
-
|
|
208
|
+
(x) => x.useExisting,
|
|
203
209
|
(p) => new Resolvable(getToken(p), (x) => x, [p.useExisting], p.policy),
|
|
204
210
|
],
|
|
205
211
|
]);
|
|
206
212
|
const tuple2Resolvable = pattern([
|
|
207
213
|
[
|
|
208
|
-
pipe(
|
|
214
|
+
pipe((x) => x.val, isString),
|
|
209
215
|
(tuple) =>
|
|
210
216
|
new Resolvable(tuple.token, (x) => x, [tuple.val], tuple.policy),
|
|
211
217
|
],
|
|
212
218
|
[
|
|
213
|
-
pipe(
|
|
219
|
+
pipe((x) => x.val, Array.isArray),
|
|
214
220
|
(tuple) =>
|
|
215
221
|
new Resolvable(
|
|
216
222
|
tuple.token,
|
|
@@ -220,7 +226,7 @@ export function resolvablesBuilder(state) {
|
|
|
220
226
|
),
|
|
221
227
|
],
|
|
222
228
|
[
|
|
223
|
-
pipe(
|
|
229
|
+
pipe((x) => x.val, isFunction),
|
|
224
230
|
(tuple) =>
|
|
225
231
|
new Resolvable(
|
|
226
232
|
tuple.token,
|
|
@@ -1,30 +1,39 @@
|
|
|
1
|
-
import { prop } from "../../shared/hof";
|
|
2
1
|
import { isString } from "../../shared/utils";
|
|
3
2
|
import { StateObject } from "./state-object";
|
|
4
3
|
|
|
5
4
|
export class StateQueueManager {
|
|
5
|
+
/**
|
|
6
|
+
* @param {import("./state-registry.js").StateRegistryProvider} stateRegistry
|
|
7
|
+
* @param {*} urlServiceRules
|
|
8
|
+
* @param {*} states
|
|
9
|
+
* @param {*} builder
|
|
10
|
+
* @param {*} listeners
|
|
11
|
+
*/
|
|
6
12
|
constructor(stateRegistry, urlServiceRules, states, builder, listeners) {
|
|
7
13
|
this.stateRegistry = stateRegistry;
|
|
8
14
|
this.urlServiceRules = urlServiceRules;
|
|
9
15
|
this.states = states;
|
|
10
16
|
this.builder = builder;
|
|
11
17
|
this.listeners = listeners;
|
|
18
|
+
/**
|
|
19
|
+
* @type {Array<StateObject>}
|
|
20
|
+
*/
|
|
12
21
|
this.queue = [];
|
|
13
22
|
}
|
|
23
|
+
|
|
14
24
|
register(stateDecl) {
|
|
15
|
-
const queue = this.queue;
|
|
16
25
|
const state = new StateObject(stateDecl);
|
|
17
|
-
const name = state.name;
|
|
18
26
|
if (!isString(name)) throw new Error("State must have a valid name");
|
|
19
27
|
if (
|
|
20
|
-
Object.prototype.hasOwnProperty.call(this.states, name) ||
|
|
21
|
-
queue.map(
|
|
28
|
+
Object.prototype.hasOwnProperty.call(this.states, state.name) ||
|
|
29
|
+
this.queue.map((x) => x.name).includes(state.name)
|
|
22
30
|
)
|
|
23
|
-
throw new Error(`State '${name}' is already defined`);
|
|
24
|
-
queue.push(state);
|
|
31
|
+
throw new Error(`State '${state.name}' is already defined`);
|
|
32
|
+
this.queue.push(state);
|
|
25
33
|
this.flush();
|
|
26
34
|
return state;
|
|
27
35
|
}
|
|
36
|
+
|
|
28
37
|
flush() {
|
|
29
38
|
const { queue, states, builder } = this;
|
|
30
39
|
const registered = [], // states that got registered
|
|
@@ -12,7 +12,7 @@ import { isString } from "../../shared/utils";
|
|
|
12
12
|
*
|
|
13
13
|
* This API is found at `$stateRegistry` ([[UIRouter.stateRegistry]])
|
|
14
14
|
*/
|
|
15
|
-
export class
|
|
15
|
+
export class StateRegistryProvider {
|
|
16
16
|
static $inject = [
|
|
17
17
|
"$urlServiceProvider",
|
|
18
18
|
"$stateProvider",
|
|
@@ -42,7 +42,8 @@ export class StateRegistry {
|
|
|
42
42
|
this.builder,
|
|
43
43
|
this.listeners,
|
|
44
44
|
);
|
|
45
|
-
|
|
45
|
+
|
|
46
|
+
this.registerRoot();
|
|
46
47
|
|
|
47
48
|
viewService._pluginapi._rootViewContext(this.root());
|
|
48
49
|
globals.$current = this.root();
|
|
@@ -90,7 +91,10 @@ export class StateRegistry {
|
|
|
90
91
|
};
|
|
91
92
|
}
|
|
92
93
|
|
|
93
|
-
|
|
94
|
+
/**
|
|
95
|
+
* @private
|
|
96
|
+
*/
|
|
97
|
+
registerRoot() {
|
|
94
98
|
const rootStateDef = {
|
|
95
99
|
name: "",
|
|
96
100
|
url: "^",
|
|
@@ -100,8 +104,8 @@ export class StateRegistry {
|
|
|
100
104
|
},
|
|
101
105
|
abstract: true,
|
|
102
106
|
};
|
|
103
|
-
|
|
104
|
-
_root.navigable = null;
|
|
107
|
+
this._root = this.stateQueue.register(rootStateDef);
|
|
108
|
+
this._root.navigable = null;
|
|
105
109
|
}
|
|
106
110
|
|
|
107
111
|
/**
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
import { isDefined, isObject, isString, minErr } from "../../shared/utils";
|
|
9
9
|
import { Queue } from "../common/queue";
|
|
10
10
|
import { services } from "../common/coreservices";
|
|
11
|
-
import {
|
|
11
|
+
import { makeTargetState } from "../path/path-utils";
|
|
12
12
|
import { PathNode } from "../path/path-node";
|
|
13
13
|
import { defaultTransOpts } from "../transition/transition-service";
|
|
14
14
|
import { Rejection, RejectType } from "../transition/reject-factory";
|
|
@@ -27,7 +27,7 @@ const err = minErr("$stateProvider");
|
|
|
27
27
|
*
|
|
28
28
|
* This API is located at `router.stateService` ([[UIRouter.stateService]])
|
|
29
29
|
*/
|
|
30
|
-
export class
|
|
30
|
+
export class StateProvider {
|
|
31
31
|
/**
|
|
32
32
|
* The latest successful state parameters
|
|
33
33
|
*
|
|
@@ -73,11 +73,11 @@ export class StateService {
|
|
|
73
73
|
}
|
|
74
74
|
};
|
|
75
75
|
const getters = ["current", "$current", "params", "transition"];
|
|
76
|
-
const boundFns = Object.keys(
|
|
76
|
+
const boundFns = Object.keys(StateProvider.prototype).filter(
|
|
77
77
|
(x) => !getters.includes(x),
|
|
78
78
|
);
|
|
79
79
|
createProxyFunctions(
|
|
80
|
-
val(
|
|
80
|
+
val(StateProvider.prototype),
|
|
81
81
|
this,
|
|
82
82
|
val(this),
|
|
83
83
|
boundFns,
|
|
@@ -88,11 +88,7 @@ export class StateService {
|
|
|
88
88
|
);
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
$get =
|
|
92
|
-
() => {
|
|
93
|
-
return this;
|
|
94
|
-
},
|
|
95
|
-
];
|
|
91
|
+
$get = () => this;
|
|
96
92
|
|
|
97
93
|
/**
|
|
98
94
|
* Decorates states when they are registered
|
|
@@ -215,7 +211,7 @@ export class StateService {
|
|
|
215
211
|
* @internal
|
|
216
212
|
*/
|
|
217
213
|
_handleInvalidTargetState(fromPath, toState) {
|
|
218
|
-
const fromState =
|
|
214
|
+
const fromState = makeTargetState(this.stateRegistry, fromPath);
|
|
219
215
|
const globals = this.globals;
|
|
220
216
|
const latestThing = () => globals.transitionHistory.peekTail();
|
|
221
217
|
const latest = latestThing();
|
|
@@ -690,7 +686,7 @@ export class StateService {
|
|
|
690
686
|
if (!state || !state.lazyLoad)
|
|
691
687
|
throw new Error("Can not lazy load " + stateOrName);
|
|
692
688
|
const currentPath = this.getCurrentPath();
|
|
693
|
-
const target =
|
|
689
|
+
const target = makeTargetState(this.stateRegistry, currentPath);
|
|
694
690
|
transition =
|
|
695
691
|
transition || this.transitionService.create(currentPath, target);
|
|
696
692
|
return lazyLoadState(transition, state);
|
|
@@ -14,7 +14,7 @@ import { annotate } from "../core/di/injector";
|
|
|
14
14
|
/**
|
|
15
15
|
* Service which manages loading of templates from a ViewConfig.
|
|
16
16
|
*/
|
|
17
|
-
export class
|
|
17
|
+
export class TemplateFactoryProvider {
|
|
18
18
|
constructor() {
|
|
19
19
|
/** @type {boolean} */
|
|
20
20
|
this._useHttp = false;
|
|
@@ -28,7 +28,7 @@ export class TemplateFactory {
|
|
|
28
28
|
"$injector",
|
|
29
29
|
/**
|
|
30
30
|
* @param {any} $http
|
|
31
|
-
* @param {
|
|
31
|
+
* @param {import("../core/cache/cache-factory").TemplateCache} $templateCache
|
|
32
32
|
* @param {any} $templateRequest
|
|
33
33
|
* @param {any} $q
|
|
34
34
|
* @param {import("../core/di/internal-injector").InjectorService} $injector
|
|
@@ -60,7 +60,7 @@ export let defaultTransOpts = {
|
|
|
60
60
|
*
|
|
61
61
|
* This API is located at `router.transitionService` ([[UIRouter.transitionService]])
|
|
62
62
|
*/
|
|
63
|
-
export class
|
|
63
|
+
export class TransitionProvider {
|
|
64
64
|
static $inject = ["$routerGlobalsProvider", "$viewProvider"];
|
|
65
65
|
|
|
66
66
|
/**
|
|
@@ -4,7 +4,6 @@ import { stringify } from "../../shared/strings";
|
|
|
4
4
|
import {
|
|
5
5
|
map,
|
|
6
6
|
find,
|
|
7
|
-
mergeR,
|
|
8
7
|
tail,
|
|
9
8
|
omit,
|
|
10
9
|
arrayTuples,
|
|
@@ -14,7 +13,7 @@ import {
|
|
|
14
13
|
uniqR,
|
|
15
14
|
} from "../../shared/common";
|
|
16
15
|
import { isUndefined, isObject, assert } from "../../shared/utils";
|
|
17
|
-
import {
|
|
16
|
+
import { propEq, val, is } from "../../shared/hof";
|
|
18
17
|
import { TransitionHookPhase } from "./interface"; // has or is using
|
|
19
18
|
import { TransitionHook } from "./transition-hook";
|
|
20
19
|
import { matchState, makeEvent } from "./hook-registry";
|
|
@@ -25,7 +24,6 @@ import { Resolvable } from "../resolve/resolvable";
|
|
|
25
24
|
import { ResolveContext } from "../resolve/resolve-context";
|
|
26
25
|
import { Rejection } from "./reject-factory";
|
|
27
26
|
|
|
28
|
-
const stateSelf = prop("self");
|
|
29
27
|
/**
|
|
30
28
|
* Represents a transition between two states.
|
|
31
29
|
*
|
|
@@ -45,7 +43,7 @@ export class Transition {
|
|
|
45
43
|
* @param fromPath The path of [[PathNode]]s from which the transition is leaving. The last node in the `fromPath`
|
|
46
44
|
* encapsulates the "from state".
|
|
47
45
|
* @param targetState The target state and parameters being transitioned to (also, the transition options)
|
|
48
|
-
* @param {import('../transition/transition-service').
|
|
46
|
+
* @param {import('../transition/transition-service').TransitionProvider} transitionService The [[TransitionService]] instance
|
|
49
47
|
* @internal
|
|
50
48
|
*/
|
|
51
49
|
constructor(fromPath, targetState, transitionService, globals) {
|
|
@@ -172,7 +170,9 @@ export class Transition {
|
|
|
172
170
|
}
|
|
173
171
|
params(pathname = "to") {
|
|
174
172
|
return Object.freeze(
|
|
175
|
-
this._treeChanges[pathname]
|
|
173
|
+
this._treeChanges[pathname]
|
|
174
|
+
.map((x) => x.paramValues)
|
|
175
|
+
.reduce((acc, obj) => ({ ...acc, ...obj }), {}),
|
|
176
176
|
);
|
|
177
177
|
}
|
|
178
178
|
paramsChanged() {
|
|
@@ -403,7 +403,7 @@ export class Transition {
|
|
|
403
403
|
* @returns an array of states that will be entered during this transition.
|
|
404
404
|
*/
|
|
405
405
|
entering() {
|
|
406
|
-
return map(this._treeChanges.entering,
|
|
406
|
+
return map(this._treeChanges.entering, (x) => x.state).map((x) => x.self);
|
|
407
407
|
}
|
|
408
408
|
/**
|
|
409
409
|
* Gets the states being exited.
|
|
@@ -411,8 +411,8 @@ export class Transition {
|
|
|
411
411
|
* @returns an array of states that will be exited during this transition.
|
|
412
412
|
*/
|
|
413
413
|
exiting() {
|
|
414
|
-
return map(this._treeChanges.exiting,
|
|
415
|
-
.map(
|
|
414
|
+
return map(this._treeChanges.exiting, (x) => x.state)
|
|
415
|
+
.map((x) => x.self)
|
|
416
416
|
.reverse();
|
|
417
417
|
}
|
|
418
418
|
/**
|
|
@@ -422,7 +422,7 @@ export class Transition {
|
|
|
422
422
|
* exited during this Transition
|
|
423
423
|
*/
|
|
424
424
|
retained() {
|
|
425
|
-
return map(this._treeChanges.retained,
|
|
425
|
+
return map(this._treeChanges.retained, (x) => x.state).map((x) => x.self);
|
|
426
426
|
}
|
|
427
427
|
/**
|
|
428
428
|
* Get the [[ViewConfig]]s associated with this Transition
|
|
@@ -439,7 +439,7 @@ export class Transition {
|
|
|
439
439
|
views(pathname = "entering", state) {
|
|
440
440
|
let path = this._treeChanges[pathname];
|
|
441
441
|
path = !state ? path : path.filter(propEq("state", state));
|
|
442
|
-
return path.map(
|
|
442
|
+
return path.map((x) => x.views).reduce(unnestR, []);
|
|
443
443
|
}
|
|
444
444
|
treeChanges(pathname) {
|
|
445
445
|
return pathname ? this._treeChanges[pathname] : this._treeChanges;
|
|
@@ -702,7 +702,9 @@ export class Transition {
|
|
|
702
702
|
from = isObject(fromStateOrName) ? fromStateOrName.name : fromStateOrName,
|
|
703
703
|
fromParams = stringify(
|
|
704
704
|
avoidEmptyHash(
|
|
705
|
-
this._treeChanges.from
|
|
705
|
+
this._treeChanges.from
|
|
706
|
+
.map((x) => x.paramValues)
|
|
707
|
+
.reduce((acc, obj) => ({ ...acc, ...obj }), {}),
|
|
706
708
|
),
|
|
707
709
|
),
|
|
708
710
|
toValid = this.valid() ? "" : "(X) ",
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
arrayTuples,
|
|
10
10
|
defaults,
|
|
11
11
|
} from "../../shared/common";
|
|
12
|
-
import {
|
|
12
|
+
import { propEq } from "../../shared/hof";
|
|
13
13
|
import { isDefined, isString } from "../../shared/utils";
|
|
14
14
|
import { Param, DefType } from "../params/param";
|
|
15
15
|
import { joinNeighborsR, splitOnDelim } from "../../shared/strings";
|
|
@@ -344,7 +344,7 @@ export class UrlMatcher {
|
|
|
344
344
|
return new RegExp(
|
|
345
345
|
[
|
|
346
346
|
"^",
|
|
347
|
-
unnest(this._cache.path.map(
|
|
347
|
+
unnest(this._cache.path.map((x) => x._compiled)).join(""),
|
|
348
348
|
this.config.strict === false ? "/?" : "",
|
|
349
349
|
"$",
|
|
350
350
|
].join(""),
|
|
@@ -26,7 +26,7 @@ export class UrlService {
|
|
|
26
26
|
];
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
* @param {import("../../core/location/location")
|
|
29
|
+
* @param {import("../../core/location/location").LocationProvider} $locationProvider
|
|
30
30
|
*/
|
|
31
31
|
constructor($locationProvider, stateService, globals, urlConfigProvider) {
|
|
32
32
|
this.stateService = stateService;
|
package/src/router/view/view.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { equals, applyPairs, removeFrom, find } from "../../shared/common";
|
|
2
|
-
import { curry
|
|
2
|
+
import { curry } from "../../shared/hof";
|
|
3
3
|
import { trace } from "../common/trace";
|
|
4
4
|
import { getNg1ViewConfigFactory } from "../state/views";
|
|
5
5
|
/**
|
|
@@ -177,7 +177,7 @@ export class ViewService {
|
|
|
177
177
|
* @return {Array} Returns an array of fully-qualified view names.
|
|
178
178
|
*/
|
|
179
179
|
available() {
|
|
180
|
-
return this._ngViews.map(
|
|
180
|
+
return this._ngViews.map((x) => x.fqn);
|
|
181
181
|
}
|
|
182
182
|
/**
|
|
183
183
|
* Returns the list of views on the page containing loaded content.
|
|
@@ -185,7 +185,7 @@ export class ViewService {
|
|
|
185
185
|
* @return {Array} Returns an array of fully-qualified view names.
|
|
186
186
|
*/
|
|
187
187
|
active() {
|
|
188
|
-
return this._ngViews.filter(
|
|
188
|
+
return this._ngViews.filter((x) => x.$config).map((x) => x.name);
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
/**
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export class ViewScrollProvider {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.enabled = false;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
useAnchorScroll() {
|
|
7
|
+
this.enabled = true;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
$get = [
|
|
7
11
|
"$anchorScroll",
|
|
8
12
|
"$timeout",
|
|
9
13
|
/**
|
|
@@ -12,15 +16,16 @@ export function $ViewScrollProvider() {
|
|
|
12
16
|
* @returns {import('../services/anchor-scroll').AnchorScrollObject|Function}
|
|
13
17
|
*/
|
|
14
18
|
($anchorScroll, $timeout) => {
|
|
15
|
-
if (
|
|
19
|
+
if (this.enabled) {
|
|
16
20
|
return $anchorScroll;
|
|
17
21
|
}
|
|
18
22
|
/**
|
|
19
23
|
* @param {import('../shared/jqlite/jqlite').JQLite} $element
|
|
24
|
+
* @returns {import('../core/q/q').QPromise<any>}
|
|
20
25
|
*/
|
|
21
26
|
return function ($element) {
|
|
22
27
|
return $timeout(
|
|
23
|
-
|
|
28
|
+
() => {
|
|
24
29
|
$element[0].scrollIntoView();
|
|
25
30
|
},
|
|
26
31
|
0,
|
|
@@ -54,7 +54,7 @@ function serializeValue(v) {
|
|
|
54
54
|
*
|
|
55
55
|
* Note that serializer will sort the request parameters alphabetically.
|
|
56
56
|
*/
|
|
57
|
-
export function
|
|
57
|
+
export function HttpParamSerializerProvider() {
|
|
58
58
|
this.$get = function () {
|
|
59
59
|
return function ngParamSerializer(params) {
|
|
60
60
|
if (!params) return "";
|
|
@@ -82,86 +82,6 @@ export function $HttpParamSerializerProvider() {
|
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
/**
|
|
86
|
-
*
|
|
87
|
-
* Alternative {@link $http `$http`} params serializer that follows
|
|
88
|
-
* jQuery's [`param()`](http://api.jquery.com/jquery.param/) method logic.
|
|
89
|
-
* The serializer will also sort the params alphabetically.
|
|
90
|
-
*
|
|
91
|
-
* To use it for serializing `$http` request parameters, set it as the `paramSerializer` property:
|
|
92
|
-
*
|
|
93
|
-
* ```js
|
|
94
|
-
* $http({
|
|
95
|
-
* url: myUrl,
|
|
96
|
-
* method: 'GET',
|
|
97
|
-
* params: myParams,
|
|
98
|
-
* paramSerializer: '$httpParamSerializerJQLike'
|
|
99
|
-
* });
|
|
100
|
-
* ```
|
|
101
|
-
*
|
|
102
|
-
* It is also possible to set it as the default `paramSerializer` in the
|
|
103
|
-
* {@link $httpProvider#defaults `$httpProvider`}.
|
|
104
|
-
*
|
|
105
|
-
* Additionally, you can inject the serializer and use it explicitly, for example to serialize
|
|
106
|
-
* form data for submission:
|
|
107
|
-
*
|
|
108
|
-
* ```js
|
|
109
|
-
* .controller(function($http, $httpParamSerializerJQLike) {
|
|
110
|
-
* //...
|
|
111
|
-
*
|
|
112
|
-
* $http({
|
|
113
|
-
* url: myUrl,
|
|
114
|
-
* method: 'POST',
|
|
115
|
-
* data: $httpParamSerializerJQLike(myData),
|
|
116
|
-
* headers: {
|
|
117
|
-
* 'Content-Type': 'application/x-www-form-urlencoded'
|
|
118
|
-
* }
|
|
119
|
-
* });
|
|
120
|
-
*
|
|
121
|
-
* });
|
|
122
|
-
* ```
|
|
123
|
-
*
|
|
124
|
-
*/
|
|
125
|
-
export function $HttpParamSerializerJQLikeProvider() {
|
|
126
|
-
this.$get = function () {
|
|
127
|
-
return function jQueryLikeParamSerializer(params) {
|
|
128
|
-
if (!params) return "";
|
|
129
|
-
const parts = [];
|
|
130
|
-
serialize(params, "", true);
|
|
131
|
-
return parts.join("&");
|
|
132
|
-
|
|
133
|
-
function serialize(toSerialize, prefix, topLevel) {
|
|
134
|
-
if (Array.isArray(toSerialize)) {
|
|
135
|
-
forEach(toSerialize, (value, index) => {
|
|
136
|
-
serialize(value, `${prefix}[${isObject(value) ? index : ""}]`);
|
|
137
|
-
});
|
|
138
|
-
} else if (isObject(toSerialize) && !isDate(toSerialize)) {
|
|
139
|
-
Object.keys(toSerialize)
|
|
140
|
-
.sort()
|
|
141
|
-
.forEach((key) => {
|
|
142
|
-
const value = toSerialize[key];
|
|
143
|
-
serialize(
|
|
144
|
-
value,
|
|
145
|
-
prefix + (topLevel ? "" : "[") + key + (topLevel ? "" : "]"),
|
|
146
|
-
);
|
|
147
|
-
});
|
|
148
|
-
} else {
|
|
149
|
-
if (isFunction(toSerialize)) {
|
|
150
|
-
toSerialize = toSerialize();
|
|
151
|
-
}
|
|
152
|
-
parts.push(
|
|
153
|
-
`${encodeUriQuery(prefix)}=${
|
|
154
|
-
toSerialize == null
|
|
155
|
-
? ""
|
|
156
|
-
: encodeUriQuery(serializeValue(toSerialize))
|
|
157
|
-
}`,
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
};
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
|
|
165
85
|
export function defaultHttpResponseTransform(data, headers) {
|
|
166
86
|
if (isString(data)) {
|
|
167
87
|
// Strip json vulnerability protection prefix and trim whitespace
|
|
@@ -297,7 +217,7 @@ function isSuccess(status) {
|
|
|
297
217
|
/**
|
|
298
218
|
* Use `$httpProvider` to change the default behavior of the {@link ng.$http $http} service.
|
|
299
219
|
*/
|
|
300
|
-
export function
|
|
220
|
+
export function HttpProvider() {
|
|
301
221
|
/**
|
|
302
222
|
* Object containing default values for all {@link ng.$http $http} requests.
|
|
303
223
|
*
|