@angular/compiler 16.0.1 → 16.1.0-next.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/esm2022/src/compiler_facade_interface.mjs +1 -1
- package/esm2022/src/jit_compiler_facade.mjs +2 -1
- package/esm2022/src/render3/partial/api.mjs +1 -1
- package/esm2022/src/render3/partial/class_metadata.mjs +1 -1
- package/esm2022/src/render3/partial/directive.mjs +5 -2
- package/esm2022/src/render3/partial/factory.mjs +1 -1
- package/esm2022/src/render3/partial/injectable.mjs +1 -1
- package/esm2022/src/render3/partial/injector.mjs +1 -1
- package/esm2022/src/render3/partial/ng_module.mjs +1 -1
- package/esm2022/src/render3/partial/pipe.mjs +1 -1
- package/esm2022/src/render3/view/api.mjs +1 -1
- package/esm2022/src/render3/view/compiler.mjs +6 -1
- package/esm2022/src/template/pipeline/ir/src/enums.mjs +18 -6
- package/esm2022/src/template/pipeline/ir/src/expression.mjs +8 -1
- package/esm2022/src/template/pipeline/ir/src/ops/create.mjs +1 -1
- package/esm2022/src/template/pipeline/src/conversion.mjs +28 -0
- package/esm2022/src/template/pipeline/src/emit.mjs +6 -2
- package/esm2022/src/template/pipeline/src/ingest.mjs +45 -8
- package/esm2022/src/template/pipeline/src/instruction.mjs +17 -8
- package/esm2022/src/template/pipeline/src/phases/chaining.mjs +4 -1
- package/esm2022/src/template/pipeline/src/phases/empty_elements.mjs +16 -8
- package/esm2022/src/template/pipeline/src/phases/generate_variables.mjs +8 -27
- package/esm2022/src/template/pipeline/src/phases/ng_container.mjs +29 -0
- package/esm2022/src/template/pipeline/src/phases/reify.mjs +10 -1
- package/esm2022/src/template/pipeline/src/phases/save_restore_view.mjs +46 -0
- package/esm2022/src/version.mjs +1 -1
- package/fesm2022/compiler.mjs +216 -62
- package/fesm2022/compiler.mjs.map +1 -1
- package/fesm2022/testing.mjs +1 -1
- package/index.d.ts +9 -1
- package/package.json +2 -2
- package/testing/index.d.ts +1 -1
package/fesm2022/compiler.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v16.0.
|
|
2
|
+
* @license Angular v16.1.0-next.0
|
|
3
3
|
* (c) 2010-2022 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -8502,26 +8502,38 @@ var OpKind;
|
|
|
8502
8502
|
* An operation to end rendering of an element previously started with `ElementStart`.
|
|
8503
8503
|
*/
|
|
8504
8504
|
OpKind[OpKind["ElementEnd"] = 6] = "ElementEnd";
|
|
8505
|
+
/**
|
|
8506
|
+
* An operation to begin an `ng-container`.
|
|
8507
|
+
*/
|
|
8508
|
+
OpKind[OpKind["ContainerStart"] = 7] = "ContainerStart";
|
|
8509
|
+
/**
|
|
8510
|
+
* An operation for an `ng-container` with no children.
|
|
8511
|
+
*/
|
|
8512
|
+
OpKind[OpKind["Container"] = 8] = "Container";
|
|
8513
|
+
/**
|
|
8514
|
+
* An operation to end an `ng-container`.
|
|
8515
|
+
*/
|
|
8516
|
+
OpKind[OpKind["ContainerEnd"] = 9] = "ContainerEnd";
|
|
8505
8517
|
/**
|
|
8506
8518
|
* An operation to render a text node.
|
|
8507
8519
|
*/
|
|
8508
|
-
OpKind[OpKind["Text"] =
|
|
8520
|
+
OpKind[OpKind["Text"] = 10] = "Text";
|
|
8509
8521
|
/**
|
|
8510
8522
|
* An operation declaring an event listener for an element.
|
|
8511
8523
|
*/
|
|
8512
|
-
OpKind[OpKind["Listener"] =
|
|
8524
|
+
OpKind[OpKind["Listener"] = 11] = "Listener";
|
|
8513
8525
|
/**
|
|
8514
8526
|
* An operation to interpolate text into a text node.
|
|
8515
8527
|
*/
|
|
8516
|
-
OpKind[OpKind["InterpolateText"] =
|
|
8528
|
+
OpKind[OpKind["InterpolateText"] = 12] = "InterpolateText";
|
|
8517
8529
|
/**
|
|
8518
8530
|
* An operation to bind an expression to a property of an element.
|
|
8519
8531
|
*/
|
|
8520
|
-
OpKind[OpKind["Property"] =
|
|
8532
|
+
OpKind[OpKind["Property"] = 13] = "Property";
|
|
8521
8533
|
/**
|
|
8522
8534
|
* An operation to advance the runtime's implicit slot context during the update phase of a view.
|
|
8523
8535
|
*/
|
|
8524
|
-
OpKind[OpKind["Advance"] =
|
|
8536
|
+
OpKind[OpKind["Advance"] = 14] = "Advance";
|
|
8525
8537
|
})(OpKind || (OpKind = {}));
|
|
8526
8538
|
/**
|
|
8527
8539
|
* Distinguishes different kinds of IR expressions.
|
|
@@ -8876,6 +8888,9 @@ function transformExpressionsInOp(op, transform, flags) {
|
|
|
8876
8888
|
case OpKind.Element:
|
|
8877
8889
|
case OpKind.ElementStart:
|
|
8878
8890
|
case OpKind.ElementEnd:
|
|
8891
|
+
case OpKind.Container:
|
|
8892
|
+
case OpKind.ContainerStart:
|
|
8893
|
+
case OpKind.ContainerEnd:
|
|
8879
8894
|
case OpKind.Template:
|
|
8880
8895
|
case OpKind.Text:
|
|
8881
8896
|
case OpKind.Advance:
|
|
@@ -8903,6 +8918,10 @@ function transformExpressionsInExpression(expr, transform, flags) {
|
|
|
8903
8918
|
else if (expr instanceof ReadPropExpr) {
|
|
8904
8919
|
expr.receiver = transformExpressionsInExpression(expr.receiver, transform, flags);
|
|
8905
8920
|
}
|
|
8921
|
+
else if (expr instanceof ReadKeyExpr) {
|
|
8922
|
+
expr.receiver = transformExpressionsInExpression(expr.receiver, transform, flags);
|
|
8923
|
+
expr.index = transformExpressionsInExpression(expr.index, transform, flags);
|
|
8924
|
+
}
|
|
8906
8925
|
else if (expr instanceof InvokeFunctionExpr) {
|
|
8907
8926
|
expr.fn = transformExpressionsInExpression(expr.fn, transform, flags);
|
|
8908
8927
|
for (let i = 0; i < expr.args.length; i++) {
|
|
@@ -9347,19 +9366,27 @@ function serializeAttributes({ attributes, bindings, classes, i18n, projectAs, s
|
|
|
9347
9366
|
return literalArr(attrArray);
|
|
9348
9367
|
}
|
|
9349
9368
|
|
|
9369
|
+
const REPLACEMENTS = new Map([
|
|
9370
|
+
[OpKind.ElementEnd, [OpKind.ElementStart, OpKind.Element]],
|
|
9371
|
+
[OpKind.ContainerEnd, [OpKind.ContainerStart, OpKind.Container]],
|
|
9372
|
+
]);
|
|
9350
9373
|
/**
|
|
9351
|
-
* Replace sequences of `ElementStart`
|
|
9352
|
-
*
|
|
9374
|
+
* Replace sequences of mergable elements (e.g. `ElementStart` and `ElementEnd`) with a consolidated
|
|
9375
|
+
* element (e.g. `Element`).
|
|
9353
9376
|
*/
|
|
9354
9377
|
function phaseEmptyElements(cpl) {
|
|
9355
9378
|
for (const [_, view] of cpl.views) {
|
|
9356
9379
|
for (const op of view.create) {
|
|
9357
|
-
|
|
9358
|
-
|
|
9359
|
-
|
|
9380
|
+
const opReplacements = REPLACEMENTS.get(op.kind);
|
|
9381
|
+
if (opReplacements === undefined) {
|
|
9382
|
+
continue;
|
|
9383
|
+
}
|
|
9384
|
+
const [startKind, mergedKind] = opReplacements;
|
|
9385
|
+
if (op.prev !== null && op.prev.kind === startKind) {
|
|
9386
|
+
// Transmute the start instruction to the merged version. This is safe as they're designed
|
|
9360
9387
|
// to be identical apart from the `kind`.
|
|
9361
|
-
op.prev.kind =
|
|
9362
|
-
// Remove the
|
|
9388
|
+
op.prev.kind = mergedKind;
|
|
9389
|
+
// Remove the end instruction.
|
|
9363
9390
|
OpList.remove(op);
|
|
9364
9391
|
}
|
|
9365
9392
|
}
|
|
@@ -9418,16 +9445,16 @@ function phaseGenerateAdvance(cpl) {
|
|
|
9418
9445
|
// instruction type is represented as a function, which may select a specific instruction variant
|
|
9419
9446
|
// depending on the exact arguments.
|
|
9420
9447
|
function element(slot, tag, constIndex, localRefIndex) {
|
|
9421
|
-
return
|
|
9448
|
+
return elementOrContainerBase(Identifiers.element, slot, tag, constIndex, localRefIndex);
|
|
9422
9449
|
}
|
|
9423
9450
|
function elementStart(slot, tag, constIndex, localRefIndex) {
|
|
9424
|
-
return
|
|
9451
|
+
return elementOrContainerBase(Identifiers.elementStart, slot, tag, constIndex, localRefIndex);
|
|
9425
9452
|
}
|
|
9426
|
-
function
|
|
9427
|
-
const args = [
|
|
9428
|
-
|
|
9429
|
-
literal(tag)
|
|
9430
|
-
|
|
9453
|
+
function elementOrContainerBase(instruction, slot, tag, constIndex, localRefIndex) {
|
|
9454
|
+
const args = [literal(slot)];
|
|
9455
|
+
if (tag !== null) {
|
|
9456
|
+
args.push(literal(tag));
|
|
9457
|
+
}
|
|
9431
9458
|
if (localRefIndex !== null) {
|
|
9432
9459
|
args.push(literal(constIndex), // might be null, but that's okay.
|
|
9433
9460
|
literal(localRefIndex));
|
|
@@ -9440,6 +9467,15 @@ function elementStartBase(instruction, slot, tag, constIndex, localRefIndex) {
|
|
|
9440
9467
|
function elementEnd() {
|
|
9441
9468
|
return call(Identifiers.elementEnd, []);
|
|
9442
9469
|
}
|
|
9470
|
+
function elementContainerStart(slot, constIndex, localRefIndex) {
|
|
9471
|
+
return elementOrContainerBase(Identifiers.elementContainerStart, slot, /* tag */ null, constIndex, localRefIndex);
|
|
9472
|
+
}
|
|
9473
|
+
function elementContainer(slot, constIndex, localRefIndex) {
|
|
9474
|
+
return elementOrContainerBase(Identifiers.elementContainer, slot, /* tag */ null, constIndex, localRefIndex);
|
|
9475
|
+
}
|
|
9476
|
+
function elementContainerEnd() {
|
|
9477
|
+
return call(Identifiers.elementContainerEnd, []);
|
|
9478
|
+
}
|
|
9443
9479
|
function template(slot, templateFnRef, decls, vars, tag, constIndex) {
|
|
9444
9480
|
return call(Identifiers.templateCreate, [
|
|
9445
9481
|
literal(slot),
|
|
@@ -9578,6 +9614,15 @@ function reifyCreateOperations(view, ops) {
|
|
|
9578
9614
|
case OpKind.ElementEnd:
|
|
9579
9615
|
OpList.replace(op, elementEnd());
|
|
9580
9616
|
break;
|
|
9617
|
+
case OpKind.ContainerStart:
|
|
9618
|
+
OpList.replace(op, elementContainerStart(op.slot, op.attributes, op.localRefs));
|
|
9619
|
+
break;
|
|
9620
|
+
case OpKind.Container:
|
|
9621
|
+
OpList.replace(op, elementContainer(op.slot, op.attributes, op.localRefs));
|
|
9622
|
+
break;
|
|
9623
|
+
case OpKind.ContainerEnd:
|
|
9624
|
+
OpList.replace(op, elementContainerEnd());
|
|
9625
|
+
break;
|
|
9581
9626
|
case OpKind.Template:
|
|
9582
9627
|
const childView = view.tpl.views.get(op.xref);
|
|
9583
9628
|
OpList.replace(op, template(op.slot, variable(childView.fnName), childView.decls, childView.vars, op.tag, op.attributes));
|
|
@@ -9953,11 +9998,11 @@ function phaseGenerateVariables(cpl) {
|
|
|
9953
9998
|
function recursivelyProcessView(view, parentScope) {
|
|
9954
9999
|
// Extract a `Scope` from this view.
|
|
9955
10000
|
const scope = getScopeForView(view, parentScope);
|
|
9956
|
-
//
|
|
9957
|
-
|
|
9958
|
-
|
|
9959
|
-
|
|
9960
|
-
|
|
10001
|
+
// Embedded views require an operation to save/restore the view context.
|
|
10002
|
+
if (view.parent !== null) {
|
|
10003
|
+
// Start the view creation block with an operation to save the current view context. This may be
|
|
10004
|
+
// used to restore the view context in any listeners that may be present.
|
|
10005
|
+
}
|
|
9961
10006
|
for (const op of view.create) {
|
|
9962
10007
|
switch (op.kind) {
|
|
9963
10008
|
case OpKind.Template:
|
|
@@ -9965,22 +10010,8 @@ function recursivelyProcessView(view, parentScope) {
|
|
|
9965
10010
|
recursivelyProcessView(view.tpl.views.get(op.xref), scope);
|
|
9966
10011
|
break;
|
|
9967
10012
|
case OpKind.Listener:
|
|
9968
|
-
//
|
|
9969
|
-
|
|
9970
|
-
createVariableOp(view.tpl.allocateXrefId(), scope.viewContextVariable, new RestoreViewExpr(view.xref)),
|
|
9971
|
-
// And includes all variables available to this view.
|
|
9972
|
-
...generateVariablesInScopeForView(view, scope)
|
|
9973
|
-
];
|
|
9974
|
-
op.handlerOps.prepend(preambleOps);
|
|
9975
|
-
// The "restore view" operation in listeners requires a call to `resetView` to reset the
|
|
9976
|
-
// context prior to returning from the listener operation. Find any `return` statements in
|
|
9977
|
-
// the listener body and wrap them in a call to reset the view.
|
|
9978
|
-
for (const handlerOp of op.handlerOps) {
|
|
9979
|
-
if (handlerOp.kind === OpKind.Statement &&
|
|
9980
|
-
handlerOp.statement instanceof ReturnStatement) {
|
|
9981
|
-
handlerOp.statement.value = new ResetViewExpr(handlerOp.statement.value);
|
|
9982
|
-
}
|
|
9983
|
-
}
|
|
10013
|
+
// Prepend variables to listener handler functions.
|
|
10014
|
+
op.handlerOps.prepend(generateVariablesInScopeForView(view, scope));
|
|
9984
10015
|
break;
|
|
9985
10016
|
}
|
|
9986
10017
|
}
|
|
@@ -10000,11 +10031,6 @@ function getScopeForView(view, parent) {
|
|
|
10000
10031
|
name: null,
|
|
10001
10032
|
view: view.xref,
|
|
10002
10033
|
},
|
|
10003
|
-
savedViewVariable: {
|
|
10004
|
-
kind: SemanticVariableKind.SavedView,
|
|
10005
|
-
name: null,
|
|
10006
|
-
view: view.xref,
|
|
10007
|
-
},
|
|
10008
10034
|
contextVariables: new Map(),
|
|
10009
10035
|
references: [],
|
|
10010
10036
|
parent,
|
|
@@ -10558,6 +10584,9 @@ const CHAINABLE = new Set([
|
|
|
10558
10584
|
Identifiers.elementStart,
|
|
10559
10585
|
Identifiers.elementEnd,
|
|
10560
10586
|
Identifiers.property,
|
|
10587
|
+
Identifiers.elementContainerStart,
|
|
10588
|
+
Identifiers.elementContainerEnd,
|
|
10589
|
+
Identifiers.elementContainer,
|
|
10561
10590
|
]);
|
|
10562
10591
|
/**
|
|
10563
10592
|
* Post-process a reified view compilation and convert sequential calls to chainable instructions
|
|
@@ -10682,16 +10711,74 @@ function mergeNextContextsInOps(ops) {
|
|
|
10682
10711
|
}
|
|
10683
10712
|
}
|
|
10684
10713
|
|
|
10714
|
+
const CONTAINER_TAG = 'ng-container';
|
|
10715
|
+
/**
|
|
10716
|
+
* Replace an `Element` or `ElementStart` whose tag is `ng-container` with a specific op.
|
|
10717
|
+
*/
|
|
10718
|
+
function phaseNgContainer(cpl) {
|
|
10719
|
+
for (const [_, view] of cpl.views) {
|
|
10720
|
+
const updatedElementXrefs = new Set();
|
|
10721
|
+
for (const op of view.create) {
|
|
10722
|
+
if (op.kind === OpKind.ElementStart && op.tag === CONTAINER_TAG) {
|
|
10723
|
+
// Transmute the `ElementStart` instruction to `ContainerStart`.
|
|
10724
|
+
op.kind = OpKind.ContainerStart;
|
|
10725
|
+
updatedElementXrefs.add(op.xref);
|
|
10726
|
+
}
|
|
10727
|
+
if (op.kind === OpKind.ElementEnd && updatedElementXrefs.has(op.xref)) {
|
|
10728
|
+
// This `ElementEnd` is associated with an `ElementStart` we already transmuted.
|
|
10729
|
+
op.kind = OpKind.ContainerEnd;
|
|
10730
|
+
}
|
|
10731
|
+
}
|
|
10732
|
+
}
|
|
10733
|
+
}
|
|
10734
|
+
|
|
10735
|
+
function phaseSaveRestoreView(cpl) {
|
|
10736
|
+
for (const view of cpl.views.values()) {
|
|
10737
|
+
if (view === cpl.root) {
|
|
10738
|
+
// Save/restore operations are not necessary for the root view.
|
|
10739
|
+
continue;
|
|
10740
|
+
}
|
|
10741
|
+
view.create.prepend([
|
|
10742
|
+
createVariableOp(view.tpl.allocateXrefId(), {
|
|
10743
|
+
kind: SemanticVariableKind.SavedView,
|
|
10744
|
+
name: null,
|
|
10745
|
+
view: view.xref,
|
|
10746
|
+
}, new GetCurrentViewExpr()),
|
|
10747
|
+
]);
|
|
10748
|
+
for (const op of view.create) {
|
|
10749
|
+
if (op.kind !== OpKind.Listener) {
|
|
10750
|
+
continue;
|
|
10751
|
+
}
|
|
10752
|
+
op.handlerOps.prepend([
|
|
10753
|
+
createVariableOp(view.tpl.allocateXrefId(), {
|
|
10754
|
+
kind: SemanticVariableKind.Context,
|
|
10755
|
+
name: null,
|
|
10756
|
+
view: view.xref,
|
|
10757
|
+
}, new RestoreViewExpr(view.xref)),
|
|
10758
|
+
]);
|
|
10759
|
+
// The "restore view" operation in listeners requires a call to `resetView` to reset the
|
|
10760
|
+
// context prior to returning from the listener operation. Find any `return` statements in
|
|
10761
|
+
// the listener body and wrap them in a call to reset the view.
|
|
10762
|
+
for (const handlerOp of op.handlerOps) {
|
|
10763
|
+
if (handlerOp.kind === OpKind.Statement &&
|
|
10764
|
+
handlerOp.statement instanceof ReturnStatement) {
|
|
10765
|
+
handlerOp.statement.value = new ResetViewExpr(handlerOp.statement.value);
|
|
10766
|
+
}
|
|
10767
|
+
}
|
|
10768
|
+
}
|
|
10769
|
+
}
|
|
10770
|
+
}
|
|
10771
|
+
|
|
10685
10772
|
/**
|
|
10686
10773
|
* Run all transformation phases in the correct order against a `ComponentCompilation`. After this
|
|
10687
10774
|
* processing, the compilation should be in a state where it can be emitted via `emitTemplateFn`.s
|
|
10688
10775
|
*/
|
|
10689
10776
|
function transformTemplate(cpl) {
|
|
10690
10777
|
phaseGenerateVariables(cpl);
|
|
10778
|
+
phaseSaveRestoreView(cpl);
|
|
10691
10779
|
phaseResolveNames(cpl);
|
|
10692
10780
|
phaseResolveContexts(cpl);
|
|
10693
10781
|
phaseLocalRefs(cpl);
|
|
10694
|
-
phaseEmptyElements(cpl);
|
|
10695
10782
|
phaseConstCollection(cpl);
|
|
10696
10783
|
phaseSlotAllocation(cpl);
|
|
10697
10784
|
phaseVarCounting(cpl);
|
|
@@ -10699,6 +10786,8 @@ function transformTemplate(cpl) {
|
|
|
10699
10786
|
phaseNaming(cpl);
|
|
10700
10787
|
phaseVariableOptimization(cpl, { conservative: true });
|
|
10701
10788
|
phaseMergeNextContext(cpl);
|
|
10789
|
+
phaseNgContainer(cpl);
|
|
10790
|
+
phaseEmptyElements(cpl);
|
|
10702
10791
|
phaseReify(cpl);
|
|
10703
10792
|
phaseChaining(cpl);
|
|
10704
10793
|
}
|
|
@@ -10878,6 +10967,26 @@ class ViewCompilation {
|
|
|
10878
10967
|
}
|
|
10879
10968
|
}
|
|
10880
10969
|
|
|
10970
|
+
const BINARY_OPERATORS = new Map([
|
|
10971
|
+
['&&', BinaryOperator.And],
|
|
10972
|
+
['>', BinaryOperator.Bigger],
|
|
10973
|
+
['>=', BinaryOperator.BiggerEquals],
|
|
10974
|
+
['&', BinaryOperator.BitwiseAnd],
|
|
10975
|
+
['/', BinaryOperator.Divide],
|
|
10976
|
+
['==', BinaryOperator.Equals],
|
|
10977
|
+
['===', BinaryOperator.Identical],
|
|
10978
|
+
['<', BinaryOperator.Lower],
|
|
10979
|
+
['<=', BinaryOperator.LowerEquals],
|
|
10980
|
+
['-', BinaryOperator.Minus],
|
|
10981
|
+
['%', BinaryOperator.Modulo],
|
|
10982
|
+
['*', BinaryOperator.Multiply],
|
|
10983
|
+
['!=', BinaryOperator.NotEquals],
|
|
10984
|
+
['!==', BinaryOperator.NotIdentical],
|
|
10985
|
+
['??', BinaryOperator.NullishCoalesce],
|
|
10986
|
+
['||', BinaryOperator.Or],
|
|
10987
|
+
['+', BinaryOperator.Plus],
|
|
10988
|
+
]);
|
|
10989
|
+
|
|
10881
10990
|
/**
|
|
10882
10991
|
* Process a template AST and convert it into a `ComponentCompilation` in the intermediate
|
|
10883
10992
|
* representation.
|
|
@@ -10989,9 +11098,22 @@ function convertAst(ast, cpl) {
|
|
|
10989
11098
|
else if (ast instanceof LiteralPrimitive) {
|
|
10990
11099
|
return literal(ast.value);
|
|
10991
11100
|
}
|
|
11101
|
+
else if (ast instanceof Binary) {
|
|
11102
|
+
const operator = BINARY_OPERATORS.get(ast.operation);
|
|
11103
|
+
if (operator === undefined) {
|
|
11104
|
+
throw new Error(`AssertionError: unknown binary operator ${ast.operation}`);
|
|
11105
|
+
}
|
|
11106
|
+
return new BinaryOperatorExpr(operator, convertAst(ast.left, cpl), convertAst(ast.right, cpl));
|
|
11107
|
+
}
|
|
10992
11108
|
else if (ast instanceof ThisReceiver) {
|
|
10993
11109
|
return new ContextExpr(cpl.root.xref);
|
|
10994
11110
|
}
|
|
11111
|
+
else if (ast instanceof KeyedRead) {
|
|
11112
|
+
return new ReadKeyExpr(convertAst(ast.receiver, cpl), convertAst(ast.key, cpl));
|
|
11113
|
+
}
|
|
11114
|
+
else if (ast instanceof Chain) {
|
|
11115
|
+
throw new Error(`AssertionError: Chain in unknown context`);
|
|
11116
|
+
}
|
|
10995
11117
|
else {
|
|
10996
11118
|
throw new Error(`Unhandled expression type: ${ast.constructor.name}`);
|
|
10997
11119
|
}
|
|
@@ -11024,13 +11146,14 @@ function ingestAttributes(op, element) {
|
|
|
11024
11146
|
*/
|
|
11025
11147
|
function ingestBindings(view, op, element) {
|
|
11026
11148
|
if (element instanceof Template) {
|
|
11027
|
-
|
|
11028
|
-
|
|
11029
|
-
|
|
11030
|
-
|
|
11031
|
-
|
|
11032
|
-
|
|
11149
|
+
// TODO: Are ng-template inputs handled differently from element inputs?
|
|
11150
|
+
// <ng-template dir [foo]="...">
|
|
11151
|
+
// <item-cmp *ngFor="let item of items" [item]="item">
|
|
11152
|
+
for (const input of [...element.templateAttrs, ...element.inputs]) {
|
|
11153
|
+
if (!(input instanceof BoundAttribute)) {
|
|
11154
|
+
continue;
|
|
11033
11155
|
}
|
|
11156
|
+
view.update.push(createPropertyOp(op.xref, input.name, convertAst(input.value, view.tpl)));
|
|
11034
11157
|
}
|
|
11035
11158
|
}
|
|
11036
11159
|
else {
|
|
@@ -11039,7 +11162,29 @@ function ingestBindings(view, op, element) {
|
|
|
11039
11162
|
}
|
|
11040
11163
|
for (const output of element.outputs) {
|
|
11041
11164
|
const listenerOp = createListenerOp(op.xref, output.name, op.tag);
|
|
11042
|
-
|
|
11165
|
+
// if output.handler is a chain, then push each statement from the chain separately, and
|
|
11166
|
+
// return the last one?
|
|
11167
|
+
let inputExprs;
|
|
11168
|
+
let handler = output.handler;
|
|
11169
|
+
if (handler instanceof ASTWithSource) {
|
|
11170
|
+
handler = handler.ast;
|
|
11171
|
+
}
|
|
11172
|
+
if (handler instanceof Chain) {
|
|
11173
|
+
inputExprs = handler.expressions;
|
|
11174
|
+
}
|
|
11175
|
+
else {
|
|
11176
|
+
inputExprs = [handler];
|
|
11177
|
+
}
|
|
11178
|
+
if (inputExprs.length === 0) {
|
|
11179
|
+
throw new Error('Expected listener to have non-empty expression list.');
|
|
11180
|
+
}
|
|
11181
|
+
const expressions = inputExprs.map(expr => convertAst(expr, view.tpl));
|
|
11182
|
+
const returnExpr = expressions.pop();
|
|
11183
|
+
for (const expr of expressions) {
|
|
11184
|
+
const stmtOp = createStatementOp(new ExpressionStatement(expr));
|
|
11185
|
+
listenerOp.handlerOps.push(stmtOp);
|
|
11186
|
+
}
|
|
11187
|
+
listenerOp.handlerOps.push(createStatementOp(new ReturnStatement(returnExpr)));
|
|
11043
11188
|
view.create.push(listenerOp);
|
|
11044
11189
|
}
|
|
11045
11190
|
}
|
|
@@ -21308,6 +21453,9 @@ function baseDirectiveFields(meta, constantPool, bindingParser) {
|
|
|
21308
21453
|
if (meta.isStandalone) {
|
|
21309
21454
|
definitionMap.set('standalone', literal(true));
|
|
21310
21455
|
}
|
|
21456
|
+
if (meta.isSignal) {
|
|
21457
|
+
definitionMap.set('signals', literal(true));
|
|
21458
|
+
}
|
|
21311
21459
|
return definitionMap;
|
|
21312
21460
|
}
|
|
21313
21461
|
/**
|
|
@@ -21478,6 +21626,7 @@ function createComponentType(meta) {
|
|
|
21478
21626
|
typeParams.push(stringArrayAsType(meta.template.ngContentSelectors));
|
|
21479
21627
|
typeParams.push(expressionType(literal(meta.isStandalone)));
|
|
21480
21628
|
typeParams.push(createHostDirectivesType(meta));
|
|
21629
|
+
typeParams.push(expressionType(literal(meta.isSignal)));
|
|
21481
21630
|
return expressionType(importExpr(Identifiers.ComponentDeclaration, typeParams));
|
|
21482
21631
|
}
|
|
21483
21632
|
/**
|
|
@@ -21605,6 +21754,7 @@ function createDirectiveType(meta) {
|
|
|
21605
21754
|
typeParams.push(NONE_TYPE);
|
|
21606
21755
|
typeParams.push(expressionType(literal(meta.isStandalone)));
|
|
21607
21756
|
typeParams.push(createHostDirectivesType(meta));
|
|
21757
|
+
typeParams.push(expressionType(literal(meta.isSignal)));
|
|
21608
21758
|
return expressionType(importExpr(Identifiers.DirectiveDeclaration, typeParams));
|
|
21609
21759
|
}
|
|
21610
21760
|
// Define and update any view queries
|
|
@@ -22268,6 +22418,7 @@ function convertDeclareDirectiveFacadeToMetadata(declaration, typeSourceSpan) {
|
|
|
22268
22418
|
typeArgumentCount: 0,
|
|
22269
22419
|
fullInheritance: false,
|
|
22270
22420
|
isStandalone: declaration.isStandalone ?? false,
|
|
22421
|
+
isSignal: declaration.isSignal ?? false,
|
|
22271
22422
|
hostDirectives: convertHostDirectivesToMetadata(declaration),
|
|
22272
22423
|
};
|
|
22273
22424
|
}
|
|
@@ -22559,7 +22710,7 @@ function publishFacade(global) {
|
|
|
22559
22710
|
* @description
|
|
22560
22711
|
* Entry point for all public APIs of the compiler package.
|
|
22561
22712
|
*/
|
|
22562
|
-
const VERSION = new Version('16.0.
|
|
22713
|
+
const VERSION = new Version('16.1.0-next.0');
|
|
22563
22714
|
|
|
22564
22715
|
class CompilerConfig {
|
|
22565
22716
|
constructor({ defaultEncapsulation = ViewEncapsulation.Emulated, useJit = true, missingTranslation = null, preserveWhitespaces, strictInjectionParameters } = {}) {
|
|
@@ -24487,7 +24638,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$6 = '12.0.0';
|
|
|
24487
24638
|
function compileDeclareClassMetadata(metadata) {
|
|
24488
24639
|
const definitionMap = new DefinitionMap();
|
|
24489
24640
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$6));
|
|
24490
|
-
definitionMap.set('version', literal('16.0.
|
|
24641
|
+
definitionMap.set('version', literal('16.1.0-next.0'));
|
|
24491
24642
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
24492
24643
|
definitionMap.set('type', metadata.type);
|
|
24493
24644
|
definitionMap.set('decorators', metadata.decorators);
|
|
@@ -24590,12 +24741,15 @@ function compileDeclareDirectiveFromMetadata(meta) {
|
|
|
24590
24741
|
function createDirectiveDefinitionMap(meta) {
|
|
24591
24742
|
const definitionMap = new DefinitionMap();
|
|
24592
24743
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$5));
|
|
24593
|
-
definitionMap.set('version', literal('16.0.
|
|
24744
|
+
definitionMap.set('version', literal('16.1.0-next.0'));
|
|
24594
24745
|
// e.g. `type: MyDirective`
|
|
24595
24746
|
definitionMap.set('type', meta.type.value);
|
|
24596
24747
|
if (meta.isStandalone) {
|
|
24597
24748
|
definitionMap.set('isStandalone', literal(meta.isStandalone));
|
|
24598
24749
|
}
|
|
24750
|
+
if (meta.isSignal) {
|
|
24751
|
+
definitionMap.set('isSignal', literal(meta.isSignal));
|
|
24752
|
+
}
|
|
24599
24753
|
// e.g. `selector: 'some-dir'`
|
|
24600
24754
|
if (meta.selector !== null) {
|
|
24601
24755
|
definitionMap.set('selector', literal(meta.selector));
|
|
@@ -24815,7 +24969,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$4 = '12.0.0';
|
|
|
24815
24969
|
function compileDeclareFactoryFunction(meta) {
|
|
24816
24970
|
const definitionMap = new DefinitionMap();
|
|
24817
24971
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$4));
|
|
24818
|
-
definitionMap.set('version', literal('16.0.
|
|
24972
|
+
definitionMap.set('version', literal('16.1.0-next.0'));
|
|
24819
24973
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
24820
24974
|
definitionMap.set('type', meta.type.value);
|
|
24821
24975
|
definitionMap.set('deps', compileDependencies(meta.deps));
|
|
@@ -24850,7 +25004,7 @@ function compileDeclareInjectableFromMetadata(meta) {
|
|
|
24850
25004
|
function createInjectableDefinitionMap(meta) {
|
|
24851
25005
|
const definitionMap = new DefinitionMap();
|
|
24852
25006
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$3));
|
|
24853
|
-
definitionMap.set('version', literal('16.0.
|
|
25007
|
+
definitionMap.set('version', literal('16.1.0-next.0'));
|
|
24854
25008
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
24855
25009
|
definitionMap.set('type', meta.type.value);
|
|
24856
25010
|
// Only generate providedIn property if it has a non-null value
|
|
@@ -24901,7 +25055,7 @@ function compileDeclareInjectorFromMetadata(meta) {
|
|
|
24901
25055
|
function createInjectorDefinitionMap(meta) {
|
|
24902
25056
|
const definitionMap = new DefinitionMap();
|
|
24903
25057
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$2));
|
|
24904
|
-
definitionMap.set('version', literal('16.0.
|
|
25058
|
+
definitionMap.set('version', literal('16.1.0-next.0'));
|
|
24905
25059
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
24906
25060
|
definitionMap.set('type', meta.type.value);
|
|
24907
25061
|
definitionMap.set('providers', meta.providers);
|
|
@@ -24931,7 +25085,7 @@ function compileDeclareNgModuleFromMetadata(meta) {
|
|
|
24931
25085
|
function createNgModuleDefinitionMap(meta) {
|
|
24932
25086
|
const definitionMap = new DefinitionMap();
|
|
24933
25087
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$1));
|
|
24934
|
-
definitionMap.set('version', literal('16.0.
|
|
25088
|
+
definitionMap.set('version', literal('16.1.0-next.0'));
|
|
24935
25089
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
24936
25090
|
definitionMap.set('type', meta.type.value);
|
|
24937
25091
|
// We only generate the keys in the metadata if the arrays contain values.
|
|
@@ -24982,7 +25136,7 @@ function compileDeclarePipeFromMetadata(meta) {
|
|
|
24982
25136
|
function createPipeDefinitionMap(meta) {
|
|
24983
25137
|
const definitionMap = new DefinitionMap();
|
|
24984
25138
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION));
|
|
24985
|
-
definitionMap.set('version', literal('16.0.
|
|
25139
|
+
definitionMap.set('version', literal('16.1.0-next.0'));
|
|
24986
25140
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
24987
25141
|
// e.g. `type: MyPipe`
|
|
24988
25142
|
definitionMap.set('type', meta.type.value);
|