@angular-wave/angular.ts 0.4.1 → 0.4.2

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 (45) hide show
  1. package/dist/angular-ts.esm.js +2 -2
  2. package/dist/angular-ts.umd.js +2 -2
  3. package/package.json +1 -1
  4. package/src/animations/animate-queue.js +5 -4
  5. package/src/animations/shared.js +3 -3
  6. package/src/core/compile/compile.js +1 -1
  7. package/src/core/interpolate/interpolate.js +2 -2
  8. package/src/core/{parser/lexer.html → parse/ast/ast.html} +1 -1
  9. package/src/core/{parser → parse/ast}/ast.js +43 -29
  10. package/src/core/parse/ast/ast.spec.js +1462 -0
  11. package/src/core/parse/ast/ast.test.js +10 -0
  12. package/src/core/{parser → parse}/interpreter.js +10 -10
  13. package/src/core/parse/lexer/lexer.html +18 -0
  14. package/src/core/{parser → parse/lexer}/lexer.js +1 -1
  15. package/src/core/{parser → parse/lexer}/lexer.spec.js +2 -2
  16. package/src/core/parse/lexer/lexer.test.js +10 -0
  17. package/src/core/{parser → parse}/parse.html +1 -1
  18. package/src/core/{parser → parse}/parse.js +5 -5
  19. package/src/core/{parser → parse}/parse.spec.js +6 -1725
  20. package/src/core/parse/parse.test.js +10 -0
  21. package/src/core/parse/parser/parser.html +18 -0
  22. package/src/core/{parser → parse/parser}/parser.js +6 -6
  23. package/src/core/parse/parser/parser.spec.js +8 -0
  24. package/src/core/parse/parser/parser.test.js +10 -0
  25. package/src/core/scope/scope.js +3 -3
  26. package/src/directive/class/class.js +1 -1
  27. package/src/directive/model/model.js +2 -2
  28. package/src/directive/validators/validators.js +3 -3
  29. package/src/public.js +1 -1
  30. package/types/animations/shared.d.ts +1 -1
  31. package/types/core/compile/compile.d.ts +1 -1
  32. package/types/core/interpolate/interpolate.d.ts +1 -1
  33. package/types/core/{parser → parse/ast}/ast.d.ts +17 -17
  34. package/types/core/{parser → parse}/interpreter.d.ts +7 -7
  35. package/types/core/{parser → parse/parser}/parser.d.ts +8 -8
  36. package/types/core/scope/scope.d.ts +3 -3
  37. package/types/directive/class/class.d.ts +3 -3
  38. package/types/directive/model/model.d.ts +6 -6
  39. package/types/directive/validators/validators.d.ts +3 -3
  40. package/src/core/parser/parser.test.js +0 -19
  41. /package/src/core/{parser → parse}/ast-type.js +0 -0
  42. /package/src/core/{parser → parse}/parse.md +0 -0
  43. /package/types/core/{parser → parse}/ast-type.d.ts +0 -0
  44. /package/types/core/{parser → parse/lexer}/lexer.d.ts +0 -0
  45. /package/types/core/{parser → parse}/parse.d.ts +0 -0
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@angular-wave/angular.ts",
3
3
  "description": "A modern, optimized and typesafe version of AngularJS",
4
4
  "license": "MIT",
5
- "version": "0.4.1",
5
+ "version": "0.4.2",
6
6
  "type": "module",
7
7
  "main": "dist/angular-ts.esm.js",
8
8
  "browser": "dist/angular-ts.umd.js",
@@ -195,12 +195,13 @@ export function AnimateQueueProvider($animateProvider) {
195
195
  // compiled. The $templateRequest.totalPendingRequests variable keeps track of
196
196
  // all of the remote templates being currently downloaded. If there are no
197
197
  // templates currently downloading then the watcher will still fire anyway.
198
+ $rootScope["$templateRequest"] = $templateRequest;
198
199
  const deregisterWatch = $rootScope.$watch(
199
- () => $templateRequest.totalPendingRequests === 0,
200
- (isEmpty) => {
201
- if (!isEmpty) return;
200
+ "$templateRequest.totalPendingRequests",
201
+ (val) => {
202
+ if (val !== 0) return;
202
203
  deregisterWatch();
203
-
204
+ $rootScope["$templateRequest"] = undefined;
204
205
  // Now that all templates have been downloaded, $animate will wait until
205
206
  // the post digest queue is empty before enabling animations. By having two
206
207
  // calls to $postDigest calls we can ensure that the flag is enabled at the
@@ -1,6 +1,6 @@
1
- import { forEach, isString, minErr, extend } from "../shared/utils";
2
- import { JQLite } from "../shared/jqlite/jqlite";
3
- import { ASTType } from "../core/parser/ast-type";
1
+ import { forEach, isString, minErr, extend } from "../shared/utils.js";
2
+ import { JQLite } from "../shared/jqlite/jqlite.js";
3
+ import { ASTType } from "../core/parse/ast-type.js";
4
4
 
5
5
  export const ADD_CLASS_SUFFIX = "-add";
6
6
  export const REMOVE_CLASS_SUFFIX = "-remove";
@@ -528,7 +528,7 @@ export function CompileProvider($provide, $$sanitizeUriProvider) {
528
528
  * @param {*} $interpolate
529
529
  * @param {import("../exception-handler").ErrorHandler} $exceptionHandler
530
530
  * @param {*} $templateRequest
531
- * @param {import("../parser/parse").ParseService} $parse
531
+ * @param {import("../parse/parse").ParseService} $parse
532
532
  * @param {*} $controller
533
533
  * @param {import('../scope/scope').Scope} $rootScope
534
534
  * @param {*} $sce
@@ -6,7 +6,7 @@ import {
6
6
  valueFn,
7
7
  extend,
8
8
  } from "../../shared/utils";
9
- import { constantWatchDelegate } from "../parser/parse";
9
+ import { constantWatchDelegate } from "../parse/parse.js";
10
10
 
11
11
  const $interpolateMinErr = minErr("$interpolate");
12
12
  function throwNoconcat(text) {
@@ -81,7 +81,7 @@ export class InterpolateProvider {
81
81
  "$sce",
82
82
  /**
83
83
  *
84
- * @param {import("../parser/parse").ParseService} $parse
84
+ * @param {import("../parse/parse").ParseService} $parse
85
85
  * @param {*} $sce
86
86
  * @returns
87
87
  */
@@ -10,7 +10,7 @@
10
10
  <script src="/jasmine/jasmine-5.1.2/jasmine-html.js"></script>
11
11
  <script src="/jasmine/jasmine-5.1.2/boot0.js"></script>
12
12
  <script src="/jasmine/jasmine-5.1.2/boot1.js"></script>
13
- <script type="module" src="/src/core/parser/lexer.spec.js"></script>
13
+ <script type="module" src="/src/core/parse/ast/ast.spec.js"></script>
14
14
  </head>
15
15
  <body>
16
16
  <div id="dummy"></div>
@@ -1,6 +1,6 @@
1
- import { isAssignable } from "./interpreter";
2
- import { ASTType } from "./ast-type";
3
- import { minErr } from "../../shared/utils";
1
+ import { isAssignable } from "../interpreter.js";
2
+ import { ASTType } from "../ast-type.js";
3
+ import { minErr } from "../../../shared/utils.js";
4
4
 
5
5
  const $parseMinErr = minErr("$parse");
6
6
 
@@ -48,10 +48,10 @@ export const literals = new Map(
48
48
  */
49
49
  export class AST {
50
50
  /**
51
- * @param {import('./lexer').Lexer} lexer - The lexer instance for tokenizing input
51
+ * @param {import('../lexer/lexer.js').Lexer} lexer - The lexer instance for tokenizing input
52
52
  */
53
53
  constructor(lexer) {
54
- /** @type {import('./lexer').Lexer} */
54
+ /** @type {import('../lexer/lexer.js').Lexer} */
55
55
  this.lexer = lexer;
56
56
  this.selfReferential = {
57
57
  this: { type: ASTType.ThisExpression },
@@ -202,7 +202,7 @@ export class AST {
202
202
  while ((token = this.expect("==", "!=", "===", "!=="))) {
203
203
  left = {
204
204
  type: ASTType.BinaryExpression,
205
- operator: /** @type {import("./lexer").Token} */ (token).text,
205
+ operator: /** @type {import("../lexer/lexer.js").Token} */ (token).text,
206
206
  left,
207
207
  right: this.relational(),
208
208
  };
@@ -220,7 +220,7 @@ export class AST {
220
220
  while ((token = this.expect("<", ">", "<=", ">="))) {
221
221
  left = {
222
222
  type: ASTType.BinaryExpression,
223
- operator: /** @type {import("./lexer").Token} */ (token).text,
223
+ operator: /** @type {import("../lexer/lexer.js").Token} */ (token).text,
224
224
  left,
225
225
  right: this.additive(),
226
226
  };
@@ -238,7 +238,7 @@ export class AST {
238
238
  while ((token = this.expect("+", "-"))) {
239
239
  left = {
240
240
  type: ASTType.BinaryExpression,
241
- operator: /** @type {import("./lexer").Token} */ (token).text,
241
+ operator: /** @type {import("../lexer/lexer.js").Token} */ (token).text,
242
242
  left,
243
243
  right: this.multiplicative(),
244
244
  };
@@ -256,7 +256,7 @@ export class AST {
256
256
  while ((token = this.expect("*", "/", "%"))) {
257
257
  left = {
258
258
  type: ASTType.BinaryExpression,
259
- operator: /** @type {import("./lexer").Token} */ (token).text,
259
+ operator: /** @type {import("../lexer/lexer.js").Token} */ (token).text,
260
260
  left,
261
261
  right: this.unary(),
262
262
  };
@@ -273,7 +273,7 @@ export class AST {
273
273
  if ((token = this.expect("+", "-", "!"))) {
274
274
  return {
275
275
  type: ASTType.UnaryExpression,
276
- operator: /** @type {import("./lexer").Token} */ (token).text,
276
+ operator: /** @type {import("../lexer/lexer.js").Token} */ (token).text,
277
277
  prefix: true,
278
278
  argument: this.unary(),
279
279
  };
@@ -297,40 +297,48 @@ export class AST {
297
297
  } else if (
298
298
  Object.prototype.hasOwnProperty.call(
299
299
  this.selfReferential,
300
- /** @type {import("./lexer").Token} */ (this.peek()).text,
300
+ /** @type {import("../lexer/lexer.js").Token} */ (this.peek()).text,
301
301
  )
302
302
  ) {
303
303
  primary = structuredClone(this.selfReferential[this.consume().text]);
304
304
  } else if (
305
- literals.has(/** @type {import("./lexer").Token} */ (this.peek()).text)
305
+ literals.has(
306
+ /** @type {import("../lexer/lexer.js").Token} */ (this.peek()).text,
307
+ )
306
308
  ) {
307
309
  primary = {
308
310
  type: ASTType.Literal,
309
311
  value: literals.get(this.consume().text),
310
312
  };
311
313
  } else if (
312
- /** @type {import("./lexer").Token} */ (this.peek()).identifier
314
+ /** @type {import("../lexer/lexer.js").Token} */ (this.peek()).identifier
313
315
  ) {
314
316
  primary = this.identifier();
315
- } else if (/** @type {import("./lexer").Token} */ (this.peek()).constant) {
317
+ } else if (
318
+ /** @type {import("../lexer/lexer.js").Token} */ (this.peek()).constant
319
+ ) {
316
320
  primary = this.constant();
317
321
  } else {
318
322
  this.throwError(
319
323
  "not a primary expression",
320
- /** @type {import("./lexer").Token} */ (this.peek()),
324
+ /** @type {import("../lexer/lexer.js").Token} */ (this.peek()),
321
325
  );
322
326
  }
323
327
 
324
328
  let next;
325
329
  while ((next = this.expect("(", "[", "."))) {
326
- if (/** @type {import("./lexer").Token} */ (next).text === "(") {
330
+ if (
331
+ /** @type {import("../lexer/lexer.js").Token} */ (next).text === "("
332
+ ) {
327
333
  primary = {
328
334
  type: ASTType.CallExpression,
329
335
  callee: primary,
330
336
  arguments: this.parseArguments(),
331
337
  };
332
338
  this.consume(")");
333
- } else if (/** @type {import("./lexer").Token} */ (next).text === "[") {
339
+ } else if (
340
+ /** @type {import("../lexer/lexer.js").Token} */ (next).text === "["
341
+ ) {
334
342
  primary = {
335
343
  type: ASTType.MemberExpression,
336
344
  object: primary,
@@ -338,7 +346,9 @@ export class AST {
338
346
  computed: true,
339
347
  };
340
348
  this.consume("]");
341
- } else if (/** @type {import("./lexer").Token} */ (next).text === ".") {
349
+ } else if (
350
+ /** @type {import("../lexer/lexer.js").Token} */ (next).text === "."
351
+ ) {
342
352
  primary = {
343
353
  type: ASTType.MemberExpression,
344
354
  object: primary,
@@ -447,13 +457,17 @@ export class AST {
447
457
  break;
448
458
  }
449
459
  property = { type: ASTType.Property, kind: "init" };
450
- if (/** @type {import("./lexer").Token} */ (this.peek()).constant) {
460
+ if (
461
+ /** @type {import("../lexer/lexer.js").Token} */ (this.peek())
462
+ .constant
463
+ ) {
451
464
  property.key = this.constant();
452
465
  property.computed = false;
453
466
  this.consume(":");
454
467
  property.value = this.assignment();
455
468
  } else if (
456
- /** @type {import("./lexer").Token} */ (this.peek()).identifier
469
+ /** @type {import("../lexer/lexer.js").Token} */ (this.peek())
470
+ .identifier
457
471
  ) {
458
472
  property.key = this.identifier();
459
473
  property.computed = false;
@@ -473,7 +487,7 @@ export class AST {
473
487
  } else {
474
488
  this.throwError(
475
489
  "invalid key",
476
- /** @type {import("./lexer").Token} */ (this.peek()),
490
+ /** @type {import("../lexer/lexer.js").Token} */ (this.peek()),
477
491
  );
478
492
  }
479
493
  properties.push(property);
@@ -487,7 +501,7 @@ export class AST {
487
501
  /**
488
502
  * Throws a syntax error.
489
503
  * @param {string} msg - The error message.
490
- * @param {import("./lexer").Token} [token] - The token that caused the error.
504
+ * @param {import("../lexer/lexer.js").Token} [token] - The token that caused the error.
491
505
  */
492
506
  throwError(msg, token) {
493
507
  throw $parseMinErr(
@@ -504,7 +518,7 @@ export class AST {
504
518
  /**
505
519
  * Consumes a token if it matches the expected type.
506
520
  * @param {string} [e1] - The expected token type.
507
- * @returns {import("./lexer").Token} The consumed token.
521
+ * @returns {import("../lexer/lexer.js").Token} The consumed token.
508
522
  */
509
523
  consume(e1) {
510
524
  if (this.tokens.length === 0) {
@@ -519,16 +533,16 @@ export class AST {
519
533
  if (!token) {
520
534
  this.throwError(
521
535
  `is unexpected, expecting [${e1}]`,
522
- /** @type {import("./lexer").Token} */ (this.peek()),
536
+ /** @type {import("../lexer/lexer.js").Token} */ (this.peek()),
523
537
  );
524
538
  } else {
525
- return /** @type {import("./lexer").Token} */ (token);
539
+ return /** @type {import("../lexer/lexer.js").Token} */ (token);
526
540
  }
527
541
  }
528
542
 
529
543
  /**
530
544
  * Returns the next token without consuming it.
531
- * @returns {import("./lexer").Token} The next token.
545
+ * @returns {import("../lexer/lexer.js").Token} The next token.
532
546
  */
533
547
  peekToken() {
534
548
  if (this.tokens.length === 0) {
@@ -544,7 +558,7 @@ export class AST {
544
558
  /**
545
559
  * Checks if the next token matches any of the expected types.
546
560
  * @param {...string} [expected] - The expected token types.
547
- * @returns {import('./lexer').Token|boolean} The next token if it matches, otherwise false.
561
+ * @returns {import('../lexer/lexer.js').Token|boolean} The next token if it matches, otherwise false.
548
562
  */
549
563
  peek(...expected) {
550
564
  return this.peekAhead(0, ...expected);
@@ -554,7 +568,7 @@ export class AST {
554
568
  * Checks if the token at the specified index matches any of the expected types.
555
569
  * @param {number} i - The index to check.
556
570
  * @param {...string} [expected] - The expected token types.
557
- * @returns {import("./lexer").Token|boolean} The token at the specified index if it matches, otherwise false.
571
+ * @returns {import("../lexer/lexer.js").Token|boolean} The token at the specified index if it matches, otherwise false.
558
572
  */
559
573
  peekAhead(i, ...expected) {
560
574
  if (this.tokens.length > i) {
@@ -573,7 +587,7 @@ export class AST {
573
587
  /**
574
588
  * Consumes the next token if it matches any of the expected types.
575
589
  * @param {...string} [expected] - The expected token types.
576
- * @returns {import("./lexer").Token|boolean} The consumed token if it matches, otherwise false.
590
+ * @returns {import("../lexer/lexer.js").Token|boolean} The consumed token if it matches, otherwise false.
577
591
  */
578
592
  expect(...expected) {
579
593
  const token = this.peek(...expected);