@angular/compiler 17.2.0-next.1 → 17.2.0-rc.1

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 (50) hide show
  1. package/esm2022/src/compiler_util/expression_converter.mjs +98 -25
  2. package/esm2022/src/constant_pool.mjs +14 -4
  3. package/esm2022/src/expression_parser/ast.mjs +1 -3
  4. package/esm2022/src/expression_parser/parser.mjs +8 -27
  5. package/esm2022/src/render3/partial/class_metadata.mjs +1 -1
  6. package/esm2022/src/render3/partial/directive.mjs +1 -1
  7. package/esm2022/src/render3/partial/factory.mjs +1 -1
  8. package/esm2022/src/render3/partial/injectable.mjs +1 -1
  9. package/esm2022/src/render3/partial/injector.mjs +1 -1
  10. package/esm2022/src/render3/partial/ng_module.mjs +1 -1
  11. package/esm2022/src/render3/partial/pipe.mjs +1 -1
  12. package/esm2022/src/render3/r3_class_metadata_compiler.mjs +5 -3
  13. package/esm2022/src/render3/r3_identifiers.mjs +6 -1
  14. package/esm2022/src/render3/r3_template_transform.mjs +2 -2
  15. package/esm2022/src/render3/view/api.mjs +1 -1
  16. package/esm2022/src/render3/view/compiler.mjs +3 -3
  17. package/esm2022/src/render3/view/template.mjs +18 -8
  18. package/esm2022/src/render3/view/util.mjs +3 -1
  19. package/esm2022/src/template/pipeline/ir/src/enums.mjs +27 -11
  20. package/esm2022/src/template/pipeline/ir/src/expression.mjs +32 -1
  21. package/esm2022/src/template/pipeline/ir/src/ops/create.mjs +19 -1
  22. package/esm2022/src/template/pipeline/ir/src/ops/update.mjs +22 -1
  23. package/esm2022/src/template/pipeline/src/compilation.mjs +2 -2
  24. package/esm2022/src/template/pipeline/src/emit.mjs +3 -1
  25. package/esm2022/src/template/pipeline/src/ingest.mjs +54 -13
  26. package/esm2022/src/template/pipeline/src/instruction.mjs +14 -1
  27. package/esm2022/src/template/pipeline/src/phases/attribute_extraction.mjs +15 -1
  28. package/esm2022/src/template/pipeline/src/phases/binding_specialization.mjs +11 -1
  29. package/esm2022/src/template/pipeline/src/phases/chaining.mjs +3 -1
  30. package/esm2022/src/template/pipeline/src/phases/const_collection.mjs +12 -5
  31. package/esm2022/src/template/pipeline/src/phases/create_defer_deps_fns.mjs +4 -2
  32. package/esm2022/src/template/pipeline/src/phases/generate_variables.mjs +2 -1
  33. package/esm2022/src/template/pipeline/src/phases/naming.mjs +14 -2
  34. package/esm2022/src/template/pipeline/src/phases/next_context_merging.mjs +2 -2
  35. package/esm2022/src/template/pipeline/src/phases/ordering.mjs +14 -5
  36. package/esm2022/src/template/pipeline/src/phases/reify.mjs +9 -1
  37. package/esm2022/src/template/pipeline/src/phases/resolve_contexts.mjs +2 -1
  38. package/esm2022/src/template/pipeline/src/phases/resolve_dollar_event.mjs +6 -3
  39. package/esm2022/src/template/pipeline/src/phases/resolve_names.mjs +3 -2
  40. package/esm2022/src/template/pipeline/src/phases/save_restore_view.mjs +2 -2
  41. package/esm2022/src/template/pipeline/src/phases/temporary_variables.mjs +2 -2
  42. package/esm2022/src/template/pipeline/src/phases/transform_two_way_binding_set.mjs +79 -0
  43. package/esm2022/src/template/pipeline/src/phases/var_counting.mjs +4 -1
  44. package/esm2022/src/template/pipeline/src/phases/variable_optimization.mjs +3 -3
  45. package/esm2022/src/template_parser/binding_parser.mjs +35 -8
  46. package/esm2022/src/version.mjs +1 -1
  47. package/fesm2022/compiler.mjs +511 -122
  48. package/fesm2022/compiler.mjs.map +1 -1
  49. package/index.d.ts +40 -219
  50. package/package.json +2 -2
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v17.2.0-next.1
2
+ * @license Angular v17.2.0-rc.1
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -157,12 +157,12 @@ export declare abstract class ASTWithName extends AST {
157
157
  constructor(span: ParseSpan, sourceSpan: AbsoluteSourceSpan, nameSpan: AbsoluteSourceSpan);
158
158
  }
159
159
 
160
- export declare class ASTWithSource extends AST {
161
- ast: AST;
160
+ export declare class ASTWithSource<T extends AST = AST> extends AST {
161
+ ast: T;
162
162
  source: string | null;
163
163
  location: string;
164
164
  errors: ParserError[];
165
- constructor(ast: AST, source: string | null, location: string, absoluteOffset: number, errors: ParserError[]);
165
+ constructor(ast: T, source: string | null, location: string, absoluteOffset: number, errors: ParserError[]);
166
166
  visit(visitor: AstVisitor, context?: any): any;
167
167
  toString(): string;
168
168
  }
@@ -420,6 +420,11 @@ declare class BindingParser {
420
420
  * @param isAttr true when binding to an attribute
421
421
  */
422
422
  private _validatePropertyOrAttributeName;
423
+ /**
424
+ * Returns whether a parsed AST is allowed to be used within the event side of a two-way binding.
425
+ * @param ast Parsed AST to be checked.
426
+ */
427
+ private _isAllowedAssignmentEvent;
423
428
  }
424
429
 
425
430
  export declare class BindingPipe extends ASTWithName {
@@ -692,7 +697,10 @@ export declare type CompileClassMetadataFn = (metadata: R3ClassMetadata) => outp
692
697
  * Similar to the `setClassMetadata` call, it's wrapped into the `ngDevMode`
693
698
  * check to tree-shake away this code in production mode.
694
699
  */
695
- export declare function compileComponentClassMetadata(metadata: R3ClassMetadata, deferrableTypes: Map<string, string> | null): outputAst.Expression;
700
+ export declare function compileComponentClassMetadata(metadata: R3ClassMetadata, deferrableTypes: Map<string, {
701
+ importPath: string;
702
+ isDefaultImport: boolean;
703
+ }> | null): outputAst.Expression;
696
704
 
697
705
  /**
698
706
  * Compile a component for the render3 runtime as defined by the `R3ComponentMetadata`.
@@ -800,6 +808,13 @@ export declare class ConstantPool {
800
808
  private literals;
801
809
  private literalFactories;
802
810
  private sharedConstants;
811
+ /**
812
+ * Constant pool also tracks claimed names from {@link uniqueName}.
813
+ * This is useful to avoid collisions if variables are intended to be
814
+ * named a certain way- but may conflict. We wouldn't want to always suffix
815
+ * them with unique numbers.
816
+ */
817
+ private _claimedNames;
803
818
  private nextNameIndex;
804
819
  constructor(isClosureCompilerEnabled?: boolean);
805
820
  getConstLiteral(literal: outputAst.Expression, forceShared?: boolean): outputAst.Expression;
@@ -811,13 +826,13 @@ export declare class ConstantPool {
811
826
  getSharedFunctionReference(fn: outputAst.FunctionExpr | outputAst.ArrowFunctionExpr, prefix: string, useUniqueName?: boolean): outputAst.Expression;
812
827
  private _getLiteralFactory;
813
828
  /**
814
- * Produce a unique name.
829
+ * Produce a unique name in the context of this pool.
815
830
  *
816
831
  * The name might be unique among different prefixes if any of the prefixes end in
817
832
  * a digit so the prefix should be a constant string (not based on user input) and
818
833
  * must not end in a digit.
819
834
  */
820
- uniqueName(prefix: string): string;
835
+ uniqueName(name: string, alwaysIncludeSuffix?: boolean): string;
821
836
  private freshName;
822
837
  }
823
838
 
@@ -2218,210 +2233,6 @@ declare namespace outputAst {
2218
2233
  }
2219
2234
  export { outputAst }
2220
2235
 
2221
- export declare class _ParseAST {
2222
- input: string;
2223
- location: string;
2224
- absoluteOffset: number;
2225
- tokens: Token[];
2226
- parseFlags: ParseFlags;
2227
- private errors;
2228
- private offset;
2229
- private rparensExpected;
2230
- private rbracketsExpected;
2231
- private rbracesExpected;
2232
- private context;
2233
- private sourceSpanCache;
2234
- index: number;
2235
- constructor(input: string, location: string, absoluteOffset: number, tokens: Token[], parseFlags: ParseFlags, errors: ParserError[], offset: number);
2236
- peek(offset: number): Token;
2237
- get next(): Token;
2238
- /** Whether all the parser input has been processed. */
2239
- get atEOF(): boolean;
2240
- /**
2241
- * Index of the next token to be processed, or the end of the last token if all have been
2242
- * processed.
2243
- */
2244
- get inputIndex(): number;
2245
- /**
2246
- * End index of the last processed token, or the start of the first token if none have been
2247
- * processed.
2248
- */
2249
- get currentEndIndex(): number;
2250
- /**
2251
- * Returns the absolute offset of the start of the current token.
2252
- */
2253
- get currentAbsoluteOffset(): number;
2254
- /**
2255
- * Retrieve a `ParseSpan` from `start` to the current position (or to `artificialEndIndex` if
2256
- * provided).
2257
- *
2258
- * @param start Position from which the `ParseSpan` will start.
2259
- * @param artificialEndIndex Optional ending index to be used if provided (and if greater than the
2260
- * natural ending index)
2261
- */
2262
- span(start: number, artificialEndIndex?: number): ParseSpan;
2263
- sourceSpan(start: number, artificialEndIndex?: number): AbsoluteSourceSpan;
2264
- advance(): void;
2265
- /**
2266
- * Executes a callback in the provided context.
2267
- */
2268
- private withContext;
2269
- consumeOptionalCharacter(code: number): boolean;
2270
- peekKeywordLet(): boolean;
2271
- peekKeywordAs(): boolean;
2272
- /**
2273
- * Consumes an expected character, otherwise emits an error about the missing expected character
2274
- * and skips over the token stream until reaching a recoverable point.
2275
- *
2276
- * See `this.error` and `this.skip` for more details.
2277
- */
2278
- expectCharacter(code: number): void;
2279
- consumeOptionalOperator(op: string): boolean;
2280
- expectOperator(operator: string): void;
2281
- prettyPrintToken(tok: Token): string;
2282
- expectIdentifierOrKeyword(): string | null;
2283
- expectIdentifierOrKeywordOrString(): string;
2284
- parseChain(): AST;
2285
- parsePipe(): AST;
2286
- parseExpression(): AST;
2287
- parseConditional(): AST;
2288
- parseLogicalOr(): AST;
2289
- parseLogicalAnd(): AST;
2290
- parseNullishCoalescing(): AST;
2291
- parseEquality(): AST;
2292
- parseRelational(): AST;
2293
- parseAdditive(): AST;
2294
- parseMultiplicative(): AST;
2295
- parsePrefix(): AST;
2296
- parseCallChain(): AST;
2297
- parsePrimary(): AST;
2298
- parseExpressionList(terminator: number): AST[];
2299
- parseLiteralMap(): LiteralMap;
2300
- parseAccessMember(readReceiver: AST, start: number, isSafe: boolean): AST;
2301
- parseCall(receiver: AST, start: number, isSafe: boolean): AST;
2302
- private consumeOptionalAssignment;
2303
- parseCallArguments(): BindingPipe[];
2304
- /**
2305
- * Parses an identifier, a keyword, a string with an optional `-` in between,
2306
- * and returns the string along with its absolute source span.
2307
- */
2308
- expectTemplateBindingKey(): TemplateBindingIdentifier;
2309
- /**
2310
- * Parse microsyntax template expression and return a list of bindings or
2311
- * parsing errors in case the given expression is invalid.
2312
- *
2313
- * For example,
2314
- * ```
2315
- * <div *ngFor="let item of items; index as i; trackBy: func">
2316
- * ```
2317
- * contains five bindings:
2318
- * 1. ngFor -> null
2319
- * 2. item -> NgForOfContext.$implicit
2320
- * 3. ngForOf -> items
2321
- * 4. i -> NgForOfContext.index
2322
- * 5. ngForTrackBy -> func
2323
- *
2324
- * For a full description of the microsyntax grammar, see
2325
- * https://gist.github.com/mhevery/d3530294cff2e4a1b3fe15ff75d08855
2326
- *
2327
- * @param templateKey name of the microsyntax directive, like ngIf, ngFor,
2328
- * without the *, along with its absolute span.
2329
- */
2330
- parseTemplateBindings(templateKey: TemplateBindingIdentifier): TemplateBindingParseResult;
2331
- parseKeyedReadOrWrite(receiver: AST, start: number, isSafe: boolean): AST;
2332
- /**
2333
- * Parse a directive keyword, followed by a mandatory expression.
2334
- * For example, "of items", "trackBy: func".
2335
- * The bindings are: ngForOf -> items, ngForTrackBy -> func
2336
- * There could be an optional "as" binding that follows the expression.
2337
- * For example,
2338
- * ```
2339
- * *ngFor="let item of items | slice:0:1 as collection".
2340
- * ^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^
2341
- * keyword bound target optional 'as' binding
2342
- * ```
2343
- *
2344
- * @param key binding key, for example, ngFor, ngIf, ngForOf, along with its
2345
- * absolute span.
2346
- */
2347
- private parseDirectiveKeywordBindings;
2348
- /**
2349
- * Return the expression AST for the bound target of a directive keyword
2350
- * binding. For example,
2351
- * ```
2352
- * *ngIf="condition | pipe"
2353
- * ^^^^^^^^^^^^^^^^ bound target for "ngIf"
2354
- * *ngFor="let item of items"
2355
- * ^^^^^ bound target for "ngForOf"
2356
- * ```
2357
- */
2358
- private getDirectiveBoundTarget;
2359
- /**
2360
- * Return the binding for a variable declared using `as`. Note that the order
2361
- * of the key-value pair in this declaration is reversed. For example,
2362
- * ```
2363
- * *ngFor="let item of items; index as i"
2364
- * ^^^^^ ^
2365
- * value key
2366
- * ```
2367
- *
2368
- * @param value name of the value in the declaration, "ngIf" in the example
2369
- * above, along with its absolute span.
2370
- */
2371
- private parseAsBinding;
2372
- /**
2373
- * Return the binding for a variable declared using `let`. For example,
2374
- * ```
2375
- * *ngFor="let item of items; let i=index;"
2376
- * ^^^^^^^^ ^^^^^^^^^^^
2377
- * ```
2378
- * In the first binding, `item` is bound to `NgForOfContext.$implicit`.
2379
- * In the second binding, `i` is bound to `NgForOfContext.index`.
2380
- */
2381
- private parseLetBinding;
2382
- /**
2383
- * Consume the optional statement terminator: semicolon or comma.
2384
- */
2385
- private consumeStatementTerminator;
2386
- /**
2387
- * Records an error and skips over the token stream until reaching a recoverable point. See
2388
- * `this.skip` for more details on token skipping.
2389
- */
2390
- error(message: string, index?: number | null): void;
2391
- private locationText;
2392
- /**
2393
- * Records an error for an unexpected private identifier being discovered.
2394
- * @param token Token representing a private identifier.
2395
- * @param extraMessage Optional additional message being appended to the error.
2396
- */
2397
- private _reportErrorForPrivateIdentifier;
2398
- /**
2399
- * Error recovery should skip tokens until it encounters a recovery point.
2400
- *
2401
- * The following are treated as unconditional recovery points:
2402
- * - end of input
2403
- * - ';' (parseChain() is always the root production, and it expects a ';')
2404
- * - '|' (since pipes may be chained and each pipe expression may be treated independently)
2405
- *
2406
- * The following are conditional recovery points:
2407
- * - ')', '}', ']' if one of calling productions is expecting one of these symbols
2408
- * - This allows skip() to recover from errors such as '(a.) + 1' allowing more of the AST to
2409
- * be retained (it doesn't skip any tokens as the ')' is retained because of the '(' begins
2410
- * an '(' <expr> ')' production).
2411
- * The recovery points of grouping symbols must be conditional as they must be skipped if
2412
- * none of the calling productions are not expecting the closing token else we will never
2413
- * make progress in the case of an extraneous group closing symbol (such as a stray ')').
2414
- * That is, we skip a closing symbol if we are not in a grouping production.
2415
- * - '=' in a `Writable` context
2416
- * - In this context, we are able to recover after seeing the `=` operator, which
2417
- * signals the presence of an independent rvalue expression following the `=` operator.
2418
- *
2419
- * If a production expects one of these token it increments the corresponding nesting count,
2420
- * and then decrements it just prior to checking if the token is in the input.
2421
- */
2422
- private skip;
2423
- }
2424
-
2425
2236
  export declare class ParsedEvent {
2426
2237
  name: string;
2427
2238
  targetOrPhase: string;
@@ -2430,6 +2241,7 @@ export declare class ParsedEvent {
2430
2241
  sourceSpan: ParseSourceSpan;
2431
2242
  handlerSpan: ParseSourceSpan;
2432
2243
  readonly keySpan: ParseSourceSpan;
2244
+ constructor(name: string, targetOrPhase: string, type: ParsedEventType.TwoWay, handler: ASTWithSource<NonNullAssert | PropertyRead | KeyedRead>, sourceSpan: ParseSourceSpan, handlerSpan: ParseSourceSpan, keySpan: ParseSourceSpan);
2433
2245
  constructor(name: string, targetOrPhase: string, type: ParsedEventType, handler: ASTWithSource, sourceSpan: ParseSourceSpan, handlerSpan: ParseSourceSpan, keySpan: ParseSourceSpan);
2434
2246
  }
2435
2247
 
@@ -2552,12 +2364,7 @@ export declare const enum ParseFlags {
2552
2364
  /**
2553
2365
  * Whether an output binding is being parsed.
2554
2366
  */
2555
- Action = 1,
2556
- /**
2557
- * Whether an assignment event is being parsed, i.e. an expression originating from
2558
- * two-way-binding aka banana-in-a-box syntax.
2559
- */
2560
- AssignmentEvent = 2
2367
+ Action = 1
2561
2368
  }
2562
2369
 
2563
2370
  export declare function parseHostBindings(host: {
@@ -2582,7 +2389,7 @@ export declare class Parser {
2582
2389
  private _lexer;
2583
2390
  private errors;
2584
2391
  constructor(_lexer: Lexer);
2585
- parseAction(input: string, isAssignmentEvent: boolean, location: string, absoluteOffset: number, interpolationConfig?: InterpolationConfig): ASTWithSource;
2392
+ parseAction(input: string, location: string, absoluteOffset: number, interpolationConfig?: InterpolationConfig): ASTWithSource;
2586
2393
  parseBinding(input: string, location: string, absoluteOffset: number, interpolationConfig?: InterpolationConfig): ASTWithSource;
2587
2394
  private checkSimpleExpression;
2588
2395
  parseSimpleBinding(input: string, location: string, absoluteOffset: number, interpolationConfig?: InterpolationConfig): ASTWithSource;
@@ -3038,7 +2845,10 @@ export declare interface R3ComponentMetadata<DeclarationT extends R3TemplateDepe
3038
2845
  /**
3039
2846
  * Map of deferrable symbol names -> corresponding import paths.
3040
2847
  */
3041
- deferrableTypes: Map<string, string>;
2848
+ deferrableTypes: Map<string, {
2849
+ importPath: string;
2850
+ isDefaultImport: boolean;
2851
+ }>;
3042
2852
  /**
3043
2853
  * Specifies how the 'directives' and/or `pipes` array, if generated, need to be emitted.
3044
2854
  */
@@ -3626,6 +3436,10 @@ export declare interface R3DeferBlockTemplateDependency {
3626
3436
  * Import path where this dependency is located.
3627
3437
  */
3628
3438
  importPath: string | null;
3439
+ /**
3440
+ * Whether the symbol is the default export.
3441
+ */
3442
+ isDefaultImport: boolean;
3629
3443
  }
3630
3444
 
3631
3445
  declare interface R3DelegatedFnOrClassMetadata extends R3ConstructorFactoryMetadata {
@@ -4034,6 +3848,9 @@ export declare class R3Identifiers {
4034
3848
  static viewQuerySignal: outputAst.ExternalReference;
4035
3849
  static contentQuerySignal: outputAst.ExternalReference;
4036
3850
  static queryAdvance: outputAst.ExternalReference;
3851
+ static twoWayProperty: outputAst.ExternalReference;
3852
+ static twoWayBindingSet: outputAst.ExternalReference;
3853
+ static twoWayListener: outputAst.ExternalReference;
4037
3854
  static NgOnChangesFeature: outputAst.ExternalReference;
4038
3855
  static InheritDefinitionFeature: outputAst.ExternalReference;
4039
3856
  static CopyDefinitionFeature: outputAst.ExternalReference;
@@ -4061,6 +3878,10 @@ export declare class R3Identifiers {
4061
3878
  name: string;
4062
3879
  moduleName: string;
4063
3880
  };
3881
+ static unwrapWritableSignal: {
3882
+ name: string;
3883
+ moduleName: string;
3884
+ };
4064
3885
  }
4065
3886
 
4066
3887
  export declare interface R3InjectableMetadata {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/compiler",
3
- "version": "17.2.0-next.1",
3
+ "version": "17.2.0-rc.1",
4
4
  "description": "Angular - the compiler library",
5
5
  "author": "angular",
6
6
  "license": "MIT",
@@ -11,7 +11,7 @@
11
11
  "tslib": "^2.3.0"
12
12
  },
13
13
  "peerDependencies": {
14
- "@angular/core": "17.2.0-next.1"
14
+ "@angular/core": "17.2.0-rc.1"
15
15
  },
16
16
  "peerDependenciesMeta": {
17
17
  "@angular/core": {