@angular-wave/angular.ts 0.0.48 → 0.0.50

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.
Files changed (38) hide show
  1. package/Makefile +3 -0
  2. package/README.md +1 -1
  3. package/css/angular.css +0 -6
  4. package/dist/angular-ts.esm.js +2 -2
  5. package/dist/angular-ts.umd.js +2 -2
  6. package/jsdoc.json +24 -0
  7. package/package.json +6 -2
  8. package/src/core/compile/compile.md +1 -1
  9. package/src/core/compile/compile.spec.js +50 -48
  10. package/src/core/interpolate/interpolate.js +1 -18
  11. package/src/core/on.spec.js +7 -12
  12. package/src/core/parser/ast.js +234 -69
  13. package/src/core/parser/interpreter.js +246 -50
  14. package/src/core/parser/lexer.js +144 -57
  15. package/src/core/parser/parse.js +38 -278
  16. package/src/core/parser/parse.md +44 -0
  17. package/src/core/parser/parser.js +32 -6
  18. package/src/core/parser/shared.js +7 -1
  19. package/src/core/prop.spec.js +4 -4
  20. package/src/core/scope/scope.js +14 -10
  21. package/src/directive/csp.md +0 -26
  22. package/src/directive/form/form.spec.js +18 -18
  23. package/src/directive/include/include.spec.js +18 -18
  24. package/src/directive/switch/switch.spec.js +4 -4
  25. package/src/shared/constants.js +3 -2
  26. package/src/shared/jqlite/jqlite.js +2 -2
  27. package/src/types.js +4 -1
  28. package/types/core/parser/ast.d.ts +269 -67
  29. package/types/core/parser/interpreter.d.ts +202 -53
  30. package/types/core/parser/lexer.d.ts +153 -0
  31. package/types/core/parser/parse.d.ts +23 -34
  32. package/types/core/parser/parser.d.ts +43 -14
  33. package/types/core/parser/shared.d.ts +7 -1
  34. package/types/core/scope/scope.d.ts +11 -11
  35. package/types/shared/jqlite/jqlite.d.ts +4 -4
  36. package/types/types.d.ts +1 -1
  37. package/src/core/parser/compiler.js +0 -561
  38. package/types/core/parser/compiler.d.ts +0 -49
@@ -0,0 +1,153 @@
1
+ /**
2
+ * @typedef {Object} LexerOptions
3
+ * @property {(ch: string, codePoint: number) => boolean} [isIdentifierStart] - Custom function to determine if a character is a valid identifier start.
4
+ * @property {(ch: string, codePoint: number) => boolean} [isIdentifierContinue] - Custom function to determine if a character is a valid identifier continuation.
5
+ */
6
+ /**
7
+ * Represents a token produced by the lexer.
8
+ * @typedef {Object} Token
9
+ * @property {number} index - Index of the token.
10
+ * @property {string} text - Text of the token.
11
+ * @property {boolean} [identifier] - Indicates if token is an identifier.
12
+ * @property {boolean} [constant] - Indicates if token is a constant.
13
+ * @property {string|number} [value] - Value of the token if it's a constant.
14
+ * @property {boolean} [operator] - Indicates if token is an operator.
15
+ */
16
+ /**
17
+ * Represents a lexer that tokenizes input text. The Lexer takes the original expression string and returns an array of tokens parsed from that string.
18
+ * For example, the string "a + b" would result in tokens for a, +, and b.
19
+ */
20
+ export class Lexer {
21
+ /**
22
+ * Creates an instance of Lexer.
23
+ * @param {LexerOptions} options - Lexer options.
24
+ */
25
+ constructor(options: LexerOptions);
26
+ /** @type {LexerOptions} */
27
+ options: LexerOptions;
28
+ /**
29
+ * Tokenizes the input text.
30
+ * @param {string} text Input text to lex.
31
+ * @returns {Array<Token>} Array of tokens.
32
+ */
33
+ lex(text: string): Array<Token>;
34
+ text: string;
35
+ index: number;
36
+ /** @type {Array<Token>} */
37
+ tokens: Array<Token>;
38
+ /**
39
+ * Checks if a character is contained in a set of characters.
40
+ * @param {string} ch Character to check.
41
+ * @param {string} chars Set of characters.
42
+ * @returns {boolean} True if character is in the set, false otherwise.
43
+ */
44
+ is(ch: string, chars: string): boolean;
45
+ /**
46
+ * Peeks at the next character in the text.
47
+ * @param {number} [i=1] Number of characters to peek.
48
+ * @returns {string|false} Next character or false if end of text.
49
+ */
50
+ peek(i?: number): string | false;
51
+ /**
52
+ * Checks if a character is a number.
53
+ * @param {string} ch Character to check.
54
+ * @returns {boolean} True if character is a number, false otherwise.
55
+ */
56
+ isNumber(ch: string): boolean;
57
+ /**
58
+ * Checks if a character is whitespace.
59
+ * @param {string} ch Character to check.
60
+ * @returns {boolean} True if character is whitespace, false otherwise.
61
+ */
62
+ isWhitespace(ch: string): boolean;
63
+ /**
64
+ * Checks if a character is a valid identifier start.
65
+ * @param {string} ch Character to check.
66
+ * @returns {boolean} True if character is a valid identifier start, false otherwise.
67
+ */
68
+ isIdentifierStart(ch: string): boolean;
69
+ /**
70
+ * Checks if a character is a valid identifier continuation.
71
+ * @param {string} ch Character to check.
72
+ * @returns {boolean} True if character is a valid identifier continuation, false otherwise.
73
+ */
74
+ isIdentifierContinue(ch: string): boolean;
75
+ /**
76
+ * Converts a character to its Unicode code point.
77
+ * @param {string} ch Character to convert.
78
+ * @returns {number} Unicode code point.
79
+ */
80
+ codePointAt(ch: string): number;
81
+ /**
82
+ * Peeks at the next multicharacter sequence in the text.
83
+ * @returns {string} Next multicharacter sequence.
84
+ */
85
+ peekMultichar(): string;
86
+ /**
87
+ * Checks if a character is an exponent operator.
88
+ * @param {string} ch Character to check.
89
+ * @returns {boolean} True if character is an exponent operator, false otherwise.
90
+ */
91
+ isExpOperator(ch: string): boolean;
92
+ /**
93
+ * Throws a lexer error.
94
+ * @param {string} error Error message.
95
+ * @param {number} [start] Start index.
96
+ * @param {number} [end] End index.
97
+ * @throws {Error} Lexer error.
98
+ */
99
+ throwError(error: string, start?: number, end?: number): void;
100
+ /**
101
+ * Reads and tokenizes a number from the text.
102
+ */
103
+ readNumber(): void;
104
+ /**
105
+ * Reads and tokenizes an identifier from the text.
106
+ */
107
+ readIdent(): void;
108
+ /**
109
+ * Reads and tokenizes a string from the text.
110
+ * @param {string} quote Quote character used for the string.
111
+ */
112
+ readString(quote: string): void;
113
+ handleUnicodeEscape(): string;
114
+ }
115
+ export type LexerOptions = {
116
+ /**
117
+ * - Custom function to determine if a character is a valid identifier start.
118
+ */
119
+ isIdentifierStart?: (ch: string, codePoint: number) => boolean;
120
+ /**
121
+ * - Custom function to determine if a character is a valid identifier continuation.
122
+ */
123
+ isIdentifierContinue?: (ch: string, codePoint: number) => boolean;
124
+ };
125
+ /**
126
+ * Represents a token produced by the lexer.
127
+ */
128
+ export type Token = {
129
+ /**
130
+ * - Index of the token.
131
+ */
132
+ index: number;
133
+ /**
134
+ * - Text of the token.
135
+ */
136
+ text: string;
137
+ /**
138
+ * - Indicates if token is an identifier.
139
+ */
140
+ identifier?: boolean;
141
+ /**
142
+ * - Indicates if token is a constant.
143
+ */
144
+ constant?: boolean;
145
+ /**
146
+ * - Value of the token if it's a constant.
147
+ */
148
+ value?: string | number;
149
+ /**
150
+ * - Indicates if token is an operator.
151
+ */
152
+ operator?: boolean;
153
+ };
@@ -1,12 +1,3 @@
1
- /**
2
- * @ngdoc provider
3
- * @name $parseProvider
4
- *
5
- *
6
- * @description
7
- * `$parseProvider` can be used for configuring the default behavior of the {@link ng.$parse $parse}
8
- * service.
9
- */
10
1
  export function $ParseProvider(): void;
11
2
  export class $ParseProvider {
12
3
  /**
@@ -22,11 +13,6 @@ export class $ParseProvider {
22
13
  **/
23
14
  addLiteral: (literalName: string, literalValue: any) => void;
24
15
  /**
25
- * @ngdoc method
26
- * @name $parseProvider#setIdentifierFns
27
- *
28
- * @description
29
- *
30
16
  * Allows defining the set of characters that are allowed in AngularJS expressions. The function
31
17
  * `identifierStart` will get called to know if a given character is a valid character to be the
32
18
  * first character for an identifier. The function `identifierContinue` will get called to know if
@@ -40,32 +26,34 @@ export class $ParseProvider {
40
26
  * Since this function will be called extensively, keep the implementation of these functions fast,
41
27
  * as the performance of these functions have a direct impact on the expressions parsing speed.
42
28
  *
43
- * @param {function=} identifierStart The function that will decide whether the given character is
29
+ * @param {function(any):boolean} [identifierStart] The function that will decide whether the given character is
44
30
  * a valid identifier start character.
45
- * @param {function=} identifierContinue The function that will decide whether the given character is
31
+ * @param {function(any):boolean} [identifierContinue] The function that will decide whether the given character is
46
32
  * a valid identifier continue character.
33
+ * @returns {$ParseProvider}
47
34
  */
48
- setIdentifierFns: (identifierStart?: Function | undefined, identifierContinue?: Function | undefined) => this;
35
+ setIdentifierFns: (identifierStart?: (arg0: any) => boolean, identifierContinue?: (arg0: any) => boolean) => $ParseProvider;
49
36
  $get: (string | (($filter: any) => {
50
37
  (exp: any, interceptorFn: any): any;
51
- $$getAst: (exp: any) => {
52
- type: string;
53
- body: {
54
- type: string;
55
- expression: any;
56
- }[];
57
- };
38
+ $$getAst: (exp: string) => import("./ast").ASTNode;
58
39
  }))[];
59
40
  }
60
- export function inputsWatchDelegate(scope: any, listener: any, objectEquality: any, parsedExpression: any): any;
61
- export function oneTimeWatchDelegate(scope: any, listener: any, objectEquality: any, parsedExpression: any): any;
62
- export function chainInterceptors(first: any, second: any): {
63
- (value: any): any;
64
- $stateful: any;
65
- $$pure: any;
66
- };
67
- export function expressionInputDirtyCheck(newValue: any, oldValueOfValue: any, compareObjectIdentity: any): boolean;
68
- export function isAllDefined(value: any): boolean;
41
+ export function constantWatchDelegate(scope: any, listener: any, objectEquality: any, parsedExpression: any): any;
42
+ /**
43
+ * @typedef {function} CompiledExpression
44
+ * @param {import('../scope/scope').Scope} context - An object against which any expressions embedded in the strings are evaluated against (typically a scope object).
45
+ * @param {object} [locals] - local variables context object, useful for overriding values in `context`.
46
+ * @returns {any}
47
+ * @property {boolean} literal - Indicates if the expression is a literal.
48
+ * @property {boolean} constant - Indicates if the expression is constant.
49
+ * @property {function(any, any): any} assign - Assigns a value to a context. If value is not provided,
50
+ * undefined is gonna be used since the implementation
51
+ * does not check the parameter. Let's force a value for consistency. If consumer
52
+ * wants to undefine it, pass the undefined value explicitly.
53
+ */
54
+ /**
55
+ * @typedef {function(string|function(import('../scope/scope').Scope):any, function(any, import('../scope/scope').Scope, any):any=, boolean=): CompiledExpression} ParseService
56
+ */
69
57
  export const $parseMinErr: (arg0: string, ...arg1: any[]) => Error;
70
58
  export namespace literals {
71
59
  let _true: boolean;
@@ -76,4 +64,5 @@ export namespace literals {
76
64
  export { _null as null };
77
65
  export let undefined: any;
78
66
  }
79
- export type ParseService = (arg0: string | ((arg0: import("../scope/scope").Scope) => any), arg1: ((arg0: any, arg1: Scope, arg2: any) => any) | undefined, arg2: boolean | undefined) => import("../../types").CompiledExpression;
67
+ export type CompiledExpression = Function;
68
+ export type ParseService = (arg0: string | ((arg0: import("../scope/scope").Scope) => any), arg1: ((arg0: any, arg1: import("../scope/scope").Scope, arg2: any) => any) | undefined, arg2: boolean | undefined) => CompiledExpression;
@@ -1,22 +1,51 @@
1
+ /**
2
+ * @typedef {Object} ParsedAST
3
+ * @property {import("./ast").ASTNode} ast - AST representation of expression
4
+ * @property {boolean} oneTime - True if expression should be evaluated only once
5
+ */
6
+ /**
7
+ * @typedef {Object} ParserOptions
8
+ * @property {function(string):any} literals
9
+ */
1
10
  /**
2
11
  * @constructor
3
12
  */
4
13
  export class Parser {
5
- constructor(lexer: any, $filter: any, options: any);
14
+ /**
15
+ *
16
+ * @param {import('./lexer').Lexer} lexer
17
+ * @param {function(any):any} $filter
18
+ * @param {ParserOptions} options
19
+ */
20
+ constructor(lexer: import("./lexer").Lexer, $filter: (arg0: any) => any, options: ParserOptions);
21
+ /** @type {AST} */
6
22
  ast: AST;
7
- astCompiler: ASTInterpreter | ASTCompiler;
8
- parse(text: any): any;
9
- getAst(exp: any): {
10
- ast: {
11
- type: string;
12
- body: {
13
- type: string;
14
- expression: any;
15
- }[];
16
- };
17
- oneTime: boolean;
18
- };
23
+ /** @type {ASTInterpreter} */
24
+ astCompiler: ASTInterpreter;
25
+ /**
26
+ *
27
+ * @param {string} exp - Expression to be parsed
28
+ * @returns
29
+ */
30
+ parse(exp: string): any;
31
+ /**
32
+ * @param {string} exp - Expression to be parsed
33
+ * @returns {ParsedAST}
34
+ */
35
+ getAst(exp: string): ParsedAST;
19
36
  }
37
+ export type ParsedAST = {
38
+ /**
39
+ * - AST representation of expression
40
+ */
41
+ ast: import("./ast").ASTNode;
42
+ /**
43
+ * - True if expression should be evaluated only once
44
+ */
45
+ oneTime: boolean;
46
+ };
47
+ export type ParserOptions = {
48
+ literals: (arg0: string) => any;
49
+ };
20
50
  import { AST } from "./ast";
21
51
  import { ASTInterpreter } from "./interpreter";
22
- import { ASTCompiler } from "./compiler";
@@ -11,7 +11,13 @@ export function ifDefined(v: any, d: any): any;
11
11
  export function plusFn(l: any, r: any): any;
12
12
  export function isStateless($filter: any, filterName: any): boolean;
13
13
  export function isPure(node: any, parentIsPure: any): any;
14
- export function findConstantAndWatchExpressions(ast: any, $filter: any, parentIsPure: any): void;
14
+ /**
15
+ * Decorates ast with constant, toWatch, and isPure properties
16
+ * @param {import("./ast").ASTNode} ast
17
+ * @param {function(any):any} $filter
18
+ * @param {*} parentIsPure
19
+ */
20
+ export function findConstantAndWatchExpressions(ast: import("./ast").ASTNode, $filter: (arg0: any) => any, parentIsPure: any): void;
15
21
  export function getInputs(body: any): any;
16
22
  export function isAssignable(ast: any): boolean;
17
23
  export function assignableAST(ast: any): {
@@ -61,7 +61,7 @@ export const $$applyAsyncQueue: Function[];
61
61
  *
62
62
  */
63
63
  export class $RootScopeProvider {
64
- $get: (string | ((exceptionHandler: import("../exception-handler").ErrorHandler, parse: angular.IParseService, browser: import("../../services/browser").Browser) => Scope))[];
64
+ $get: (string | ((exceptionHandler: import("../exception-handler").ErrorHandler, parse: import("../parser/parse").ParseService, browser: import("../../services/browser").Browser) => Scope))[];
65
65
  }
66
66
  /**
67
67
  * DESIGN NOTES
@@ -103,9 +103,9 @@ export class Scope {
103
103
  */
104
104
  $root: Scope | null;
105
105
  /**
106
- * @type {[]}
106
+ * @type {Array<any>}
107
107
  */
108
- $$watchers: [];
108
+ $$watchers: Array<any>;
109
109
  /**
110
110
  * @type {number}
111
111
  */
@@ -296,10 +296,10 @@ export class Scope {
296
296
  * values are examined for changes on every call to `$digest`.
297
297
  * - The `listener` is called whenever any expression in the `watchExpressions` array changes.
298
298
  *
299
- * @param {Array.<string|Function(scope)>} watchExpressions Array of expressions that will be individually
299
+ * @param {Array.<string|((Scope)=>any)>} watchExpressions Array of expressions that will be individually
300
300
  * watched using {@link ng.$rootScope.Scope#$watch $watch()}
301
301
  *
302
- * @param {function(newValues, oldValues, scope)} listener Callback called whenever the return value of any
302
+ * @param {function(any, any, Scope): any} listener Callback called whenever the return value of any
303
303
  * expression in `watchExpressions` changes
304
304
  * The `newValues` array contains the current values of the `watchExpressions`, with the indexes matching
305
305
  * those of `watchExpression`
@@ -308,7 +308,7 @@ export class Scope {
308
308
  * The `scope` refers to the current scope.
309
309
  * @returns {function()} Returns a de-registration function for all listeners.
310
310
  */
311
- $watchGroup(watchExpressions: any, listener: (arg0: any[], arg1: any[], arg2: scope) => any): () => any;
311
+ $watchGroup(watchExpressions: Array<string | ((Scope: any) => any)>, listener: (arg0: any, arg1: any, arg2: Scope) => any): () => any;
312
312
  /**
313
313
  * @ngdoc method
314
314
  * @name $rootScope.Scope#$watchCollection
@@ -327,12 +327,12 @@ export class Scope {
327
327
  *
328
328
  *
329
329
  *
330
- * @param {string|function(scope)} obj Evaluated as {@link guide/expression expression}. The
330
+ * @param {string|function(Scope):any} obj Evaluated as {@link guide/expression expression}. The
331
331
  * expression value should evaluate to an object or an array which is observed on each
332
332
  * {@link ng.$rootScope.Scope#$digest $digest} cycle. Any shallow change within the
333
333
  * collection will trigger a call to the `listener`.
334
334
  *
335
- * @param {function(newCollection, oldCollection, scope)} listener a callback function called
335
+ * @param {function(any[], any[], Scope):any} listener a callback function called
336
336
  * when a change is detected.
337
337
  * - The `newCollection` object is the newly modified data obtained from the `obj` expression
338
338
  * - The `oldCollection` object is a copy of the former collection data.
@@ -343,7 +343,7 @@ export class Scope {
343
343
  * @returns {function()} Returns a de-registration function for this listener. When the
344
344
  * de-registration function is executed, the internal watch operation is terminated.
345
345
  */
346
- $watchCollection(obj: string | ((arg0: scope) => any), listener: (arg0: newCollection, arg1: oldCollection, arg2: scope) => any): () => any;
346
+ $watchCollection(obj: string | ((arg0: Scope) => any), listener: (arg0: any[], arg1: any[], arg2: Scope) => any): () => any;
347
347
  /**
348
348
  * @ngdoc method
349
349
  * @name $rootScope.Scope#$digest
@@ -630,10 +630,10 @@ export class Scope {
630
630
  * - `defaultPrevented` - `{boolean}`: true if `preventDefault` was called.
631
631
  *
632
632
  * @param {string} name Event name to listen on.
633
- * @param {function(angular.IAngularEvent): any} listener Function to call when the event is emitted.
633
+ * @param {function(any): any} listener Function to call when the event is emitted witn angular.IAngularEvent
634
634
  * @returns {function()} Returns a deregistration function for this listener.
635
635
  */
636
- $on(name: string, listener: (arg0: angular.IAngularEvent) => any): () => any;
636
+ $on(name: string, listener: (arg0: any) => any): () => any;
637
637
  /**
638
638
  * @ngdoc method
639
639
  * @name $rootScope.Scope#$eval
@@ -66,16 +66,16 @@ export class JQLite {
66
66
  /**
67
67
  * Gets or sets data on a parent element
68
68
  * @param {string} name
69
- * @param {any} value
69
+ * @param {any} [value]
70
70
  * @returns {JQLite|any}
71
71
  */
72
- inheritedData(name: string, value: any): JQLite | any;
72
+ inheritedData(name: string, value?: any): JQLite | any;
73
73
  /**
74
74
  * Gets or sets innerHTML on the first element in JQLite collection
75
- * @param {string} value
75
+ * @param {string} [value]
76
76
  * @returns {JQLite|any|undefined}
77
77
  */
78
- html(value: string): JQLite | any | undefined;
78
+ html(value?: string): JQLite | any | undefined;
79
79
  /**
80
80
  * Get the combined text contents of each element in the JQLite collection
81
81
  * or set the text contents of all elements.
package/types/types.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export type BootstrapConfig = any;
2
2
  export type Injectable<T_1> = Function | Array<string | Function>;
3
- export type CompiledExpression = (arg0: any, arg1: any | undefined) => any;
3
+ export type CompiledExpression = Function;
4
4
  export type ComponentOptions = any;
5
5
  export type ControllerConstructor = Function;
6
6
  export type OnChangesObject = any;