@angular-wave/angular.ts 0.0.73 → 0.1.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/types.yml +19 -0
- 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.js +1 -8
- package/src/core/compile/attributes.js +3 -3
- package/src/core/compile/compile.js +432 -368
- package/src/core/interpolate/interpolate.js +14 -10
- package/src/router/resolve/resolve-context.js +1 -0
- package/src/router/state/state-builder.js +38 -13
- package/src/router/state/state-object.js +12 -22
- package/src/router/state/state-queue-manager.js +1 -1
- package/src/router/state/state-registry.js +2 -1
- package/src/router/transition/transition.js +3 -1
- package/src/router/url/url-rule.js +14 -2
- package/src/router/view/view.spec.js +1 -1
- package/src/shared/predicates.js +3 -0
- package/tsconfig.json +1 -1
- package/types/core/compile/attributes.d.ts +5 -5
- package/types/core/interpolate/interpolate.d.ts +5 -5
- package/types/router/state/state-object.d.ts +12 -9
- package/types/router/state/state-registry.d.ts +2 -2
- package/types/router/transition/transition.d.ts +1 -1
- package/types/router/url/url-rule.d.ts +6 -1
- package/types/shared/predicates.d.ts +2 -0
- package/src/router/injectables.js +0 -263
- package/types/router/injectables.d.ts +0 -1
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
import { constantWatchDelegate } from "../parser/parse";
|
|
10
10
|
|
|
11
11
|
const $interpolateMinErr = minErr("$interpolate");
|
|
12
|
-
|
|
12
|
+
function throwNoconcat(text) {
|
|
13
13
|
throw $interpolateMinErr(
|
|
14
14
|
"noconcat",
|
|
15
15
|
"Error while interpolating: {0}\nStrict Contextual Escaping disallows " +
|
|
@@ -17,16 +17,16 @@ $interpolateMinErr.throwNoconcat = function (text) {
|
|
|
17
17
|
"required. See http://docs.angularjs.org/api/ng.$sce",
|
|
18
18
|
text,
|
|
19
19
|
);
|
|
20
|
-
}
|
|
20
|
+
}
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
function interr(text, err) {
|
|
23
23
|
throw $interpolateMinErr(
|
|
24
24
|
"interr",
|
|
25
25
|
"Can't interpolate: {0}\n{1}",
|
|
26
26
|
text,
|
|
27
27
|
err.toString(),
|
|
28
28
|
);
|
|
29
|
-
}
|
|
29
|
+
}
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
*
|
|
@@ -48,7 +48,7 @@ export function $InterpolateProvider() {
|
|
|
48
48
|
* Symbol to denote start of expression in the interpolated string. Defaults to `{{`.
|
|
49
49
|
*
|
|
50
50
|
* @param {string=} value new value to set the starting symbol to.
|
|
51
|
-
* @returns {string
|
|
51
|
+
* @returns {string|$InterpolateProvider} Returns the symbol when used as getter and self if used as setter.
|
|
52
52
|
*/
|
|
53
53
|
this.startSymbol = function (value) {
|
|
54
54
|
if (value) {
|
|
@@ -62,7 +62,7 @@ export function $InterpolateProvider() {
|
|
|
62
62
|
* Symbol to denote the end of expression in the interpolated string. Defaults to `}}`.
|
|
63
63
|
*
|
|
64
64
|
* @param {string=} value new value to set the ending symbol to.
|
|
65
|
-
* @returns {string
|
|
65
|
+
* @returns {string|$InterpolateProvider} Returns the symbol when used as getter and self if used as setter.
|
|
66
66
|
*/
|
|
67
67
|
this.endSymbol = function (value) {
|
|
68
68
|
if (value) {
|
|
@@ -215,7 +215,7 @@ export function $InterpolateProvider() {
|
|
|
215
215
|
* provides Strict Contextual Escaping for details.
|
|
216
216
|
* @param {boolean=} allOrNothing if `true`, then the returned function returns undefined
|
|
217
217
|
* unless all embedded expressions evaluate to a value other than `undefined`.
|
|
218
|
-
* @returns {
|
|
218
|
+
* @returns {Function} an interpolation function which is used to compute the
|
|
219
219
|
* interpolated string. The function has these parameters:
|
|
220
220
|
*
|
|
221
221
|
* - `context`: evaluation context for all expressions embedded in the interpolated text
|
|
@@ -237,6 +237,10 @@ export function $InterpolateProvider() {
|
|
|
237
237
|
if (contextAllowsConcatenation) {
|
|
238
238
|
unescapedText = $sce.getTrusted(trustedContext, unescapedText);
|
|
239
239
|
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* @type {any}
|
|
243
|
+
*/
|
|
240
244
|
const constantInterp = valueFn(unescapedText);
|
|
241
245
|
constantInterp.exp = text;
|
|
242
246
|
constantInterp.expressions = [];
|
|
@@ -322,7 +326,7 @@ export function $InterpolateProvider() {
|
|
|
322
326
|
}
|
|
323
327
|
if (trustedContext && concat.length > 1) {
|
|
324
328
|
// This context does not allow more than one part, e.g. expr + string or exp + exp.
|
|
325
|
-
|
|
329
|
+
throwNoconcat(text);
|
|
326
330
|
}
|
|
327
331
|
// In an unprivileged context or only one part: just concatenate and return.
|
|
328
332
|
return concat.join("");
|
|
@@ -341,7 +345,7 @@ export function $InterpolateProvider() {
|
|
|
341
345
|
|
|
342
346
|
return compute(values);
|
|
343
347
|
} catch (err) {
|
|
344
|
-
|
|
348
|
+
interr(text, err);
|
|
345
349
|
}
|
|
346
350
|
},
|
|
347
351
|
{
|
|
@@ -380,7 +384,7 @@ export function $InterpolateProvider() {
|
|
|
380
384
|
: $sce.valueOf(value);
|
|
381
385
|
return allOrNothing && !isDefined(value) ? value : stringify(value);
|
|
382
386
|
} catch (err) {
|
|
383
|
-
|
|
387
|
+
interr(text, err);
|
|
384
388
|
}
|
|
385
389
|
}
|
|
386
390
|
}
|
|
@@ -107,6 +107,7 @@ export class ResolveContext {
|
|
|
107
107
|
* @param state Used to find the node to put the resolvable on
|
|
108
108
|
*/
|
|
109
109
|
addResolvables(newResolvables, state) {
|
|
110
|
+
/** @type {import('../path/path-node').PathNode} */
|
|
110
111
|
const node = find(this._path, propEq("state", state));
|
|
111
112
|
const keys = newResolvables.map((r) => r.token);
|
|
112
113
|
node.resolvables = node.resolvables
|
|
@@ -172,7 +172,7 @@ export function resolvablesBuilder(state) {
|
|
|
172
172
|
);
|
|
173
173
|
/** extracts the token from a Provider or provide literal */
|
|
174
174
|
const getToken = (p) => p.provide || p.token;
|
|
175
|
-
//
|
|
175
|
+
// Given a literal resolve or provider object, returns a Resolvable
|
|
176
176
|
const literal2Resolvable = pattern([
|
|
177
177
|
[
|
|
178
178
|
prop("resolveFn"),
|
|
@@ -202,20 +202,45 @@ export function resolvablesBuilder(state) {
|
|
|
202
202
|
(p) => new Resolvable(getToken(p), (x) => x, [p.useExisting], p.policy),
|
|
203
203
|
],
|
|
204
204
|
]);
|
|
205
|
-
// prettier-ignore
|
|
206
205
|
const tuple2Resolvable = pattern([
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
206
|
+
[
|
|
207
|
+
pipe(prop("val"), isString),
|
|
208
|
+
(tuple) =>
|
|
209
|
+
new Resolvable(tuple.token, (x) => x, [tuple.val], tuple.policy),
|
|
210
|
+
],
|
|
211
|
+
[
|
|
212
|
+
pipe(prop("val"), Array.isArray),
|
|
213
|
+
(tuple) =>
|
|
214
|
+
new Resolvable(
|
|
215
|
+
tuple.token,
|
|
216
|
+
tail(tuple.val),
|
|
217
|
+
tuple.val.slice(0, -1),
|
|
218
|
+
tuple.policy,
|
|
219
|
+
),
|
|
220
|
+
],
|
|
221
|
+
[
|
|
222
|
+
pipe(prop("val"), isFunction),
|
|
223
|
+
(tuple) =>
|
|
224
|
+
new Resolvable(
|
|
225
|
+
tuple.token,
|
|
226
|
+
tuple.val,
|
|
227
|
+
annotateFn(tuple.val),
|
|
228
|
+
tuple.policy,
|
|
229
|
+
),
|
|
230
|
+
],
|
|
231
|
+
]);
|
|
212
232
|
const item2Resolvable = pattern([
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
233
|
+
[is(Resolvable), (r) => r],
|
|
234
|
+
[isResolveLiteral, literal2Resolvable],
|
|
235
|
+
[isLikeNg2Provider, literal2Resolvable],
|
|
236
|
+
[isTupleFromObj, tuple2Resolvable],
|
|
237
|
+
[
|
|
238
|
+
val(true),
|
|
239
|
+
(obj) => {
|
|
240
|
+
throw new Error("Invalid resolve value: " + stringify(obj));
|
|
241
|
+
},
|
|
242
|
+
],
|
|
243
|
+
]);
|
|
219
244
|
// If resolveBlock is already an array, use it as-is.
|
|
220
245
|
// Otherwise, assume it's an object and convert to an Array of tuples
|
|
221
246
|
const decl = state.resolve;
|
|
@@ -13,29 +13,19 @@ import { isFunction, isObject } from "../../shared/utils";
|
|
|
13
13
|
* Each of its own properties (i.e., `hasOwnProperty`) are built using builders from the [[StateBuilder]].
|
|
14
14
|
*/
|
|
15
15
|
export class StateObject {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
*/
|
|
24
|
-
static create(stateDecl) {
|
|
25
|
-
const state = Object.setPrototypeOf(
|
|
26
|
-
Object.assign({}, stateDecl),
|
|
27
|
-
StateObject.prototype,
|
|
28
|
-
);
|
|
29
|
-
stateDecl.$$state = () => state;
|
|
30
|
-
state.self = stateDecl;
|
|
31
|
-
state.__stateObjectCache = {
|
|
32
|
-
nameGlob: Glob.fromString(state.name), // might return null
|
|
33
|
-
};
|
|
34
|
-
return state;
|
|
35
|
-
}
|
|
36
|
-
// /** @deprecated use State.create() */
|
|
16
|
+
name = undefined;
|
|
17
|
+
navigable = undefined;
|
|
18
|
+
/** @type {?StateObject} */
|
|
19
|
+
parent = undefined;
|
|
20
|
+
params = undefined;
|
|
21
|
+
url = undefined;
|
|
22
|
+
|
|
37
23
|
constructor(config) {
|
|
38
|
-
|
|
24
|
+
Object.assign(this, config);
|
|
25
|
+
this.$$state = () => this;
|
|
26
|
+
this.self = config;
|
|
27
|
+
const nameGlob = this.name ? Glob.fromString(this.name) : null;
|
|
28
|
+
this.__stateObjectCache = { nameGlob };
|
|
39
29
|
}
|
|
40
30
|
/**
|
|
41
31
|
* Returns true if the provided parameter is the same state.
|
|
@@ -13,7 +13,7 @@ export class StateQueueManager {
|
|
|
13
13
|
}
|
|
14
14
|
register(stateDecl) {
|
|
15
15
|
const queue = this.queue;
|
|
16
|
-
const state = StateObject
|
|
16
|
+
const state = new StateObject(stateDecl);
|
|
17
17
|
const name = state.name;
|
|
18
18
|
if (!isString(name)) throw new Error("State must have a valid name");
|
|
19
19
|
if (
|
|
@@ -6,6 +6,7 @@ import { propEq } from "../../shared/hof";
|
|
|
6
6
|
import { ResolveContext } from "../resolve/resolve-context";
|
|
7
7
|
import { ng1ViewsBuilder } from "./views";
|
|
8
8
|
import { isString } from "../../shared/utils";
|
|
9
|
+
|
|
9
10
|
/**
|
|
10
11
|
* A registry for all of the application's [[StateDeclaration]]s
|
|
11
12
|
*
|
|
@@ -196,7 +197,7 @@ export class StateRegistry {
|
|
|
196
197
|
* If the state has children, they are are also removed from the registry.
|
|
197
198
|
*
|
|
198
199
|
* @param stateOrName the state's name or object representation
|
|
199
|
-
* @returns {StateObject[]} a list of removed states
|
|
200
|
+
* @returns {import('./state-object').StateObject[]} a list of removed states
|
|
200
201
|
*/
|
|
201
202
|
deregister(stateOrName) {
|
|
202
203
|
const _state = this.get(stateOrName);
|
|
@@ -323,12 +323,14 @@ export class Transition {
|
|
|
323
323
|
* @param resolvable a [[ResolvableLiteral]] object (or a [[Resolvable]])
|
|
324
324
|
* @param state the state in the "to path" which should receive the new resolve (otherwise, the root state)
|
|
325
325
|
*/
|
|
326
|
-
addResolvable(resolvable, state
|
|
326
|
+
addResolvable(resolvable, state) {
|
|
327
327
|
resolvable = is(Resolvable)(resolvable)
|
|
328
328
|
? resolvable
|
|
329
329
|
: new Resolvable(resolvable);
|
|
330
|
+
|
|
330
331
|
const stateName = typeof state === "string" ? state : state.name;
|
|
331
332
|
const topath = this._treeChanges.to;
|
|
333
|
+
/** @type {import('../path/path-node').PathNode} */
|
|
332
334
|
const targetNode = find(topath, (node) => {
|
|
333
335
|
return node.state.name === stateName;
|
|
334
336
|
});
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { UrlMatcher } from "./url-matcher";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
isString,
|
|
4
|
+
isFunction,
|
|
5
|
+
isDefined,
|
|
6
|
+
isUndefined,
|
|
7
|
+
assert,
|
|
8
|
+
} from "../../shared/utils";
|
|
3
9
|
import { is, or, pattern } from "../../shared/hof";
|
|
4
10
|
import { StateObject } from "../state/state-object";
|
|
5
11
|
/**
|
|
@@ -207,7 +213,13 @@ export class BaseUrlRule {
|
|
|
207
213
|
this.handler = handler || ((x) => x);
|
|
208
214
|
}
|
|
209
215
|
|
|
210
|
-
|
|
216
|
+
/**
|
|
217
|
+
* This function should be overridden
|
|
218
|
+
* @param {*} [params]
|
|
219
|
+
* @returns {number}
|
|
220
|
+
*/
|
|
221
|
+
matchPriority(params) {
|
|
222
|
+
assert(isUndefined(params));
|
|
211
223
|
return 0 - this.$id;
|
|
212
224
|
}
|
|
213
225
|
}
|
|
@@ -61,7 +61,7 @@ describe("view", () => {
|
|
|
61
61
|
|
|
62
62
|
let register;
|
|
63
63
|
const registerState = curry(function (_states, stateBuilder, config) {
|
|
64
|
-
const state = StateObject
|
|
64
|
+
const state = new StateObject(config);
|
|
65
65
|
const built = stateBuilder.build(state);
|
|
66
66
|
return (_states[built.name] = built);
|
|
67
67
|
});
|
package/src/shared/predicates.js
CHANGED
|
@@ -15,11 +15,14 @@ export const isNullOrUndefined = or(isNull, isUndefined);
|
|
|
15
15
|
*
|
|
16
16
|
* A value is "injectable" if it is a function, or if it is an ng1 array-notation-style array
|
|
17
17
|
* where all the elements in the array are Strings, except the last one, which is a Function
|
|
18
|
+
* @param {*} val
|
|
19
|
+
* @returns {boolean}
|
|
18
20
|
*/
|
|
19
21
|
export function isInjectable(val) {
|
|
20
22
|
if (Array.isArray(val) && val.length) {
|
|
21
23
|
const head = val.slice(0, -1),
|
|
22
24
|
tail = val.slice(-1);
|
|
25
|
+
|
|
23
26
|
return !(
|
|
24
27
|
head.filter((x) => !isString(x)).length ||
|
|
25
28
|
tail.filter((x) => !isFunction(x)).length
|
package/tsconfig.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {Object}
|
|
3
|
-
* @property {
|
|
2
|
+
* @typedef {Object} AttributeLike
|
|
3
|
+
* @property {Object} $attr
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
* @extends {
|
|
6
|
+
* @extends {AttributeLike}
|
|
7
7
|
*/
|
|
8
8
|
export class Attributes {
|
|
9
9
|
/**
|
|
@@ -104,7 +104,7 @@ export class Attributes {
|
|
|
104
104
|
sanitizeSrcset(value: any, invokeType: any): any;
|
|
105
105
|
srcset: any;
|
|
106
106
|
}
|
|
107
|
-
export type
|
|
108
|
-
|
|
107
|
+
export type AttributeLike = {
|
|
108
|
+
$attr: any;
|
|
109
109
|
};
|
|
110
110
|
import { directiveNormalize } from "../../shared/utils";
|
|
@@ -16,18 +16,18 @@ export class $InterpolateProvider {
|
|
|
16
16
|
* Symbol to denote start of expression in the interpolated string. Defaults to `{{`.
|
|
17
17
|
*
|
|
18
18
|
* @param {string=} value new value to set the starting symbol to.
|
|
19
|
-
* @returns {string
|
|
19
|
+
* @returns {string|$InterpolateProvider} Returns the symbol when used as getter and self if used as setter.
|
|
20
20
|
*/
|
|
21
|
-
startSymbol: (value?: string | undefined) => string |
|
|
21
|
+
startSymbol: (value?: string | undefined) => string | $InterpolateProvider;
|
|
22
22
|
/**
|
|
23
23
|
* Symbol to denote the end of expression in the interpolated string. Defaults to `}}`.
|
|
24
24
|
*
|
|
25
25
|
* @param {string=} value new value to set the ending symbol to.
|
|
26
|
-
* @returns {string
|
|
26
|
+
* @returns {string|$InterpolateProvider} Returns the symbol when used as getter and self if used as setter.
|
|
27
27
|
*/
|
|
28
|
-
endSymbol: (value?: string | undefined) => string |
|
|
28
|
+
endSymbol: (value?: string | undefined) => string | $InterpolateProvider;
|
|
29
29
|
$get: (string | (($parse: import("../parser/parse").ParseService, $exceptionHandler: import("../exception-handler").ErrorHandler, $sce: any) => {
|
|
30
|
-
(text: string, mustHaveExpression?: boolean | undefined, trustedContext?: string | undefined, allOrNothing?: boolean | undefined):
|
|
30
|
+
(text: string, mustHaveExpression?: boolean | undefined, trustedContext?: string | undefined, allOrNothing?: boolean | undefined): Function;
|
|
31
31
|
/**
|
|
32
32
|
* @ngdoc method
|
|
33
33
|
* @name $interpolate#startSymbol
|
|
@@ -9,16 +9,18 @@
|
|
|
9
9
|
* Each of its own properties (i.e., `hasOwnProperty`) are built using builders from the [[StateBuilder]].
|
|
10
10
|
*/
|
|
11
11
|
export class StateObject {
|
|
12
|
-
/**
|
|
13
|
-
* Create a state object to put the private/internal implementation details onto.
|
|
14
|
-
* The object's prototype chain looks like:
|
|
15
|
-
* (Internal State Object) -> (Copy of State.prototype) -> (State Declaration object) -> (State Declaration's prototype...)
|
|
16
|
-
*
|
|
17
|
-
* @param stateDecl the user-supplied State Declaration
|
|
18
|
-
* @returns {StateObject} an internal State object
|
|
19
|
-
*/
|
|
20
|
-
static create(stateDecl: any): StateObject;
|
|
21
12
|
constructor(config: any);
|
|
13
|
+
name: any;
|
|
14
|
+
navigable: any;
|
|
15
|
+
/** @type {?StateObject} */
|
|
16
|
+
parent: StateObject | null;
|
|
17
|
+
params: any;
|
|
18
|
+
url: any;
|
|
19
|
+
$$state: () => this;
|
|
20
|
+
self: any;
|
|
21
|
+
__stateObjectCache: {
|
|
22
|
+
nameGlob: Glob;
|
|
23
|
+
};
|
|
22
24
|
/**
|
|
23
25
|
* Returns true if the provided parameter is the same state.
|
|
24
26
|
*
|
|
@@ -68,3 +70,4 @@ export namespace StateObject {
|
|
|
68
70
|
/** Predicate which returns true if the object is an internal [[StateObject]] object */
|
|
69
71
|
function isState(obj: any): boolean;
|
|
70
72
|
}
|
|
73
|
+
import { Glob } from "../common/glob";
|
|
@@ -89,9 +89,9 @@ export class StateRegistry {
|
|
|
89
89
|
* If the state has children, they are are also removed from the registry.
|
|
90
90
|
*
|
|
91
91
|
* @param stateOrName the state's name or object representation
|
|
92
|
-
* @returns {StateObject[]} a list of removed states
|
|
92
|
+
* @returns {import('./state-object').StateObject[]} a list of removed states
|
|
93
93
|
*/
|
|
94
|
-
deregister(stateOrName: any): StateObject[];
|
|
94
|
+
deregister(stateOrName: any): import("./state-object").StateObject[];
|
|
95
95
|
get(stateOrName: any, base: any, ...args: any[]): any;
|
|
96
96
|
/**
|
|
97
97
|
* Registers a [[BuilderFunction]] for a specific [[StateObject]] property (e.g., `parent`, `url`, or `path`).
|
|
@@ -218,7 +218,7 @@ export class Transition {
|
|
|
218
218
|
* @param resolvable a [[ResolvableLiteral]] object (or a [[Resolvable]])
|
|
219
219
|
* @param state the state in the "to path" which should receive the new resolve (otherwise, the root state)
|
|
220
220
|
*/
|
|
221
|
-
addResolvable(resolvable: any, state
|
|
221
|
+
addResolvable(resolvable: any, state: any): void;
|
|
222
222
|
/**
|
|
223
223
|
* Gets the transition from which this transition was redirected.
|
|
224
224
|
*
|
|
@@ -132,5 +132,10 @@ export class BaseUrlRule {
|
|
|
132
132
|
$id: number;
|
|
133
133
|
_group: any;
|
|
134
134
|
handler: any;
|
|
135
|
-
|
|
135
|
+
/**
|
|
136
|
+
* This function should be overridden
|
|
137
|
+
* @param {*} [params]
|
|
138
|
+
* @returns {number}
|
|
139
|
+
*/
|
|
140
|
+
matchPriority(params?: any): number;
|
|
136
141
|
}
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* A value is "injectable" if it is a function, or if it is an ng1 array-notation-style array
|
|
5
5
|
* where all the elements in the array are Strings, except the last one, which is a Function
|
|
6
|
+
* @param {*} val
|
|
7
|
+
* @returns {boolean}
|
|
6
8
|
*/
|
|
7
9
|
export function isInjectable(val: any): boolean;
|
|
8
10
|
export function isNull(o: any): boolean;
|