@angular/core 18.1.0-next.0 → 18.1.0-next.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 (48) hide show
  1. package/esm2022/primitives/event-dispatch/index.mjs +2 -1
  2. package/esm2022/primitives/event-dispatch/src/dispatcher.mjs +4 -3
  3. package/esm2022/primitives/event-dispatch/src/event_dispatcher.mjs +4 -6
  4. package/esm2022/primitives/event-dispatch/src/event_type.mjs +2 -2
  5. package/esm2022/primitives/signals/src/graph.mjs +6 -5
  6. package/esm2022/src/change_detection/scheduling/ng_zone_scheduling.mjs +2 -4
  7. package/esm2022/src/core.mjs +1 -1
  8. package/esm2022/src/core_private_export.mjs +2 -2
  9. package/esm2022/src/event_delegation_utils.mjs +68 -0
  10. package/esm2022/src/event_emitter.mjs +20 -11
  11. package/esm2022/src/hydration/annotate.mjs +18 -7
  12. package/esm2022/src/hydration/api.mjs +2 -2
  13. package/esm2022/src/hydration/event_replay.mjs +46 -69
  14. package/esm2022/src/hydration/tokens.mjs +6 -1
  15. package/esm2022/src/pending_tasks.mjs +15 -20
  16. package/esm2022/src/render3/after_render_hooks.mjs +67 -132
  17. package/esm2022/src/render3/component_ref.mjs +1 -1
  18. package/esm2022/src/render3/instructions/change_detection.mjs +27 -24
  19. package/esm2022/src/render3/instructions/listener.mjs +5 -5
  20. package/esm2022/src/render3/instructions/shared.mjs +3 -3
  21. package/esm2022/src/render3/reactive_lview_consumer.mjs +56 -3
  22. package/esm2022/src/version.mjs +1 -1
  23. package/esm2022/testing/src/logger.mjs +3 -3
  24. package/fesm2022/core.mjs +474 -432
  25. package/fesm2022/core.mjs.map +1 -1
  26. package/fesm2022/primitives/event-dispatch.mjs +9 -10
  27. package/fesm2022/primitives/event-dispatch.mjs.map +1 -1
  28. package/fesm2022/primitives/signals.mjs +6 -5
  29. package/fesm2022/primitives/signals.mjs.map +1 -1
  30. package/fesm2022/rxjs-interop.mjs +1 -1
  31. package/fesm2022/testing.mjs +1 -1
  32. package/index.d.ts +218 -28
  33. package/package.json +2 -2
  34. package/primitives/event-dispatch/index.d.ts +66 -1
  35. package/primitives/signals/index.d.ts +1 -1
  36. package/rxjs-interop/index.d.ts +1 -1
  37. package/schematics/migrations/after-render-phase/bundle.js +602 -0
  38. package/schematics/migrations/after-render-phase/bundle.js.map +7 -0
  39. package/schematics/migrations/http-providers/bundle.js +10 -2
  40. package/schematics/migrations/http-providers/bundle.js.map +2 -2
  41. package/schematics/migrations/invalid-two-way-bindings/bundle.js +177 -8
  42. package/schematics/migrations/invalid-two-way-bindings/bundle.js.map +3 -3
  43. package/schematics/migrations.json +5 -0
  44. package/schematics/ng-generate/control-flow-migration/bundle.js +192 -16
  45. package/schematics/ng-generate/control-flow-migration/bundle.js.map +3 -3
  46. package/schematics/ng-generate/standalone-migration/bundle.js +9197 -9490
  47. package/schematics/ng-generate/standalone-migration/bundle.js.map +4 -4
  48. package/testing/index.d.ts +1 -1
@@ -4563,6 +4563,18 @@ var UnknownBlock = class {
4563
4563
  return visitor.visitUnknownBlock(this);
4564
4564
  }
4565
4565
  };
4566
+ var LetDeclaration = class {
4567
+ constructor(name, value, sourceSpan, nameSpan, valueSpan) {
4568
+ this.name = name;
4569
+ this.value = value;
4570
+ this.sourceSpan = sourceSpan;
4571
+ this.nameSpan = nameSpan;
4572
+ this.valueSpan = valueSpan;
4573
+ }
4574
+ visit(visitor) {
4575
+ return visitor.visitLetDeclaration(this);
4576
+ }
4577
+ };
4566
4578
  var Template = class {
4567
4579
  constructor(tagName, attributes, inputs, outputs, templateAttrs, children, references, variables, sourceSpan, startSourceSpan, endSourceSpan, i18n2) {
4568
4580
  this.tagName = tagName;
@@ -4703,6 +4715,8 @@ var RecursiveVisitor = class {
4703
4715
  }
4704
4716
  visitUnknownBlock(block) {
4705
4717
  }
4718
+ visitLetDeclaration(decl) {
4719
+ }
4706
4720
  };
4707
4721
  function visitAll(visitor, nodes) {
4708
4722
  const result = [];
@@ -11024,6 +11038,18 @@ var BlockParameter = class {
11024
11038
  return visitor.visitBlockParameter(this, context);
11025
11039
  }
11026
11040
  };
11041
+ var LetDeclaration2 = class {
11042
+ constructor(name, value, sourceSpan, nameSpan, valueSpan) {
11043
+ this.name = name;
11044
+ this.value = value;
11045
+ this.sourceSpan = sourceSpan;
11046
+ this.nameSpan = nameSpan;
11047
+ this.valueSpan = valueSpan;
11048
+ }
11049
+ visit(visitor, context) {
11050
+ return visitor.visitLetDeclaration(this, context);
11051
+ }
11052
+ };
11027
11053
  function visitAll2(visitor, nodes, context = null) {
11028
11054
  const result = [];
11029
11055
  const visit = visitor.visit ? (ast) => visitor.visit(ast, context) || ast.visit(visitor, context) : (ast) => ast.visit(visitor, context);
@@ -11852,6 +11878,9 @@ var _I18nVisitor = class {
11852
11878
  visitBlockParameter(_parameter, _context) {
11853
11879
  throw new Error("Unreachable code");
11854
11880
  }
11881
+ visitLetDeclaration(decl, context) {
11882
+ return null;
11883
+ }
11855
11884
  _visitTextWithInterpolation(tokens, sourceSpan, context, previousI18n) {
11856
11885
  const nodes = [];
11857
11886
  let hasInterpolation = false;
@@ -14123,6 +14152,7 @@ var _Tokenizer = class {
14123
14152
  this._preserveLineEndings = options.preserveLineEndings || false;
14124
14153
  this._i18nNormalizeLineEndingsInICUs = options.i18nNormalizeLineEndingsInICUs || false;
14125
14154
  this._tokenizeBlocks = (_a2 = options.tokenizeBlocks) != null ? _a2 : true;
14155
+ this._tokenizeLet = options.tokenizeLet || false;
14126
14156
  try {
14127
14157
  this._cursor.init();
14128
14158
  } catch (e) {
@@ -14153,6 +14183,8 @@ var _Tokenizer = class {
14153
14183
  } else {
14154
14184
  this._consumeTagOpen(start);
14155
14185
  }
14186
+ } else if (this._tokenizeLet && this._cursor.peek() === $AT && !this._inInterpolation && this._attemptStr("@let")) {
14187
+ this._consumeLetDeclaration(start);
14156
14188
  } else if (this._tokenizeBlocks && this._attemptCharCode($AT)) {
14157
14189
  this._consumeBlockStart(start);
14158
14190
  } else if (this._tokenizeBlocks && !this._inInterpolation && !this._isInExpansionCase() && !this._isInExpansionForm() && this._attemptCharCode($RBRACE)) {
@@ -14164,7 +14196,7 @@ var _Tokenizer = class {
14164
14196
  this.handleError(e);
14165
14197
  }
14166
14198
  }
14167
- this._beginToken(29);
14199
+ this._beginToken(33);
14168
14200
  this._endToken([]);
14169
14201
  }
14170
14202
  _getBlockName() {
@@ -14237,6 +14269,67 @@ var _Tokenizer = class {
14237
14269
  this._attemptCharCodeUntilFn(isBlockParameterChar);
14238
14270
  }
14239
14271
  }
14272
+ _consumeLetDeclaration(start) {
14273
+ this._beginToken(29, start);
14274
+ if (isWhitespace(this._cursor.peek())) {
14275
+ this._attemptCharCodeUntilFn(isNotWhitespace);
14276
+ } else {
14277
+ const token = this._endToken([this._cursor.getChars(start)]);
14278
+ token.type = 32;
14279
+ return;
14280
+ }
14281
+ const startToken = this._endToken([this._getLetDeclarationName()]);
14282
+ this._attemptCharCodeUntilFn(isNotWhitespace);
14283
+ if (!this._attemptCharCode($EQ)) {
14284
+ startToken.type = 32;
14285
+ return;
14286
+ }
14287
+ this._attemptCharCodeUntilFn((code) => isNotWhitespace(code) && !isNewLine(code));
14288
+ this._consumeLetDeclarationValue();
14289
+ const endChar = this._cursor.peek();
14290
+ if (endChar === $SEMICOLON) {
14291
+ this._beginToken(31);
14292
+ this._endToken([]);
14293
+ this._cursor.advance();
14294
+ } else {
14295
+ startToken.type = 32;
14296
+ startToken.sourceSpan = this._cursor.getSpan(start);
14297
+ }
14298
+ }
14299
+ _getLetDeclarationName() {
14300
+ const nameCursor = this._cursor.clone();
14301
+ let allowDigit = false;
14302
+ this._attemptCharCodeUntilFn((code) => {
14303
+ if (isAsciiLetter(code) || code === $_ || allowDigit && isDigit(code)) {
14304
+ allowDigit = true;
14305
+ return false;
14306
+ }
14307
+ return true;
14308
+ });
14309
+ return this._cursor.getChars(nameCursor).trim();
14310
+ }
14311
+ _consumeLetDeclarationValue() {
14312
+ const start = this._cursor.clone();
14313
+ this._beginToken(30, start);
14314
+ while (this._cursor.peek() !== $EOF) {
14315
+ const char = this._cursor.peek();
14316
+ if (char === $SEMICOLON) {
14317
+ break;
14318
+ }
14319
+ if (isQuote(char)) {
14320
+ this._cursor.advance();
14321
+ this._attemptCharCodeUntilFn((inner) => {
14322
+ if (inner === $BACKSLASH) {
14323
+ this._cursor.advance();
14324
+ return false;
14325
+ }
14326
+ return inner === char;
14327
+ });
14328
+ }
14329
+ this._cursor.advance();
14330
+ }
14331
+ this._endToken([this._cursor.getChars(start)]);
14332
+ }
14240
14333
  _tokenizeExpansionForm() {
14241
14334
  if (this.isExpansionFormStart()) {
14242
14335
  this._consumeExpansionFormStart();
@@ -15023,7 +15116,7 @@ var _TreeBuilder = class {
15023
15116
  this._advance();
15024
15117
  }
15025
15118
  build() {
15026
- while (this._peek.type !== 29) {
15119
+ while (this._peek.type !== 33) {
15027
15120
  if (this._peek.type === 0 || this._peek.type === 4) {
15028
15121
  this._consumeStartTag(this._advance());
15029
15122
  } else if (this._peek.type === 3) {
@@ -15048,6 +15141,12 @@ var _TreeBuilder = class {
15048
15141
  } else if (this._peek.type === 28) {
15049
15142
  this._closeVoidElement();
15050
15143
  this._consumeIncompleteBlock(this._advance());
15144
+ } else if (this._peek.type === 29) {
15145
+ this._closeVoidElement();
15146
+ this._consumeLet(this._advance());
15147
+ } else if (this._peek.type === 32) {
15148
+ this._closeVoidElement();
15149
+ this._consumeIncompleteLet(this._advance());
15051
15150
  } else {
15052
15151
  this._advance();
15053
15152
  }
@@ -15112,7 +15211,7 @@ var _TreeBuilder = class {
15112
15211
  if (!exp)
15113
15212
  return null;
15114
15213
  const end = this._advance();
15115
- exp.push({ type: 29, parts: [], sourceSpan: end.sourceSpan });
15214
+ exp.push({ type: 33, parts: [], sourceSpan: end.sourceSpan });
15116
15215
  const expansionCaseParser = new _TreeBuilder(exp, this.getTagDefinition);
15117
15216
  expansionCaseParser.build();
15118
15217
  if (expansionCaseParser.errors.length > 0) {
@@ -15148,7 +15247,7 @@ var _TreeBuilder = class {
15148
15247
  return null;
15149
15248
  }
15150
15249
  }
15151
- if (this._peek.type === 29) {
15250
+ if (this._peek.type === 33) {
15152
15251
  this.errors.push(TreeError.create(null, start.sourceSpan, `Invalid ICU message. Missing '}'.`));
15153
15252
  return null;
15154
15253
  }
@@ -15320,6 +15419,44 @@ var _TreeBuilder = class {
15320
15419
  this._popContainer(null, Block, null);
15321
15420
  this.errors.push(TreeError.create(token.parts[0], span, `Incomplete block "${token.parts[0]}". If you meant to write the @ character, you should use the "@" HTML entity instead.`));
15322
15421
  }
15422
+ _consumeLet(startToken) {
15423
+ const name = startToken.parts[0];
15424
+ let valueToken;
15425
+ let endToken;
15426
+ if (this._peek.type !== 30) {
15427
+ this.errors.push(TreeError.create(startToken.parts[0], startToken.sourceSpan, `Invalid @let declaration "${name}". Declaration must have a value.`));
15428
+ return;
15429
+ } else {
15430
+ valueToken = this._advance();
15431
+ }
15432
+ if (this._peek.type !== 31) {
15433
+ this.errors.push(TreeError.create(startToken.parts[0], startToken.sourceSpan, `Unterminated @let declaration "${name}". Declaration must be terminated with a semicolon.`));
15434
+ return;
15435
+ } else {
15436
+ endToken = this._advance();
15437
+ }
15438
+ const end = endToken.sourceSpan.fullStart;
15439
+ const span = new ParseSourceSpan(startToken.sourceSpan.start, end, startToken.sourceSpan.fullStart);
15440
+ const startOffset = startToken.sourceSpan.toString().lastIndexOf(name);
15441
+ const nameStart = startToken.sourceSpan.start.moveBy(startOffset);
15442
+ const nameSpan = new ParseSourceSpan(nameStart, startToken.sourceSpan.end);
15443
+ const node = new LetDeclaration2(name, valueToken.parts[0], span, nameSpan, valueToken.sourceSpan);
15444
+ this._addToParent(node);
15445
+ }
15446
+ _consumeIncompleteLet(token) {
15447
+ var _a2;
15448
+ const name = (_a2 = token.parts[0]) != null ? _a2 : "";
15449
+ const nameString = name ? ` "${name}"` : "";
15450
+ if (name.length > 0) {
15451
+ const startOffset = token.sourceSpan.toString().lastIndexOf(name);
15452
+ const nameStart = token.sourceSpan.start.moveBy(startOffset);
15453
+ const nameSpan = new ParseSourceSpan(nameStart, token.sourceSpan.end);
15454
+ const valueSpan = new ParseSourceSpan(token.sourceSpan.start, token.sourceSpan.start.moveBy(0));
15455
+ const node = new LetDeclaration2(name, "", token.sourceSpan, nameSpan, valueSpan);
15456
+ this._addToParent(node);
15457
+ }
15458
+ this.errors.push(TreeError.create(token.parts[0], token.sourceSpan, `Incomplete @let declaration${nameString}. @let declarations must be written as \`@let <name> = <value>;\``));
15459
+ }
15323
15460
  _getContainer() {
15324
15461
  return this._containerStack.length > 0 ? this._containerStack[this._containerStack.length - 1] : null;
15325
15462
  }
@@ -15492,6 +15629,9 @@ var I18nMetaVisitor = class {
15492
15629
  visitBlockParameter(parameter, context) {
15493
15630
  return parameter;
15494
15631
  }
15632
+ visitLetDeclaration(decl, context) {
15633
+ return decl;
15634
+ }
15495
15635
  _parseMetadata(meta) {
15496
15636
  return typeof meta === "string" ? parseI18nMeta(meta) : meta instanceof Message ? meta : {};
15497
15637
  }
@@ -18942,6 +19082,7 @@ function ingestNodes(unit, template2) {
18942
19082
  ingestIcu(unit, node);
18943
19083
  } else if (node instanceof ForLoopBlock) {
18944
19084
  ingestForBlock(unit, node);
19085
+ } else if (node instanceof LetDeclaration) {
18945
19086
  } else {
18946
19087
  throw new Error(`Unsupported template node: ${node.constructor.name}`);
18947
19088
  }
@@ -19766,6 +19907,9 @@ var WhitespaceVisitor = class {
19766
19907
  visitBlockParameter(parameter, context) {
19767
19908
  return parameter;
19768
19909
  }
19910
+ visitLetDeclaration(decl, context) {
19911
+ return decl;
19912
+ }
19769
19913
  };
19770
19914
  function createWhitespaceProcessedTextToken({ type, parts, sourceSpan }) {
19771
19915
  return { type, parts: [processWhitespace(parts[0])], sourceSpan };
@@ -21115,6 +21259,13 @@ var HtmlAstToIvyAst = class {
21115
21259
  }
21116
21260
  return null;
21117
21261
  }
21262
+ visitLetDeclaration(decl, context) {
21263
+ const value = this.bindingParser.parseBinding(decl.value, false, decl.valueSpan, decl.valueSpan.start.offset);
21264
+ if (value.errors.length === 0 && value.ast instanceof EmptyExpr) {
21265
+ this.reportError("@let declaration value cannot be empty", decl.valueSpan);
21266
+ }
21267
+ return new LetDeclaration(decl.name, value, decl.sourceSpan, decl.nameSpan, decl.valueSpan);
21268
+ }
21118
21269
  visitBlockParameter() {
21119
21270
  return null;
21120
21271
  }
@@ -21381,6 +21532,9 @@ var NonBindableVisitor = class {
21381
21532
  visitBlockParameter(parameter, context) {
21382
21533
  return null;
21383
21534
  }
21535
+ visitLetDeclaration(decl, context) {
21536
+ return new Text(`@let ${decl.name} = ${decl.value};`, decl.sourceSpan);
21537
+ }
21384
21538
  };
21385
21539
  var NON_BINDABLE_VISITOR = new NonBindableVisitor();
21386
21540
  function normalizeAttributeName(attrName) {
@@ -21400,7 +21554,7 @@ function textContents(node) {
21400
21554
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/render3/view/template.mjs
21401
21555
  var LEADING_TRIVIA_CHARS = [" ", "\n", "\r", " "];
21402
21556
  function parseTemplate(template2, templateUrl, options = {}) {
21403
- var _a2;
21557
+ var _a2, _b2;
21404
21558
  const { interpolationConfig, preserveWhitespaces, enableI18nLegacyMessageIdFormat, allowInvalidAssignmentEvents } = options;
21405
21559
  const bindingParser = makeBindingParser(interpolationConfig, allowInvalidAssignmentEvents);
21406
21560
  const htmlParser = new HtmlParser();
@@ -21408,7 +21562,8 @@ function parseTemplate(template2, templateUrl, options = {}) {
21408
21562
  leadingTriviaChars: LEADING_TRIVIA_CHARS
21409
21563
  }, options), {
21410
21564
  tokenizeExpansionForms: true,
21411
- tokenizeBlocks: (_a2 = options.enableBlockSyntax) != null ? _a2 : true
21565
+ tokenizeBlocks: (_a2 = options.enableBlockSyntax) != null ? _a2 : true,
21566
+ tokenizeLet: (_b2 = options.enableLetSyntax) != null ? _b2 : false
21412
21567
  }));
21413
21568
  if (!options.alwaysAttemptHtmlToR3AstConversion && parseResult.errors && parseResult.errors.length > 0) {
21414
21569
  const parsedTemplate2 = {
@@ -21948,6 +22103,9 @@ var Scope2 = class {
21948
22103
  visitContent(content) {
21949
22104
  this.ingestScopedNode(content);
21950
22105
  }
22106
+ visitLetDeclaration(decl) {
22107
+ this.maybeDeclare(decl);
22108
+ }
21951
22109
  visitBoundAttribute(attr) {
21952
22110
  }
21953
22111
  visitBoundEvent(event) {
@@ -22125,6 +22283,8 @@ var DirectiveBinder = class {
22125
22283
  }
22126
22284
  visitUnknownBlock(block) {
22127
22285
  }
22286
+ visitLetDeclaration(decl) {
22287
+ }
22128
22288
  };
22129
22289
  var TemplateBinder = class extends RecursiveAstVisitor {
22130
22290
  constructor(bindings, symbols, usedPipes, eagerPipes, deferBlocks, nestingLevel, scope, rootNode, level) {
@@ -22281,6 +22441,12 @@ var TemplateBinder = class extends RecursiveAstVisitor {
22281
22441
  visitBoundText(text2) {
22282
22442
  text2.value.visit(this);
22283
22443
  }
22444
+ visitLetDeclaration(decl) {
22445
+ decl.value.visit(this);
22446
+ if (this.rootNode !== null) {
22447
+ this.symbols.set(decl, this.rootNode);
22448
+ }
22449
+ }
22284
22450
  visitPipe(ast, context) {
22285
22451
  this.usedPipes.add(ast.name);
22286
22452
  if (!this.scope.isDeferred) {
@@ -22309,7 +22475,10 @@ var TemplateBinder = class extends RecursiveAstVisitor {
22309
22475
  if (!(ast.receiver instanceof ImplicitReceiver)) {
22310
22476
  return;
22311
22477
  }
22312
- let target = this.scope.lookup(name);
22478
+ const target = this.scope.lookup(name);
22479
+ if (target instanceof LetDeclaration && ast.receiver instanceof ThisReceiver) {
22480
+ return;
22481
+ }
22313
22482
  if (target !== null) {
22314
22483
  this.bindings.set(ast, target);
22315
22484
  }
@@ -23046,7 +23215,7 @@ function publishFacade(global) {
23046
23215
  }
23047
23216
 
23048
23217
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/version.mjs
23049
- var VERSION2 = new Version("18.1.0-next.0");
23218
+ var VERSION2 = new Version("18.1.0-next.2");
23050
23219
 
23051
23220
  // bazel-out/darwin_arm64-fastbuild/bin/packages/compiler/src/i18n/extractor_merger.mjs
23052
23221
  var _VisitorMode;