@angular-eslint/bundled-angular-compiler 17.0.0-alpha.0 → 17.0.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/dist/index.js +494 -271
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @license Angular v17.0.0
|
|
4
|
+
* @license Angular v17.0.0
|
|
5
5
|
* (c) 2010-2022 Google LLC. https://angular.io/
|
|
6
6
|
* License: MIT
|
|
7
7
|
*/
|
|
@@ -8745,62 +8745,70 @@ var OpKind;
|
|
|
8745
8745
|
* An operation that controls when a `@defer` loads.
|
|
8746
8746
|
*/
|
|
8747
8747
|
OpKind[OpKind["DeferOn"] = 27] = "DeferOn";
|
|
8748
|
+
/**
|
|
8749
|
+
* An operation that controls when a `@defer` loads, using a custom expression as the condition.
|
|
8750
|
+
*/
|
|
8751
|
+
OpKind[OpKind["DeferWhen"] = 28] = "DeferWhen";
|
|
8748
8752
|
/**
|
|
8749
8753
|
* An i18n message that has been extracted for inclusion in the consts array.
|
|
8750
8754
|
*/
|
|
8751
|
-
OpKind[OpKind["
|
|
8755
|
+
OpKind[OpKind["I18nMessage"] = 29] = "I18nMessage";
|
|
8752
8756
|
/**
|
|
8753
8757
|
* A host binding property.
|
|
8754
8758
|
*/
|
|
8755
|
-
OpKind[OpKind["HostProperty"] =
|
|
8759
|
+
OpKind[OpKind["HostProperty"] = 30] = "HostProperty";
|
|
8756
8760
|
/**
|
|
8757
8761
|
* A namespace change, which causes the subsequent elements to be processed as either HTML or SVG.
|
|
8758
8762
|
*/
|
|
8759
|
-
OpKind[OpKind["Namespace"] =
|
|
8763
|
+
OpKind[OpKind["Namespace"] = 31] = "Namespace";
|
|
8760
8764
|
/**
|
|
8761
8765
|
* Configure a content projeciton definition for the view.
|
|
8762
8766
|
*/
|
|
8763
|
-
OpKind[OpKind["ProjectionDef"] =
|
|
8767
|
+
OpKind[OpKind["ProjectionDef"] = 32] = "ProjectionDef";
|
|
8764
8768
|
/**
|
|
8765
8769
|
* Create a content projection slot.
|
|
8766
8770
|
*/
|
|
8767
|
-
OpKind[OpKind["Projection"] =
|
|
8771
|
+
OpKind[OpKind["Projection"] = 33] = "Projection";
|
|
8768
8772
|
/**
|
|
8769
8773
|
* Create a repeater creation instruction op.
|
|
8770
8774
|
*/
|
|
8771
|
-
OpKind[OpKind["RepeaterCreate"] =
|
|
8775
|
+
OpKind[OpKind["RepeaterCreate"] = 34] = "RepeaterCreate";
|
|
8772
8776
|
/**
|
|
8773
8777
|
* An update up for a repeater.
|
|
8774
8778
|
*/
|
|
8775
|
-
OpKind[OpKind["Repeater"] =
|
|
8779
|
+
OpKind[OpKind["Repeater"] = 35] = "Repeater";
|
|
8776
8780
|
/**
|
|
8777
8781
|
* The start of an i18n block.
|
|
8778
8782
|
*/
|
|
8779
|
-
OpKind[OpKind["I18nStart"] =
|
|
8783
|
+
OpKind[OpKind["I18nStart"] = 36] = "I18nStart";
|
|
8780
8784
|
/**
|
|
8781
8785
|
* A self-closing i18n on a single element.
|
|
8782
8786
|
*/
|
|
8783
|
-
OpKind[OpKind["I18n"] =
|
|
8787
|
+
OpKind[OpKind["I18n"] = 37] = "I18n";
|
|
8784
8788
|
/**
|
|
8785
8789
|
* The end of an i18n block.
|
|
8786
8790
|
*/
|
|
8787
|
-
OpKind[OpKind["I18nEnd"] =
|
|
8791
|
+
OpKind[OpKind["I18nEnd"] = 38] = "I18nEnd";
|
|
8788
8792
|
/**
|
|
8789
8793
|
* An expression in an i18n message.
|
|
8790
8794
|
*/
|
|
8791
|
-
OpKind[OpKind["I18nExpression"] =
|
|
8795
|
+
OpKind[OpKind["I18nExpression"] = 39] = "I18nExpression";
|
|
8792
8796
|
/**
|
|
8793
8797
|
* An instruction that applies a set of i18n expressions.
|
|
8794
8798
|
*/
|
|
8795
|
-
OpKind[OpKind["I18nApply"] =
|
|
8799
|
+
OpKind[OpKind["I18nApply"] = 40] = "I18nApply";
|
|
8796
8800
|
/**
|
|
8797
8801
|
* An instruction to create an ICU expression.
|
|
8798
8802
|
*/
|
|
8799
|
-
OpKind[OpKind["Icu"] =
|
|
8803
|
+
OpKind[OpKind["Icu"] = 41] = "Icu";
|
|
8800
8804
|
/**
|
|
8801
8805
|
* An instruction to update an ICU expression.
|
|
8802
8806
|
*/
|
|
8803
|
-
OpKind[OpKind["IcuUpdate"] =
|
|
8807
|
+
OpKind[OpKind["IcuUpdate"] = 42] = "IcuUpdate";
|
|
8808
|
+
/**
|
|
8809
|
+
* An i18n context containing information needed to generate an i18n message.
|
|
8810
|
+
*/
|
|
8811
|
+
OpKind[OpKind["I18nContext"] = 43] = "I18nContext";
|
|
8804
8812
|
})(OpKind || (OpKind = {}));
|
|
8805
8813
|
/**
|
|
8806
8814
|
* Distinguishes different kinds of IR expressions.
|
|
@@ -9285,12 +9293,12 @@ function createAdvanceOp(delta, sourceSpan) {
|
|
|
9285
9293
|
/**
|
|
9286
9294
|
* Create an i18n expression op.
|
|
9287
9295
|
*/
|
|
9288
|
-
function createI18nExpressionOp(
|
|
9296
|
+
function createI18nExpressionOp(context, target, handle, expression, i18nPlaceholder, resolutionTime, sourceSpan) {
|
|
9289
9297
|
return {
|
|
9290
9298
|
kind: OpKind.I18nExpression,
|
|
9291
|
-
|
|
9292
|
-
|
|
9293
|
-
|
|
9299
|
+
context,
|
|
9300
|
+
target,
|
|
9301
|
+
handle,
|
|
9294
9302
|
expression,
|
|
9295
9303
|
i18nPlaceholder,
|
|
9296
9304
|
resolutionTime,
|
|
@@ -9303,11 +9311,11 @@ function createI18nExpressionOp(owner, ownerSlot, expression, i18nPlaceholder, r
|
|
|
9303
9311
|
/**
|
|
9304
9312
|
*Creates an op to apply i18n expression ops
|
|
9305
9313
|
*/
|
|
9306
|
-
function createI18nApplyOp(target,
|
|
9314
|
+
function createI18nApplyOp(target, handle, sourceSpan) {
|
|
9307
9315
|
return {
|
|
9308
9316
|
kind: OpKind.I18nApply,
|
|
9309
9317
|
target,
|
|
9310
|
-
|
|
9318
|
+
handle,
|
|
9311
9319
|
sourceSpan,
|
|
9312
9320
|
...NEW_OP,
|
|
9313
9321
|
};
|
|
@@ -10042,6 +10050,17 @@ function transformExpressionsInOp(op, transform, flags) {
|
|
|
10042
10050
|
transformExpressionsInExpression(op.placeholderConfig, transform, flags);
|
|
10043
10051
|
}
|
|
10044
10052
|
break;
|
|
10053
|
+
case OpKind.I18nMessage:
|
|
10054
|
+
for (const [placeholder, expr] of op.params) {
|
|
10055
|
+
op.params.set(placeholder, transformExpressionsInExpression(expr, transform, flags));
|
|
10056
|
+
}
|
|
10057
|
+
for (const [placeholder, expr] of op.postprocessingParams) {
|
|
10058
|
+
op.postprocessingParams.set(placeholder, transformExpressionsInExpression(expr, transform, flags));
|
|
10059
|
+
}
|
|
10060
|
+
break;
|
|
10061
|
+
case OpKind.DeferWhen:
|
|
10062
|
+
op.expr = transformExpressionsInExpression(op.expr, transform, flags);
|
|
10063
|
+
break;
|
|
10045
10064
|
case OpKind.Advance:
|
|
10046
10065
|
case OpKind.Container:
|
|
10047
10066
|
case OpKind.ContainerEnd:
|
|
@@ -10052,9 +10071,9 @@ function transformExpressionsInOp(op, transform, flags) {
|
|
|
10052
10071
|
case OpKind.ElementEnd:
|
|
10053
10072
|
case OpKind.ElementStart:
|
|
10054
10073
|
case OpKind.EnableBindings:
|
|
10055
|
-
case OpKind.ExtractedMessage:
|
|
10056
10074
|
case OpKind.I18n:
|
|
10057
10075
|
case OpKind.I18nApply:
|
|
10076
|
+
case OpKind.I18nContext:
|
|
10058
10077
|
case OpKind.I18nEnd:
|
|
10059
10078
|
case OpKind.I18nStart:
|
|
10060
10079
|
case OpKind.Icu:
|
|
@@ -10507,17 +10526,17 @@ function createExtractedAttributeOp(target, bindingKind, name, expression) {
|
|
|
10507
10526
|
/**
|
|
10508
10527
|
* Create an `ExtractedMessageOp`.
|
|
10509
10528
|
*/
|
|
10510
|
-
function
|
|
10529
|
+
function createI18nMessageOp(xref, i18nBlock, message, messagePlaceholder, params, postprocessingParams, needsPostprocessing) {
|
|
10511
10530
|
return {
|
|
10512
|
-
kind: OpKind.
|
|
10513
|
-
|
|
10531
|
+
kind: OpKind.I18nMessage,
|
|
10532
|
+
xref,
|
|
10533
|
+
i18nBlock,
|
|
10514
10534
|
message,
|
|
10515
|
-
|
|
10516
|
-
params
|
|
10517
|
-
postprocessingParams
|
|
10518
|
-
needsPostprocessing
|
|
10519
|
-
|
|
10520
|
-
formattedPostprocessingParams: null,
|
|
10535
|
+
messagePlaceholder,
|
|
10536
|
+
params,
|
|
10537
|
+
postprocessingParams,
|
|
10538
|
+
needsPostprocessing,
|
|
10539
|
+
subMessages: [],
|
|
10521
10540
|
...NEW_OP,
|
|
10522
10541
|
};
|
|
10523
10542
|
}
|
|
@@ -10533,6 +10552,7 @@ function createI18nStartOp(xref, message, root) {
|
|
|
10533
10552
|
message,
|
|
10534
10553
|
messageIndex: null,
|
|
10535
10554
|
subTemplateIndex: null,
|
|
10555
|
+
context: null,
|
|
10536
10556
|
...NEW_OP,
|
|
10537
10557
|
...TRAIT_CONSUMES_SLOT,
|
|
10538
10558
|
};
|
|
@@ -10547,6 +10567,18 @@ function createI18nEndOp(xref) {
|
|
|
10547
10567
|
...NEW_OP,
|
|
10548
10568
|
};
|
|
10549
10569
|
}
|
|
10570
|
+
function createI18nContextOp(xref, i18nBlock, message, sourceSpan) {
|
|
10571
|
+
return {
|
|
10572
|
+
kind: OpKind.I18nContext,
|
|
10573
|
+
xref,
|
|
10574
|
+
i18nBlock,
|
|
10575
|
+
message,
|
|
10576
|
+
sourceSpan,
|
|
10577
|
+
params: new Map(),
|
|
10578
|
+
postprocessingParams: new Map(),
|
|
10579
|
+
...NEW_OP,
|
|
10580
|
+
};
|
|
10581
|
+
}
|
|
10550
10582
|
|
|
10551
10583
|
function createHostPropertyOp(name, expression, isAnimationTrigger, sourceSpan) {
|
|
10552
10584
|
return {
|
|
@@ -10599,10 +10631,11 @@ class CompilationJob {
|
|
|
10599
10631
|
* embedded views or host bindings.
|
|
10600
10632
|
*/
|
|
10601
10633
|
class ComponentCompilationJob extends CompilationJob {
|
|
10602
|
-
constructor(componentName, pool, compatibility, relativeContextFilePath, i18nUseExternalIds) {
|
|
10634
|
+
constructor(componentName, pool, compatibility, relativeContextFilePath, i18nUseExternalIds, deferBlocksMeta) {
|
|
10603
10635
|
super(componentName, pool, compatibility);
|
|
10604
10636
|
this.relativeContextFilePath = relativeContextFilePath;
|
|
10605
10637
|
this.i18nUseExternalIds = i18nUseExternalIds;
|
|
10638
|
+
this.deferBlocksMeta = deferBlocksMeta;
|
|
10606
10639
|
this.kind = CompilationJobKind.Tmpl;
|
|
10607
10640
|
this.fnSuffix = 'Template';
|
|
10608
10641
|
this.views = new Map();
|
|
@@ -10781,7 +10814,7 @@ function applyI18nExpressions(job) {
|
|
|
10781
10814
|
// Only add apply after expressions that are not followed by more expressions.
|
|
10782
10815
|
if (op.kind === OpKind.I18nExpression && needsApplication(op)) {
|
|
10783
10816
|
// TODO: what should be the source span for the apply op?
|
|
10784
|
-
OpList.insertAfter(createI18nApplyOp(op.
|
|
10817
|
+
OpList.insertAfter(createI18nApplyOp(op.target, op.handle, null), op);
|
|
10785
10818
|
}
|
|
10786
10819
|
}
|
|
10787
10820
|
}
|
|
@@ -10794,8 +10827,8 @@ function needsApplication(op) {
|
|
|
10794
10827
|
if (op.next?.kind !== OpKind.I18nExpression) {
|
|
10795
10828
|
return true;
|
|
10796
10829
|
}
|
|
10797
|
-
// If the next op is an expression targeting a different i18n
|
|
10798
|
-
if (op.next.
|
|
10830
|
+
// If the next op is an expression targeting a different i18n context, we need to apply.
|
|
10831
|
+
if (op.next.context !== op.context) {
|
|
10799
10832
|
return true;
|
|
10800
10833
|
}
|
|
10801
10834
|
return false;
|
|
@@ -10806,21 +10839,33 @@ function needsApplication(op) {
|
|
|
10806
10839
|
*/
|
|
10807
10840
|
function assignI18nSlotDependencies(job) {
|
|
10808
10841
|
const i18nLastSlotConsumers = new Map();
|
|
10842
|
+
const i18nContexts = new Map();
|
|
10809
10843
|
let lastSlotConsumer = null;
|
|
10844
|
+
let currentI18nOp = null;
|
|
10810
10845
|
for (const unit of job.units) {
|
|
10811
10846
|
// Record the last consumed slot before each i18n end instruction.
|
|
10812
10847
|
for (const op of unit.create) {
|
|
10813
|
-
if (op.kind === OpKind.I18nEnd) {
|
|
10814
|
-
i18nLastSlotConsumers.set(op.xref, lastSlotConsumer);
|
|
10815
|
-
}
|
|
10816
10848
|
if (hasConsumesSlotTrait(op)) {
|
|
10817
10849
|
lastSlotConsumer = op.xref;
|
|
10818
10850
|
}
|
|
10851
|
+
switch (op.kind) {
|
|
10852
|
+
case OpKind.I18nStart:
|
|
10853
|
+
currentI18nOp = op;
|
|
10854
|
+
break;
|
|
10855
|
+
case OpKind.I18nEnd:
|
|
10856
|
+
i18nLastSlotConsumers.set(currentI18nOp.xref, lastSlotConsumer);
|
|
10857
|
+
currentI18nOp = null;
|
|
10858
|
+
break;
|
|
10859
|
+
case OpKind.I18nContext:
|
|
10860
|
+
i18nContexts.set(op.xref, op);
|
|
10861
|
+
break;
|
|
10862
|
+
}
|
|
10819
10863
|
}
|
|
10820
10864
|
// Assign i18n expressions to target the last slot in its owning block.
|
|
10821
10865
|
for (const op of unit.update) {
|
|
10822
10866
|
if (op.kind === OpKind.I18nExpression) {
|
|
10823
|
-
|
|
10867
|
+
const i18nContext = i18nContexts.get(op.context);
|
|
10868
|
+
op.target = i18nLastSlotConsumers.get(i18nContext.i18nBlock);
|
|
10824
10869
|
}
|
|
10825
10870
|
}
|
|
10826
10871
|
}
|
|
@@ -11362,6 +11407,133 @@ function serializeAttributes({ attributes, bindings, classes, i18n, projectAs, s
|
|
|
11362
11407
|
return literalArr(attrArray);
|
|
11363
11408
|
}
|
|
11364
11409
|
|
|
11410
|
+
/**
|
|
11411
|
+
* Create extracted deps functions for defer ops.
|
|
11412
|
+
*/
|
|
11413
|
+
function createDeferDepsFns(job) {
|
|
11414
|
+
for (const unit of job.units) {
|
|
11415
|
+
for (const op of unit.create) {
|
|
11416
|
+
if (op.kind === OpKind.Defer) {
|
|
11417
|
+
if (op.metadata.deps.length === 0) {
|
|
11418
|
+
continue;
|
|
11419
|
+
}
|
|
11420
|
+
const dependencies = [];
|
|
11421
|
+
for (const dep of op.metadata.deps) {
|
|
11422
|
+
if (dep.isDeferrable) {
|
|
11423
|
+
// Callback function, e.g. `m () => m.MyCmp;`.
|
|
11424
|
+
const innerFn = arrowFn([new FnParam('m', DYNAMIC_TYPE)], variable('m').prop(dep.symbolName));
|
|
11425
|
+
// Dynamic import, e.g. `import('./a').then(...)`.
|
|
11426
|
+
const importExpr = (new DynamicImportExpr(dep.importPath)).prop('then').callFn([innerFn]);
|
|
11427
|
+
dependencies.push(importExpr);
|
|
11428
|
+
}
|
|
11429
|
+
else {
|
|
11430
|
+
// Non-deferrable symbol, just use a reference to the type.
|
|
11431
|
+
dependencies.push(dep.type);
|
|
11432
|
+
}
|
|
11433
|
+
}
|
|
11434
|
+
const depsFnExpr = arrowFn([], literalArr(dependencies));
|
|
11435
|
+
if (op.handle.slot === null) {
|
|
11436
|
+
throw new Error('AssertionError: slot must be assigned bfore extracting defer deps functions');
|
|
11437
|
+
}
|
|
11438
|
+
op.resolverFn = job.pool.getSharedFunctionReference(depsFnExpr, `${job.componentName}_Defer_${op.handle.slot}_DepsFn`);
|
|
11439
|
+
}
|
|
11440
|
+
}
|
|
11441
|
+
}
|
|
11442
|
+
}
|
|
11443
|
+
|
|
11444
|
+
/**
|
|
11445
|
+
* Create one helper context op per i18n block (including generate descending blocks).
|
|
11446
|
+
*
|
|
11447
|
+
* Also, if an ICU exists inside an i18n block that also contains other localizable content (such as
|
|
11448
|
+
* string), create an additional helper context op for the ICU.
|
|
11449
|
+
*
|
|
11450
|
+
* These context ops are later used for generating i18n messages. (Although we generate at least one
|
|
11451
|
+
* context op per nested view, we will collect them up the tree later, to generate a top-level
|
|
11452
|
+
* message.)
|
|
11453
|
+
*/
|
|
11454
|
+
function createI18nContexts(job) {
|
|
11455
|
+
let currentI18nOp = null;
|
|
11456
|
+
let xref;
|
|
11457
|
+
for (const unit of job.units) {
|
|
11458
|
+
for (const op of unit.create) {
|
|
11459
|
+
switch (op.kind) {
|
|
11460
|
+
case OpKind.I18nStart:
|
|
11461
|
+
// Each i18n block gets its own context.
|
|
11462
|
+
xref = job.allocateXrefId();
|
|
11463
|
+
unit.create.push(createI18nContextOp(xref, op.xref, op.message, null));
|
|
11464
|
+
op.context = xref;
|
|
11465
|
+
currentI18nOp = op;
|
|
11466
|
+
break;
|
|
11467
|
+
case OpKind.I18nEnd:
|
|
11468
|
+
currentI18nOp = null;
|
|
11469
|
+
break;
|
|
11470
|
+
case OpKind.Icu:
|
|
11471
|
+
// If an ICU represents a different message than its containing block, we give it its own
|
|
11472
|
+
// i18n context.
|
|
11473
|
+
if (currentI18nOp === null) {
|
|
11474
|
+
throw Error('Unexpected ICU outside of an i18n block.');
|
|
11475
|
+
}
|
|
11476
|
+
if (op.message.id !== currentI18nOp.message.id) {
|
|
11477
|
+
// There was an enclosing i18n block around this ICU somewhere.
|
|
11478
|
+
xref = job.allocateXrefId();
|
|
11479
|
+
unit.create.push(createI18nContextOp(xref, currentI18nOp.xref, op.message, null));
|
|
11480
|
+
op.context = xref;
|
|
11481
|
+
}
|
|
11482
|
+
else {
|
|
11483
|
+
// The i18n block was generated because of this ICU, OR it was explicit, but the ICU is
|
|
11484
|
+
// the only localizable content inside of it.
|
|
11485
|
+
op.context = currentI18nOp.context;
|
|
11486
|
+
}
|
|
11487
|
+
break;
|
|
11488
|
+
}
|
|
11489
|
+
}
|
|
11490
|
+
}
|
|
11491
|
+
}
|
|
11492
|
+
|
|
11493
|
+
/**
|
|
11494
|
+
* Replace the ICU update ops with i18n expression ops.
|
|
11495
|
+
*/
|
|
11496
|
+
function createI18nIcuExpressions(job) {
|
|
11497
|
+
const icus = new Map();
|
|
11498
|
+
const i18nContexts = new Map();
|
|
11499
|
+
const i18nBlocks = new Map();
|
|
11500
|
+
// Collect maps of ops that need to be referenced to create the I18nExpressionOps.
|
|
11501
|
+
for (const unit of job.units) {
|
|
11502
|
+
for (const op of unit.create) {
|
|
11503
|
+
switch (op.kind) {
|
|
11504
|
+
case OpKind.Icu:
|
|
11505
|
+
icus.set(op.xref, op);
|
|
11506
|
+
break;
|
|
11507
|
+
case OpKind.I18nContext:
|
|
11508
|
+
i18nContexts.set(op.xref, op);
|
|
11509
|
+
break;
|
|
11510
|
+
case OpKind.I18nStart:
|
|
11511
|
+
i18nBlocks.set(op.xref, op);
|
|
11512
|
+
break;
|
|
11513
|
+
}
|
|
11514
|
+
}
|
|
11515
|
+
// Replace each IcuUpdateOp with an I18nExpressionOp.
|
|
11516
|
+
for (const op of unit.update) {
|
|
11517
|
+
switch (op.kind) {
|
|
11518
|
+
case OpKind.IcuUpdate:
|
|
11519
|
+
const icuOp = icus.get(op.xref);
|
|
11520
|
+
if (icuOp?.icu.expressionPlaceholder === undefined) {
|
|
11521
|
+
throw Error('ICU should have an i18n placeholder');
|
|
11522
|
+
}
|
|
11523
|
+
if (icuOp.context === null) {
|
|
11524
|
+
throw Error('ICU should have its i18n context set');
|
|
11525
|
+
}
|
|
11526
|
+
const i18nContext = i18nContexts.get(icuOp.context);
|
|
11527
|
+
const i18nBlock = i18nBlocks.get(i18nContext.i18nBlock);
|
|
11528
|
+
OpList.replace(op, createI18nExpressionOp(i18nContext.xref, i18nBlock.xref, i18nBlock.handle, new LexicalReadExpr(icuOp.icu.expression), icuOp.icu.expressionPlaceholder,
|
|
11529
|
+
// ICU-based i18n Expressions are resolved during post-processing.
|
|
11530
|
+
I18nParamResolutionTime.Postproccessing, null));
|
|
11531
|
+
break;
|
|
11532
|
+
}
|
|
11533
|
+
}
|
|
11534
|
+
}
|
|
11535
|
+
}
|
|
11536
|
+
|
|
11365
11537
|
/**
|
|
11366
11538
|
* Defer instructions take a configuration array, which should be collected into the component
|
|
11367
11539
|
* consts. This phase finds the config options, and creates the corresponding const array.
|
|
@@ -11424,6 +11596,26 @@ function resolveDeferTargetNames(job) {
|
|
|
11424
11596
|
case DeferTriggerKind.Interaction:
|
|
11425
11597
|
case DeferTriggerKind.Viewport:
|
|
11426
11598
|
if (op.trigger.targetName === null) {
|
|
11599
|
+
// A `null` target name indicates we should default to the first element in the
|
|
11600
|
+
// placeholder block.
|
|
11601
|
+
if (placeholderView === null) {
|
|
11602
|
+
throw new Error('defer on trigger with no target name must have a placeholder block');
|
|
11603
|
+
}
|
|
11604
|
+
const placeholder = job.views.get(placeholderView);
|
|
11605
|
+
if (placeholder == undefined) {
|
|
11606
|
+
throw new Error('AssertionError: could not find placeholder view for defer on trigger');
|
|
11607
|
+
}
|
|
11608
|
+
for (const placeholderOp of placeholder.create) {
|
|
11609
|
+
if (hasConsumesSlotTrait(placeholderOp) &&
|
|
11610
|
+
(isElementOrContainerOp(placeholderOp) ||
|
|
11611
|
+
placeholderOp.kind === OpKind.Projection)) {
|
|
11612
|
+
op.trigger.targetXref = placeholderOp.xref;
|
|
11613
|
+
op.trigger.targetView = placeholderView;
|
|
11614
|
+
op.trigger.targetSlotViewSteps = -1;
|
|
11615
|
+
op.trigger.targetSlot = placeholderOp.handle;
|
|
11616
|
+
return;
|
|
11617
|
+
}
|
|
11618
|
+
}
|
|
11427
11619
|
return;
|
|
11428
11620
|
}
|
|
11429
11621
|
let view = placeholderView !== null ? job.views.get(placeholderView) : deferOwnerView;
|
|
@@ -11721,26 +11913,69 @@ const LIST_DELIMITER = '|';
|
|
|
11721
11913
|
* Formats the param maps on extracted message ops into a maps of `Expression` objects that can be
|
|
11722
11914
|
* used in the final output.
|
|
11723
11915
|
*/
|
|
11724
|
-
function
|
|
11916
|
+
function extractI18nMessages(job) {
|
|
11917
|
+
// Save the i18n context ops for later use.
|
|
11918
|
+
const i18nContexts = new Map();
|
|
11919
|
+
// Record which contexts represent i18n blocks (any other contexts are assumed to have been
|
|
11920
|
+
// created from ICUs).
|
|
11921
|
+
const i18nBlockContexts = new Set();
|
|
11725
11922
|
for (const unit of job.units) {
|
|
11726
11923
|
for (const op of unit.create) {
|
|
11727
|
-
|
|
11728
|
-
|
|
11729
|
-
op.
|
|
11730
|
-
|
|
11731
|
-
|
|
11732
|
-
|
|
11733
|
-
|
|
11734
|
-
|
|
11735
|
-
|
|
11736
|
-
|
|
11737
|
-
|
|
11738
|
-
|
|
11924
|
+
switch (op.kind) {
|
|
11925
|
+
case OpKind.I18nContext:
|
|
11926
|
+
i18nContexts.set(op.xref, op);
|
|
11927
|
+
break;
|
|
11928
|
+
case OpKind.I18nStart:
|
|
11929
|
+
i18nBlockContexts.add(op.context);
|
|
11930
|
+
break;
|
|
11931
|
+
}
|
|
11932
|
+
}
|
|
11933
|
+
}
|
|
11934
|
+
// Extract messages from root i18n blocks.
|
|
11935
|
+
const i18nBlockMessages = new Map();
|
|
11936
|
+
for (const unit of job.units) {
|
|
11937
|
+
for (const op of unit.create) {
|
|
11938
|
+
if (op.kind === OpKind.I18nStart && op.xref === op.root) {
|
|
11939
|
+
if (!op.context) {
|
|
11940
|
+
throw Error('I18n start op should have its context set.');
|
|
11941
|
+
}
|
|
11942
|
+
const i18nMessageOp = createI18nMessage(job, i18nContexts.get(op.context));
|
|
11943
|
+
i18nBlockMessages.set(op.xref, i18nMessageOp);
|
|
11944
|
+
unit.create.push(i18nMessageOp);
|
|
11945
|
+
}
|
|
11946
|
+
}
|
|
11947
|
+
}
|
|
11948
|
+
// Extract messages from ICUs with their own sub-context.
|
|
11949
|
+
for (const unit of job.units) {
|
|
11950
|
+
for (const op of unit.create) {
|
|
11951
|
+
if (op.kind === OpKind.Icu) {
|
|
11952
|
+
if (!op.context) {
|
|
11953
|
+
throw Error('ICU op should have its context set.');
|
|
11739
11954
|
}
|
|
11955
|
+
if (!i18nBlockContexts.has(op.context)) {
|
|
11956
|
+
const i18nContext = i18nContexts.get(op.context);
|
|
11957
|
+
const subMessage = createI18nMessage(job, i18nContext, op.messagePlaceholder);
|
|
11958
|
+
unit.create.push(subMessage);
|
|
11959
|
+
const parentMessage = i18nBlockMessages.get(i18nContext.i18nBlock);
|
|
11960
|
+
parentMessage?.subMessages.push(subMessage.xref);
|
|
11961
|
+
}
|
|
11962
|
+
OpList.remove(op);
|
|
11740
11963
|
}
|
|
11741
11964
|
}
|
|
11742
11965
|
}
|
|
11743
11966
|
}
|
|
11967
|
+
/**
|
|
11968
|
+
* Create an i18n message op from an i18n context op.
|
|
11969
|
+
*/
|
|
11970
|
+
function createI18nMessage(job, context, messagePlaceholder) {
|
|
11971
|
+
let needsPostprocessing = context.postprocessingParams.size > 0;
|
|
11972
|
+
for (const values of context.params.values()) {
|
|
11973
|
+
if (values.length > 1) {
|
|
11974
|
+
needsPostprocessing = true;
|
|
11975
|
+
}
|
|
11976
|
+
}
|
|
11977
|
+
return createI18nMessageOp(job.allocateXrefId(), context.i18nBlock, context.message, messagePlaceholder ?? null, formatParams(context.params), formatParams(context.postprocessingParams), needsPostprocessing);
|
|
11978
|
+
}
|
|
11744
11979
|
/**
|
|
11745
11980
|
* Formats a map of `I18nParamValue[]` values into a map of `Expression` values.
|
|
11746
11981
|
*/
|
|
@@ -18975,35 +19210,23 @@ const TRANSLATION_VAR_PREFIX = 'i18n_';
|
|
|
18975
19210
|
function collectI18nConsts(job) {
|
|
18976
19211
|
const fileBasedI18nSuffix = job.relativeContextFilePath.replace(/[^A-Za-z0-9]/g, '_').toUpperCase() + '_';
|
|
18977
19212
|
const messageConstIndices = new Map();
|
|
19213
|
+
// Remove all of the i18n message ops into a map.
|
|
19214
|
+
const messages = new Map();
|
|
18978
19215
|
for (const unit of job.units) {
|
|
18979
19216
|
for (const op of unit.create) {
|
|
18980
|
-
if (op.kind === OpKind.
|
|
18981
|
-
|
|
18982
|
-
if (op.isRoot) {
|
|
18983
|
-
assertAllParamsResolved(op);
|
|
18984
|
-
const mainVar = variable(job.pool.uniqueName(TRANSLATION_VAR_PREFIX));
|
|
18985
|
-
// Closure Compiler requires const names to start with `MSG_` but disallows any other
|
|
18986
|
-
// const to start with `MSG_`. We define a variable starting with `MSG_` just for the
|
|
18987
|
-
// `goog.getMsg` call
|
|
18988
|
-
const closureVar = i18nGenerateClosureVar(job.pool, op.message.id, fileBasedI18nSuffix, job.i18nUseExternalIds);
|
|
18989
|
-
let transformFn = undefined;
|
|
18990
|
-
// If nescessary, add a post-processing step and resolve any placeholder params that are
|
|
18991
|
-
// set in post-processing.
|
|
18992
|
-
if (op.needsPostprocessing) {
|
|
18993
|
-
const extraTransformFnParams = [];
|
|
18994
|
-
if (op.formattedPostprocessingParams.size > 0) {
|
|
18995
|
-
extraTransformFnParams.push(literalMap([...op.formattedPostprocessingParams].map(([key, value]) => ({ key, value, quoted: true }))));
|
|
18996
|
-
}
|
|
18997
|
-
transformFn = (expr) => importExpr(Identifiers.i18nPostprocess).callFn([expr, ...extraTransformFnParams]);
|
|
18998
|
-
}
|
|
18999
|
-
const statements = getTranslationDeclStmts$1(op.message, mainVar, closureVar, op.formattedParams, transformFn);
|
|
19000
|
-
messageConstIndices.set(op.owner, job.addConst(mainVar, statements));
|
|
19001
|
-
}
|
|
19002
|
-
// Remove the extracted messages from the IR now that they have been collected.
|
|
19217
|
+
if (op.kind === OpKind.I18nMessage) {
|
|
19218
|
+
messages.set(op.xref, op);
|
|
19003
19219
|
OpList.remove(op);
|
|
19004
19220
|
}
|
|
19005
19221
|
}
|
|
19006
19222
|
}
|
|
19223
|
+
// Serialize the extracted messages for root i18n blocks into the const array.
|
|
19224
|
+
for (const op of messages.values()) {
|
|
19225
|
+
if (op.kind === OpKind.I18nMessage && op.messagePlaceholder === null) {
|
|
19226
|
+
const { mainVar, statements } = collectMessage(job, fileBasedI18nSuffix, messages, op);
|
|
19227
|
+
messageConstIndices.set(op.i18nBlock, job.addConst(mainVar, statements));
|
|
19228
|
+
}
|
|
19229
|
+
}
|
|
19007
19230
|
// Assign const index to i18n ops that messages were extracted from.
|
|
19008
19231
|
for (const unit of job.units) {
|
|
19009
19232
|
for (const op of unit.create) {
|
|
@@ -19013,6 +19236,40 @@ function collectI18nConsts(job) {
|
|
|
19013
19236
|
}
|
|
19014
19237
|
}
|
|
19015
19238
|
}
|
|
19239
|
+
/**
|
|
19240
|
+
* Collects the given message into a set of statements that can be added to the const array.
|
|
19241
|
+
* This will recursively collect any sub-messages referenced from the parent message as well.
|
|
19242
|
+
*/
|
|
19243
|
+
function collectMessage(job, fileBasedI18nSuffix, messages, messageOp) {
|
|
19244
|
+
// Recursively collect any sub-messages, and fill in their placeholders in this message.
|
|
19245
|
+
const statements = [];
|
|
19246
|
+
for (const subMessageId of messageOp.subMessages) {
|
|
19247
|
+
const subMessage = messages.get(subMessageId);
|
|
19248
|
+
const { mainVar: subMessageVar, statements: subMessageStatements } = collectMessage(job, fileBasedI18nSuffix, messages, subMessage);
|
|
19249
|
+
statements.push(...subMessageStatements);
|
|
19250
|
+
messageOp.params.set(subMessage.messagePlaceholder, subMessageVar);
|
|
19251
|
+
}
|
|
19252
|
+
// Check that the message has all of its parameters filled out.
|
|
19253
|
+
assertAllParamsResolved(messageOp);
|
|
19254
|
+
const mainVar = variable(job.pool.uniqueName(TRANSLATION_VAR_PREFIX));
|
|
19255
|
+
// Closure Compiler requires const names to start with `MSG_` but disallows any other
|
|
19256
|
+
// const to start with `MSG_`. We define a variable starting with `MSG_` just for the
|
|
19257
|
+
// `goog.getMsg` call
|
|
19258
|
+
const closureVar = i18nGenerateClosureVar(job.pool, messageOp.message.id, fileBasedI18nSuffix, job.i18nUseExternalIds);
|
|
19259
|
+
let transformFn = undefined;
|
|
19260
|
+
// If nescessary, add a post-processing step and resolve any placeholder params that are
|
|
19261
|
+
// set in post-processing.
|
|
19262
|
+
if (messageOp.needsPostprocessing) {
|
|
19263
|
+
const extraTransformFnParams = [];
|
|
19264
|
+
if (messageOp.postprocessingParams.size > 0) {
|
|
19265
|
+
extraTransformFnParams.push(literalMap([...messageOp.postprocessingParams].map(([key, value]) => ({ key, value, quoted: true }))));
|
|
19266
|
+
}
|
|
19267
|
+
transformFn = (expr) => importExpr(Identifiers.i18nPostprocess).callFn([expr, ...extraTransformFnParams]);
|
|
19268
|
+
}
|
|
19269
|
+
// Add the message's statements
|
|
19270
|
+
statements.push(...getTranslationDeclStmts$1(messageOp.message, mainVar, closureVar, messageOp.params, transformFn));
|
|
19271
|
+
return { mainVar, statements };
|
|
19272
|
+
}
|
|
19016
19273
|
/**
|
|
19017
19274
|
* Generate statements that define a given translation message.
|
|
19018
19275
|
*
|
|
@@ -19084,36 +19341,18 @@ function i18nGenerateClosureVar(pool, messageId, fileBasedI18nSuffix, useExterna
|
|
|
19084
19341
|
* Asserts that all of the message's placeholders have values.
|
|
19085
19342
|
*/
|
|
19086
19343
|
function assertAllParamsResolved(op) {
|
|
19087
|
-
if (op.formattedParams === null || op.formattedPostprocessingParams === null) {
|
|
19088
|
-
throw Error('Params should have been formatted.');
|
|
19089
|
-
}
|
|
19090
19344
|
for (const placeholder in op.message.placeholders) {
|
|
19091
|
-
if (!op.
|
|
19092
|
-
!op.formattedPostprocessingParams.has(placeholder)) {
|
|
19345
|
+
if (!op.params.has(placeholder) && !op.postprocessingParams.has(placeholder)) {
|
|
19093
19346
|
throw Error(`Failed to resolve i18n placeholder: ${placeholder}`);
|
|
19094
19347
|
}
|
|
19095
19348
|
}
|
|
19096
19349
|
for (const placeholder in op.message.placeholderToMessage) {
|
|
19097
|
-
if (!op.
|
|
19098
|
-
!op.formattedPostprocessingParams.has(placeholder)) {
|
|
19350
|
+
if (!op.params.has(placeholder) && !op.postprocessingParams.has(placeholder)) {
|
|
19099
19351
|
throw Error(`Failed to resolve i18n message placeholder: ${placeholder}`);
|
|
19100
19352
|
}
|
|
19101
19353
|
}
|
|
19102
19354
|
}
|
|
19103
19355
|
|
|
19104
|
-
/**
|
|
19105
|
-
* Extracts i18n messages into their own op.
|
|
19106
|
-
*/
|
|
19107
|
-
function extractI18nMessages(job) {
|
|
19108
|
-
for (const unit of job.units) {
|
|
19109
|
-
for (const op of unit.create) {
|
|
19110
|
-
if (op.kind === OpKind.I18nStart) {
|
|
19111
|
-
unit.create.push(createExtractedMessageOp(op.xref, op.message, op.xref === op.root));
|
|
19112
|
-
}
|
|
19113
|
-
}
|
|
19114
|
-
}
|
|
19115
|
-
}
|
|
19116
|
-
|
|
19117
19356
|
/**
|
|
19118
19357
|
* Removes text nodes within i18n blocks since they are already hardcoded into the i18n message.
|
|
19119
19358
|
*/
|
|
@@ -19121,22 +19360,22 @@ function extractI18nText(job) {
|
|
|
19121
19360
|
for (const unit of job.units) {
|
|
19122
19361
|
// Remove all text nodes within i18n blocks, their content is already captured in the i18n
|
|
19123
19362
|
// message.
|
|
19124
|
-
let
|
|
19125
|
-
|
|
19126
|
-
const textNodes = new Map();
|
|
19363
|
+
let currentI18n = null;
|
|
19364
|
+
const textNodeI18nBlocks = new Map();
|
|
19127
19365
|
for (const op of unit.create) {
|
|
19128
19366
|
switch (op.kind) {
|
|
19129
19367
|
case OpKind.I18nStart:
|
|
19130
|
-
|
|
19131
|
-
|
|
19368
|
+
if (op.context === null) {
|
|
19369
|
+
throw Error('I18n op should have its context set.');
|
|
19370
|
+
}
|
|
19371
|
+
currentI18n = op;
|
|
19132
19372
|
break;
|
|
19133
19373
|
case OpKind.I18nEnd:
|
|
19134
|
-
|
|
19135
|
-
currentI18nSlot = null;
|
|
19374
|
+
currentI18n = null;
|
|
19136
19375
|
break;
|
|
19137
19376
|
case OpKind.Text:
|
|
19138
|
-
if (
|
|
19139
|
-
|
|
19377
|
+
if (currentI18n !== null) {
|
|
19378
|
+
textNodeI18nBlocks.set(op.xref, currentI18n);
|
|
19140
19379
|
OpList.remove(op);
|
|
19141
19380
|
}
|
|
19142
19381
|
break;
|
|
@@ -19147,17 +19386,18 @@ function extractI18nText(job) {
|
|
|
19147
19386
|
for (const op of unit.update) {
|
|
19148
19387
|
switch (op.kind) {
|
|
19149
19388
|
case OpKind.InterpolateText:
|
|
19150
|
-
if (!
|
|
19389
|
+
if (!textNodeI18nBlocks.has(op.target)) {
|
|
19151
19390
|
continue;
|
|
19152
19391
|
}
|
|
19153
|
-
const
|
|
19392
|
+
const i18nOp = textNodeI18nBlocks.get(op.target);
|
|
19154
19393
|
const ops = [];
|
|
19155
19394
|
for (let i = 0; i < op.interpolation.expressions.length; i++) {
|
|
19156
19395
|
const expr = op.interpolation.expressions[i];
|
|
19157
19396
|
const placeholder = op.i18nPlaceholders[i];
|
|
19158
|
-
|
|
19397
|
+
// For now, this i18nExpression depends on the slot context of the enclosing i18n block.
|
|
19398
|
+
// Later, we will modify this, and advance to a different point.
|
|
19399
|
+
ops.push(createI18nExpressionOp(i18nOp.context, i18nOp.xref, i18nOp.handle, expr, placeholder.name, I18nParamResolutionTime.Creation, expr.sourceSpan ?? op.sourceSpan));
|
|
19159
19400
|
}
|
|
19160
|
-
if (ops.length > 0) ;
|
|
19161
19401
|
OpList.replaceWithMany(op, ops);
|
|
19162
19402
|
break;
|
|
19163
19403
|
}
|
|
@@ -19165,53 +19405,6 @@ function extractI18nText(job) {
|
|
|
19165
19405
|
}
|
|
19166
19406
|
}
|
|
19167
19407
|
|
|
19168
|
-
/**
|
|
19169
|
-
* Extracts ICUs into i18n expressions.
|
|
19170
|
-
*/
|
|
19171
|
-
function extractI18nICUs(job) {
|
|
19172
|
-
for (const unit of job.units) {
|
|
19173
|
-
// Build a map of ICU to the i18n block they belong to, then remove the `Icu` ops.
|
|
19174
|
-
const icus = new Map();
|
|
19175
|
-
let currentI18nId = null;
|
|
19176
|
-
let currentI18nSlot = null;
|
|
19177
|
-
for (const op of unit.create) {
|
|
19178
|
-
switch (op.kind) {
|
|
19179
|
-
case OpKind.I18nStart:
|
|
19180
|
-
currentI18nId = op.xref;
|
|
19181
|
-
currentI18nSlot = op.handle;
|
|
19182
|
-
break;
|
|
19183
|
-
case OpKind.I18nEnd:
|
|
19184
|
-
currentI18nId = null;
|
|
19185
|
-
currentI18nSlot = null;
|
|
19186
|
-
break;
|
|
19187
|
-
case OpKind.Icu:
|
|
19188
|
-
if (currentI18nId === null) {
|
|
19189
|
-
throw Error('Unexpected ICU outside of an i18n block.');
|
|
19190
|
-
}
|
|
19191
|
-
icus.set(op.xref, { message: op.message, i18nBlockId: currentI18nId, i18nBlockSlot: currentI18nSlot });
|
|
19192
|
-
OpList.remove(op);
|
|
19193
|
-
break;
|
|
19194
|
-
}
|
|
19195
|
-
}
|
|
19196
|
-
// Replace the `IcuUpdate` ops with `i18nExpr` ops.
|
|
19197
|
-
for (const op of unit.update) {
|
|
19198
|
-
switch (op.kind) {
|
|
19199
|
-
case OpKind.IcuUpdate:
|
|
19200
|
-
const { message, i18nBlockId, i18nBlockSlot } = icus.get(op.xref);
|
|
19201
|
-
const icuNode = message.nodes.find((n) => n instanceof Icu);
|
|
19202
|
-
if (icuNode === undefined) {
|
|
19203
|
-
throw Error('Could not find ICU in i18n AST');
|
|
19204
|
-
}
|
|
19205
|
-
if (icuNode.expressionPlaceholder === undefined) {
|
|
19206
|
-
throw Error('ICU is missing an i18n placeholder');
|
|
19207
|
-
}
|
|
19208
|
-
OpList.replace(op, createI18nExpressionOp(i18nBlockId, i18nBlockSlot, new LexicalReadExpr(icuNode.expression), icuNode.expressionPlaceholder, I18nParamResolutionTime.Postproccessing, null));
|
|
19209
|
-
break;
|
|
19210
|
-
}
|
|
19211
|
-
}
|
|
19212
|
-
}
|
|
19213
|
-
}
|
|
19214
|
-
|
|
19215
19408
|
/**
|
|
19216
19409
|
* Lifts local reference declarations on element-like structures within each view into an entry in
|
|
19217
19410
|
* the `consts` array for the whole component.
|
|
@@ -19246,6 +19439,57 @@ function serializeLocalRefs(refs) {
|
|
|
19246
19439
|
return literalArr(constRefs);
|
|
19247
19440
|
}
|
|
19248
19441
|
|
|
19442
|
+
/**
|
|
19443
|
+
* Merge i18n contexts for child i18n blocks into their ancestor root contexts.
|
|
19444
|
+
*/
|
|
19445
|
+
function mergeI18nContexts(job) {
|
|
19446
|
+
// Record all of the i18n and extracted message ops for use later.
|
|
19447
|
+
const i18nOps = new Map();
|
|
19448
|
+
const i18nContexts = new Map();
|
|
19449
|
+
for (const unit of job.units) {
|
|
19450
|
+
for (const op of unit.create) {
|
|
19451
|
+
switch (op.kind) {
|
|
19452
|
+
case OpKind.I18nStart:
|
|
19453
|
+
if (!op.context) {
|
|
19454
|
+
throw Error('I18n op should have its context set.');
|
|
19455
|
+
}
|
|
19456
|
+
i18nOps.set(op.xref, op);
|
|
19457
|
+
break;
|
|
19458
|
+
case OpKind.I18nContext:
|
|
19459
|
+
i18nContexts.set(op.xref, op);
|
|
19460
|
+
break;
|
|
19461
|
+
}
|
|
19462
|
+
}
|
|
19463
|
+
}
|
|
19464
|
+
// For each non-root i18n op, merge its context into the root i18n op's context.
|
|
19465
|
+
for (const childI18nOp of i18nOps.values()) {
|
|
19466
|
+
if (childI18nOp.xref !== childI18nOp.root) {
|
|
19467
|
+
const childContext = i18nContexts.get(childI18nOp.context);
|
|
19468
|
+
const rootI18nOp = i18nOps.get(childI18nOp.root);
|
|
19469
|
+
const rootContext = i18nContexts.get(rootI18nOp.context);
|
|
19470
|
+
mergeParams(rootContext.params, childContext.params);
|
|
19471
|
+
mergeParams(rootContext.postprocessingParams, childContext.postprocessingParams);
|
|
19472
|
+
}
|
|
19473
|
+
}
|
|
19474
|
+
}
|
|
19475
|
+
/**
|
|
19476
|
+
* Merges the params in the `from` map to into the `to` map.
|
|
19477
|
+
*/
|
|
19478
|
+
function mergeParams(to, from) {
|
|
19479
|
+
for (const [placeholder, fromValues] of from) {
|
|
19480
|
+
const toValues = to.get(placeholder) || [];
|
|
19481
|
+
// TODO(mmalerba): Child element close tag params should be prepended to maintain the same order
|
|
19482
|
+
// as TemplateDefinitionBuilder. Can be cleaned up when compatibility is no longer required.
|
|
19483
|
+
const flags = fromValues[0].flags;
|
|
19484
|
+
if ((flags & I18nParamValueFlags.CloseTag) && !(flags & I18nParamValueFlags.OpenTag)) {
|
|
19485
|
+
to.set(placeholder, [...fromValues, ...toValues]);
|
|
19486
|
+
}
|
|
19487
|
+
else {
|
|
19488
|
+
to.set(placeholder, [...toValues, ...fromValues]);
|
|
19489
|
+
}
|
|
19490
|
+
}
|
|
19491
|
+
}
|
|
19492
|
+
|
|
19249
19493
|
/**
|
|
19250
19494
|
* Change namespaces between HTML, SVG and MathML, depending on the next element.
|
|
19251
19495
|
*/
|
|
@@ -19876,7 +20120,9 @@ function createVariadicPipes(job) {
|
|
|
19876
20120
|
|
|
19877
20121
|
/**
|
|
19878
20122
|
* Propagate i18n blocks down through child templates that act as placeholders in the root i18n
|
|
19879
|
-
* message.
|
|
20123
|
+
* message. Specifically, perform an in-order traversal of all the views, and add i18nStart/i18nEnd
|
|
20124
|
+
* op pairs into descending views. Also, assign an increasing sub-template index to each
|
|
20125
|
+
* descending view.
|
|
19880
20126
|
*/
|
|
19881
20127
|
function propagateI18nBlocks(job) {
|
|
19882
20128
|
propagateI18nBlocksToTemplates(job.root, 0);
|
|
@@ -19923,59 +20169,6 @@ function wrapTemplateWithI18n(unit, parentI18n) {
|
|
|
19923
20169
|
}
|
|
19924
20170
|
}
|
|
19925
20171
|
|
|
19926
|
-
/**
|
|
19927
|
-
* Propagate extractd message placeholders up to their root extracted message op.
|
|
19928
|
-
*/
|
|
19929
|
-
function propogateI18nPlaceholders(job) {
|
|
19930
|
-
// Record all of the i18n and extracted message ops for use later.
|
|
19931
|
-
const i18nOps = new Map();
|
|
19932
|
-
const extractedMessageOps = new Map();
|
|
19933
|
-
for (const unit of job.units) {
|
|
19934
|
-
for (const op of unit.create) {
|
|
19935
|
-
switch (op.kind) {
|
|
19936
|
-
case OpKind.I18nStart:
|
|
19937
|
-
i18nOps.set(op.xref, op);
|
|
19938
|
-
break;
|
|
19939
|
-
case OpKind.ExtractedMessage:
|
|
19940
|
-
extractedMessageOps.set(op.owner, op);
|
|
19941
|
-
break;
|
|
19942
|
-
}
|
|
19943
|
-
}
|
|
19944
|
-
}
|
|
19945
|
-
// For each non-root message, merge its params into the root message's params.
|
|
19946
|
-
for (const [xref, childExtractedMessageOp] of extractedMessageOps) {
|
|
19947
|
-
if (!childExtractedMessageOp.isRoot) {
|
|
19948
|
-
const i18nOp = i18nOps.get(xref);
|
|
19949
|
-
if (i18nOp === undefined) {
|
|
19950
|
-
throw Error('Could not find owner i18n block for extracted message.');
|
|
19951
|
-
}
|
|
19952
|
-
const rootExtractedMessageOp = extractedMessageOps.get(i18nOp.root);
|
|
19953
|
-
if (rootExtractedMessageOp === undefined) {
|
|
19954
|
-
throw Error('Could not find extracted message op for root i18n block.');
|
|
19955
|
-
}
|
|
19956
|
-
mergeParams(rootExtractedMessageOp.params, childExtractedMessageOp.params);
|
|
19957
|
-
mergeParams(rootExtractedMessageOp.postprocessingParams, childExtractedMessageOp.postprocessingParams);
|
|
19958
|
-
}
|
|
19959
|
-
}
|
|
19960
|
-
}
|
|
19961
|
-
/**
|
|
19962
|
-
* Merges the params in the `from` map to into the `to` map.
|
|
19963
|
-
*/
|
|
19964
|
-
function mergeParams(to, from) {
|
|
19965
|
-
for (const [placeholder, fromValues] of from) {
|
|
19966
|
-
const toValues = to.get(placeholder) || [];
|
|
19967
|
-
// TODO(mmalerba): Child element close tag params should be prepended to maintain the same order
|
|
19968
|
-
// as TemplateDefinitionBuilder. Can be cleaned up when compatibility is no longer required.
|
|
19969
|
-
const flags = fromValues[0].flags;
|
|
19970
|
-
if ((flags & I18nParamValueFlags.CloseTag) && !(flags & I18nParamValueFlags.OpenTag)) {
|
|
19971
|
-
to.set(placeholder, [...fromValues, ...toValues]);
|
|
19972
|
-
}
|
|
19973
|
-
else {
|
|
19974
|
-
to.set(placeholder, [...toValues, ...fromValues]);
|
|
19975
|
-
}
|
|
19976
|
-
}
|
|
19977
|
-
}
|
|
19978
|
-
|
|
19979
20172
|
function extractPureFunctions(job) {
|
|
19980
20173
|
for (const view of job.units) {
|
|
19981
20174
|
for (const op of view.ops()) {
|
|
@@ -20105,13 +20298,21 @@ function elementContainer(slot, constIndex, localRefIndex, sourceSpan) {
|
|
|
20105
20298
|
function elementContainerEnd() {
|
|
20106
20299
|
return call(Identifiers.elementContainerEnd, [], null);
|
|
20107
20300
|
}
|
|
20108
|
-
function template(slot, templateFnRef, decls, vars, tag, constIndex, sourceSpan) {
|
|
20109
|
-
const args = [
|
|
20110
|
-
|
|
20111
|
-
|
|
20112
|
-
|
|
20113
|
-
|
|
20114
|
-
|
|
20301
|
+
function template(slot, templateFnRef, decls, vars, tag, constIndex, localRefs, sourceSpan) {
|
|
20302
|
+
const args = [
|
|
20303
|
+
literal(slot),
|
|
20304
|
+
templateFnRef,
|
|
20305
|
+
literal(decls),
|
|
20306
|
+
literal(vars),
|
|
20307
|
+
literal(tag),
|
|
20308
|
+
literal(constIndex),
|
|
20309
|
+
];
|
|
20310
|
+
if (localRefs !== null) {
|
|
20311
|
+
args.push(literal(localRefs));
|
|
20312
|
+
args.push(importExpr(Identifiers.templateRefExtractor));
|
|
20313
|
+
}
|
|
20314
|
+
while (args[args.length - 1].isEquivalent(NULL_EXPR)) {
|
|
20315
|
+
args.pop();
|
|
20115
20316
|
}
|
|
20116
20317
|
return call(Identifiers.templateCreate, args, sourceSpan);
|
|
20117
20318
|
}
|
|
@@ -20185,7 +20386,7 @@ function defer(selfSlot, primarySlot, dependencyResolverFn, loadingSlot, placeho
|
|
|
20185
20386
|
const args = [
|
|
20186
20387
|
literal(selfSlot),
|
|
20187
20388
|
literal(primarySlot),
|
|
20188
|
-
literal(
|
|
20389
|
+
dependencyResolverFn ?? literal(null),
|
|
20189
20390
|
literal(loadingSlot),
|
|
20190
20391
|
literal(placeholderSlot),
|
|
20191
20392
|
literal(errorSlot),
|
|
@@ -20265,6 +20466,9 @@ function repeaterCreate(slot, viewFnName, decls, vars, tag, constIndex, trackByF
|
|
|
20265
20466
|
function repeater(metadataSlot, collection, sourceSpan) {
|
|
20266
20467
|
return call(Identifiers.repeater, [literal(metadataSlot), collection], sourceSpan);
|
|
20267
20468
|
}
|
|
20469
|
+
function deferWhen(prefetch, expr, sourceSpan) {
|
|
20470
|
+
return call(prefetch ? Identifiers.deferPrefetchWhen : Identifiers.deferWhen, [expr], sourceSpan);
|
|
20471
|
+
}
|
|
20268
20472
|
function i18n(slot, constIndex, subTemplateIndex) {
|
|
20269
20473
|
const args = [literal(slot), literal(constIndex)];
|
|
20270
20474
|
if (subTemplateIndex) {
|
|
@@ -20665,8 +20869,11 @@ function reifyCreateOperations(unit, ops) {
|
|
|
20665
20869
|
if (!(unit instanceof ViewCompilationUnit)) {
|
|
20666
20870
|
throw new Error(`AssertionError: must be compiling a component`);
|
|
20667
20871
|
}
|
|
20872
|
+
if (Array.isArray(op.localRefs)) {
|
|
20873
|
+
throw new Error(`AssertionError: local refs array should have been extracted into a constant`);
|
|
20874
|
+
}
|
|
20668
20875
|
const childView = unit.job.views.get(op.xref);
|
|
20669
|
-
OpList.replace(op, template(op.handle.slot, variable(childView.fnName), childView.decls, childView.vars, op.tag, op.attributes, op.sourceSpan));
|
|
20876
|
+
OpList.replace(op, template(op.handle.slot, variable(childView.fnName), childView.decls, childView.vars, op.tag, op.attributes, op.localRefs, op.sourceSpan));
|
|
20670
20877
|
break;
|
|
20671
20878
|
case OpKind.DisableBindings:
|
|
20672
20879
|
OpList.replace(op, disableBindings());
|
|
@@ -20705,7 +20912,7 @@ function reifyCreateOperations(unit, ops) {
|
|
|
20705
20912
|
break;
|
|
20706
20913
|
case OpKind.Defer:
|
|
20707
20914
|
const timerScheduling = !!op.loadingMinimumTime || !!op.loadingAfterTime || !!op.placeholderMinimumTime;
|
|
20708
|
-
OpList.replace(op, defer(op.handle.slot, op.mainSlot.slot,
|
|
20915
|
+
OpList.replace(op, defer(op.handle.slot, op.mainSlot.slot, op.resolverFn, op.loadingSlot?.slot ?? null, op.placeholderSlot?.slot ?? null, op.errorSlot?.slot ?? null, op.loadingConfig, op.placeholderConfig, timerScheduling, op.sourceSpan));
|
|
20709
20916
|
break;
|
|
20710
20917
|
case OpKind.DeferOn:
|
|
20711
20918
|
let args = [];
|
|
@@ -20823,7 +21030,7 @@ function reifyUpdateOperations(_unit, ops) {
|
|
|
20823
21030
|
OpList.replace(op, i18nExp(op.expression, op.sourceSpan));
|
|
20824
21031
|
break;
|
|
20825
21032
|
case OpKind.I18nApply:
|
|
20826
|
-
OpList.replace(op, i18nApply(op.
|
|
21033
|
+
OpList.replace(op, i18nApply(op.handle.slot, op.sourceSpan));
|
|
20827
21034
|
break;
|
|
20828
21035
|
case OpKind.InterpolateText:
|
|
20829
21036
|
OpList.replace(op, textInterpolate(op.interpolation.strings, op.interpolation.expressions, op.sourceSpan));
|
|
@@ -20867,6 +21074,9 @@ function reifyUpdateOperations(_unit, ops) {
|
|
|
20867
21074
|
case OpKind.Repeater:
|
|
20868
21075
|
OpList.replace(op, repeater(op.targetSlot.slot, op.collection, op.sourceSpan));
|
|
20869
21076
|
break;
|
|
21077
|
+
case OpKind.DeferWhen:
|
|
21078
|
+
OpList.replace(op, deferWhen(op.prefetch, op.expr, op.sourceSpan));
|
|
21079
|
+
break;
|
|
20870
21080
|
case OpKind.Statement:
|
|
20871
21081
|
// Pass statement operations directly through.
|
|
20872
21082
|
break;
|
|
@@ -20977,6 +21187,25 @@ function removeEmptyBindings(job) {
|
|
|
20977
21187
|
}
|
|
20978
21188
|
}
|
|
20979
21189
|
|
|
21190
|
+
/**
|
|
21191
|
+
* Remove the i18n context ops after they are no longer needed, and null out references to them to
|
|
21192
|
+
* be safe.
|
|
21193
|
+
*/
|
|
21194
|
+
function removeI18nContexts(job) {
|
|
21195
|
+
for (const unit of job.units) {
|
|
21196
|
+
for (const op of unit.create) {
|
|
21197
|
+
switch (op.kind) {
|
|
21198
|
+
case OpKind.I18nContext:
|
|
21199
|
+
OpList.remove(op);
|
|
21200
|
+
break;
|
|
21201
|
+
case OpKind.I18nStart:
|
|
21202
|
+
op.context = null;
|
|
21203
|
+
break;
|
|
21204
|
+
}
|
|
21205
|
+
}
|
|
21206
|
+
}
|
|
21207
|
+
}
|
|
21208
|
+
|
|
20980
21209
|
/**
|
|
20981
21210
|
* Inside the body of a repeater, certain context variables (such as `$first`) are ambiently
|
|
20982
21211
|
* available. This phase finds those variable usages, and replaces them with the appropriate
|
|
@@ -21091,14 +21320,14 @@ function transformDollarEvent(unit, ops) {
|
|
|
21091
21320
|
* Resolve the element placeholders in i18n messages.
|
|
21092
21321
|
*/
|
|
21093
21322
|
function resolveI18nElementPlaceholders(job) {
|
|
21094
|
-
// Record all of the element and
|
|
21095
|
-
const
|
|
21323
|
+
// Record all of the element and i18n context ops for use later.
|
|
21324
|
+
const i18nContexts = new Map();
|
|
21096
21325
|
const elements = new Map();
|
|
21097
21326
|
for (const unit of job.units) {
|
|
21098
21327
|
for (const op of unit.create) {
|
|
21099
21328
|
switch (op.kind) {
|
|
21100
|
-
case OpKind.
|
|
21101
|
-
|
|
21329
|
+
case OpKind.I18nContext:
|
|
21330
|
+
i18nContexts.set(op.xref, op);
|
|
21102
21331
|
break;
|
|
21103
21332
|
case OpKind.ElementStart:
|
|
21104
21333
|
elements.set(op.xref, op);
|
|
@@ -21107,16 +21336,16 @@ function resolveI18nElementPlaceholders(job) {
|
|
|
21107
21336
|
}
|
|
21108
21337
|
}
|
|
21109
21338
|
for (const unit of job.units) {
|
|
21110
|
-
// Track the current i18n op and corresponding
|
|
21111
|
-
//
|
|
21339
|
+
// Track the current i18n op and corresponding i18n context op as we step through the creation
|
|
21340
|
+
// IR.
|
|
21112
21341
|
let currentOps = null;
|
|
21113
21342
|
for (const op of unit.create) {
|
|
21114
21343
|
switch (op.kind) {
|
|
21115
21344
|
case OpKind.I18nStart:
|
|
21116
|
-
if (!
|
|
21117
|
-
throw Error('Could not find
|
|
21345
|
+
if (!op.context) {
|
|
21346
|
+
throw Error('Could not find i18n context for i18n op');
|
|
21118
21347
|
}
|
|
21119
|
-
currentOps = {
|
|
21348
|
+
currentOps = { i18nBlock: op, i18nContext: i18nContexts.get(op.context) };
|
|
21120
21349
|
break;
|
|
21121
21350
|
case OpKind.I18nEnd:
|
|
21122
21351
|
currentOps = null;
|
|
@@ -21135,7 +21364,7 @@ function resolveI18nElementPlaceholders(job) {
|
|
|
21135
21364
|
if (closeName === '') {
|
|
21136
21365
|
flags |= I18nParamValueFlags.CloseTag;
|
|
21137
21366
|
}
|
|
21138
|
-
addParam(currentOps.
|
|
21367
|
+
addParam(currentOps.i18nContext.params, startName, op.handle.slot, currentOps.i18nBlock.subTemplateIndex, flags);
|
|
21139
21368
|
}
|
|
21140
21369
|
break;
|
|
21141
21370
|
case OpKind.ElementEnd:
|
|
@@ -21149,7 +21378,7 @@ function resolveI18nElementPlaceholders(job) {
|
|
|
21149
21378
|
const { closeName } = startOp.i18nPlaceholder;
|
|
21150
21379
|
// Self-closing tags don't have a closing tag placeholder.
|
|
21151
21380
|
if (closeName !== '') {
|
|
21152
|
-
addParam(currentOps.
|
|
21381
|
+
addParam(currentOps.i18nContext.params, closeName, startOp.handle.slot, currentOps.i18nBlock.subTemplateIndex, I18nParamValueFlags.ElementTag | I18nParamValueFlags.CloseTag);
|
|
21153
21382
|
}
|
|
21154
21383
|
}
|
|
21155
21384
|
break;
|
|
@@ -21160,9 +21389,9 @@ function resolveI18nElementPlaceholders(job) {
|
|
|
21160
21389
|
if (currentOps === null) {
|
|
21161
21390
|
throw Error('i18n tag placeholder should only occur inside an i18n block');
|
|
21162
21391
|
}
|
|
21163
|
-
const subTemplateIndex = getSubTemplateIndexForTemplateTag(job, currentOps.
|
|
21164
|
-
addParam(currentOps.
|
|
21165
|
-
addParam(currentOps.
|
|
21392
|
+
const subTemplateIndex = getSubTemplateIndexForTemplateTag(job, currentOps.i18nBlock, op);
|
|
21393
|
+
addParam(currentOps.i18nContext.params, op.i18nPlaceholder.startName, op.handle.slot, subTemplateIndex, I18nParamValueFlags.TemplateTag);
|
|
21394
|
+
addParam(currentOps.i18nContext.params, op.i18nPlaceholder.closeName, op.handle.slot, subTemplateIndex, I18nParamValueFlags.TemplateTag | I18nParamValueFlags.CloseTag);
|
|
21166
21395
|
}
|
|
21167
21396
|
break;
|
|
21168
21397
|
}
|
|
@@ -21192,47 +21421,37 @@ function addParam(params, placeholder, value, subTemplateIndex, flags = I18nPara
|
|
|
21192
21421
|
* Resolve the i18n expression placeholders in i18n messages.
|
|
21193
21422
|
*/
|
|
21194
21423
|
function resolveI18nExpressionPlaceholders(job) {
|
|
21195
|
-
// Record all of the i18n and
|
|
21196
|
-
const
|
|
21197
|
-
const
|
|
21424
|
+
// Record all of the i18n context ops, and the sub-template index for each i18n op.
|
|
21425
|
+
const subTemplateIndicies = new Map();
|
|
21426
|
+
const i18nContexts = new Map();
|
|
21198
21427
|
for (const unit of job.units) {
|
|
21199
21428
|
for (const op of unit.create) {
|
|
21200
21429
|
switch (op.kind) {
|
|
21201
21430
|
case OpKind.I18nStart:
|
|
21202
|
-
|
|
21431
|
+
subTemplateIndicies.set(op.xref, op.subTemplateIndex);
|
|
21203
21432
|
break;
|
|
21204
|
-
case OpKind.
|
|
21205
|
-
|
|
21433
|
+
case OpKind.I18nContext:
|
|
21434
|
+
i18nContexts.set(op.xref, op);
|
|
21206
21435
|
break;
|
|
21207
21436
|
}
|
|
21208
21437
|
}
|
|
21209
21438
|
}
|
|
21210
|
-
// Keep track of the next available expression index per i18n
|
|
21439
|
+
// Keep track of the next available expression index per i18n context.
|
|
21211
21440
|
const expressionIndices = new Map();
|
|
21212
21441
|
for (const unit of job.units) {
|
|
21213
21442
|
for (const op of unit.update) {
|
|
21214
21443
|
if (op.kind === OpKind.I18nExpression) {
|
|
21215
|
-
const
|
|
21216
|
-
|
|
21217
|
-
|
|
21218
|
-
throw Error('Cannot find corresponding i18n block for i18nExpr');
|
|
21219
|
-
}
|
|
21220
|
-
const extractedMessageOp = extractedMessageOps.get(i18nOp.xref);
|
|
21221
|
-
if (!extractedMessageOp) {
|
|
21222
|
-
throw Error('Cannot find extracted message for i18n block');
|
|
21223
|
-
}
|
|
21444
|
+
const index = expressionIndices.get(op.context) || 0;
|
|
21445
|
+
const i18nContext = i18nContexts.get(op.context);
|
|
21446
|
+
const subTemplateIndex = subTemplateIndicies.get(i18nContext.i18nBlock);
|
|
21224
21447
|
// Add the expression index in the appropriate params map.
|
|
21225
21448
|
const params = op.resolutionTime === I18nParamResolutionTime.Creation ?
|
|
21226
|
-
|
|
21227
|
-
|
|
21449
|
+
i18nContext.params :
|
|
21450
|
+
i18nContext.postprocessingParams;
|
|
21228
21451
|
const values = params.get(op.i18nPlaceholder) || [];
|
|
21229
|
-
values.push({
|
|
21230
|
-
value: index,
|
|
21231
|
-
subTemplateIndex: i18nOp.subTemplateIndex,
|
|
21232
|
-
flags: I18nParamValueFlags.None
|
|
21233
|
-
});
|
|
21452
|
+
values.push({ value: index, subTemplateIndex: subTemplateIndex, flags: I18nParamValueFlags.None });
|
|
21234
21453
|
params.set(op.i18nPlaceholder, values);
|
|
21235
|
-
expressionIndices.set(op.
|
|
21454
|
+
expressionIndices.set(op.context, index + 1);
|
|
21236
21455
|
}
|
|
21237
21456
|
}
|
|
21238
21457
|
}
|
|
@@ -22324,6 +22543,7 @@ function wrapI18nIcus(job) {
|
|
|
22324
22543
|
{ kind: CompilationJobKind.Both, fn: specializeBindings },
|
|
22325
22544
|
{ kind: CompilationJobKind.Tmpl, fn: propagateI18nBlocks },
|
|
22326
22545
|
{ kind: CompilationJobKind.Tmpl, fn: wrapI18nIcus },
|
|
22546
|
+
{ kind: CompilationJobKind.Tmpl, fn: createI18nContexts },
|
|
22327
22547
|
{ kind: CompilationJobKind.Both, fn: extractAttributes },
|
|
22328
22548
|
{ kind: CompilationJobKind.Both, fn: parseExtractedStyles },
|
|
22329
22549
|
{ kind: CompilationJobKind.Tmpl, fn: removeEmptyBindings },
|
|
@@ -22333,7 +22553,7 @@ function wrapI18nIcus(job) {
|
|
|
22333
22553
|
{ kind: CompilationJobKind.Tmpl, fn: createPipes },
|
|
22334
22554
|
{ kind: CompilationJobKind.Tmpl, fn: configureDeferInstructions },
|
|
22335
22555
|
{ kind: CompilationJobKind.Tmpl, fn: extractI18nText },
|
|
22336
|
-
{ kind: CompilationJobKind.Tmpl, fn:
|
|
22556
|
+
{ kind: CompilationJobKind.Tmpl, fn: createI18nIcuExpressions },
|
|
22337
22557
|
{ kind: CompilationJobKind.Tmpl, fn: applyI18nExpressions },
|
|
22338
22558
|
{ kind: CompilationJobKind.Tmpl, fn: createVariadicPipes },
|
|
22339
22559
|
{ kind: CompilationJobKind.Both, fn: generatePureLiteralStructures },
|
|
@@ -22354,16 +22574,17 @@ function wrapI18nIcus(job) {
|
|
|
22354
22574
|
{ kind: CompilationJobKind.Both, fn: expandSafeReads },
|
|
22355
22575
|
{ kind: CompilationJobKind.Both, fn: generateTemporaryVariables },
|
|
22356
22576
|
{ kind: CompilationJobKind.Tmpl, fn: allocateSlots },
|
|
22357
|
-
{ kind: CompilationJobKind.Tmpl, fn:
|
|
22577
|
+
{ kind: CompilationJobKind.Tmpl, fn: createDeferDepsFns },
|
|
22358
22578
|
{ kind: CompilationJobKind.Tmpl, fn: resolveI18nElementPlaceholders },
|
|
22359
22579
|
{ kind: CompilationJobKind.Tmpl, fn: resolveI18nExpressionPlaceholders },
|
|
22360
|
-
{ kind: CompilationJobKind.Tmpl, fn:
|
|
22361
|
-
{ kind: CompilationJobKind.Tmpl, fn:
|
|
22580
|
+
{ kind: CompilationJobKind.Tmpl, fn: mergeI18nContexts },
|
|
22581
|
+
{ kind: CompilationJobKind.Tmpl, fn: extractI18nMessages },
|
|
22362
22582
|
{ kind: CompilationJobKind.Tmpl, fn: generateTrackFns },
|
|
22363
22583
|
{ kind: CompilationJobKind.Tmpl, fn: collectI18nConsts },
|
|
22364
22584
|
{ kind: CompilationJobKind.Tmpl, fn: collectConstExpressions },
|
|
22365
22585
|
{ kind: CompilationJobKind.Both, fn: collectElementConsts },
|
|
22366
22586
|
{ kind: CompilationJobKind.Tmpl, fn: assignI18nSlotDependencies },
|
|
22587
|
+
{ kind: CompilationJobKind.Tmpl, fn: removeI18nContexts },
|
|
22367
22588
|
{ kind: CompilationJobKind.Both, fn: countVariables },
|
|
22368
22589
|
{ kind: CompilationJobKind.Tmpl, fn: generateAdvance },
|
|
22369
22590
|
{ kind: CompilationJobKind.Both, fn: optimizeVariables },
|
|
@@ -26224,7 +26445,9 @@ class TemplateDefinitionBuilder {
|
|
|
26224
26445
|
// that we don't copy any bound attributes since they don't participate in content projection
|
|
26225
26446
|
// and they can be used in directive matching (in the case of `Template.templateAttrs`).
|
|
26226
26447
|
if (root !== null) {
|
|
26227
|
-
|
|
26448
|
+
const name = root instanceof Element$1 ? root.name : root.tagName;
|
|
26449
|
+
// Don't pass along `ng-template` tag name since it enables directive matching.
|
|
26450
|
+
tagName = name === NG_TEMPLATE_TAG_NAME ? null : name;
|
|
26228
26451
|
attrsExprs =
|
|
26229
26452
|
this.getAttributeExpressions(NG_TEMPLATE_TAG_NAME, root.attributes, root.inputs, []);
|
|
26230
26453
|
}
|
|
@@ -29461,7 +29684,7 @@ function publishFacade(global) {
|
|
|
29461
29684
|
* @description
|
|
29462
29685
|
* Entry point for all public APIs of the compiler package.
|
|
29463
29686
|
*/
|
|
29464
|
-
const VERSION = new Version('17.0.0
|
|
29687
|
+
const VERSION = new Version('17.0.0');
|
|
29465
29688
|
|
|
29466
29689
|
class CompilerConfig {
|
|
29467
29690
|
constructor({ defaultEncapsulation = exports.ViewEncapsulation.Emulated, preserveWhitespaces, strictInjectionParameters } = {}) {
|
|
@@ -30991,7 +31214,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$6 = '12.0.0';
|
|
|
30991
31214
|
function compileDeclareClassMetadata(metadata) {
|
|
30992
31215
|
const definitionMap = new DefinitionMap();
|
|
30993
31216
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$6));
|
|
30994
|
-
definitionMap.set('version', literal('17.0.0
|
|
31217
|
+
definitionMap.set('version', literal('17.0.0'));
|
|
30995
31218
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
30996
31219
|
definitionMap.set('type', metadata.type);
|
|
30997
31220
|
definitionMap.set('decorators', metadata.decorators);
|
|
@@ -31099,7 +31322,7 @@ function createDirectiveDefinitionMap(meta) {
|
|
|
31099
31322
|
// in 16.1 is actually used.
|
|
31100
31323
|
const minVersion = hasTransformFunctions ? MINIMUM_PARTIAL_LINKER_VERSION$5 : '14.0.0';
|
|
31101
31324
|
definitionMap.set('minVersion', literal(minVersion));
|
|
31102
|
-
definitionMap.set('version', literal('17.0.0
|
|
31325
|
+
definitionMap.set('version', literal('17.0.0'));
|
|
31103
31326
|
// e.g. `type: MyDirective`
|
|
31104
31327
|
definitionMap.set('type', meta.type.value);
|
|
31105
31328
|
if (meta.isStandalone) {
|
|
@@ -31373,7 +31596,7 @@ const MINIMUM_PARTIAL_LINKER_VERSION$4 = '12.0.0';
|
|
|
31373
31596
|
function compileDeclareFactoryFunction(meta) {
|
|
31374
31597
|
const definitionMap = new DefinitionMap();
|
|
31375
31598
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$4));
|
|
31376
|
-
definitionMap.set('version', literal('17.0.0
|
|
31599
|
+
definitionMap.set('version', literal('17.0.0'));
|
|
31377
31600
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
31378
31601
|
definitionMap.set('type', meta.type.value);
|
|
31379
31602
|
definitionMap.set('deps', compileDependencies(meta.deps));
|
|
@@ -31408,7 +31631,7 @@ function compileDeclareInjectableFromMetadata(meta) {
|
|
|
31408
31631
|
function createInjectableDefinitionMap(meta) {
|
|
31409
31632
|
const definitionMap = new DefinitionMap();
|
|
31410
31633
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$3));
|
|
31411
|
-
definitionMap.set('version', literal('17.0.0
|
|
31634
|
+
definitionMap.set('version', literal('17.0.0'));
|
|
31412
31635
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
31413
31636
|
definitionMap.set('type', meta.type.value);
|
|
31414
31637
|
// Only generate providedIn property if it has a non-null value
|
|
@@ -31459,7 +31682,7 @@ function compileDeclareInjectorFromMetadata(meta) {
|
|
|
31459
31682
|
function createInjectorDefinitionMap(meta) {
|
|
31460
31683
|
const definitionMap = new DefinitionMap();
|
|
31461
31684
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$2));
|
|
31462
|
-
definitionMap.set('version', literal('17.0.0
|
|
31685
|
+
definitionMap.set('version', literal('17.0.0'));
|
|
31463
31686
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
31464
31687
|
definitionMap.set('type', meta.type.value);
|
|
31465
31688
|
definitionMap.set('providers', meta.providers);
|
|
@@ -31492,7 +31715,7 @@ function createNgModuleDefinitionMap(meta) {
|
|
|
31492
31715
|
throw new Error('Invalid path! Local compilation mode should not get into the partial compilation path');
|
|
31493
31716
|
}
|
|
31494
31717
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION$1));
|
|
31495
|
-
definitionMap.set('version', literal('17.0.0
|
|
31718
|
+
definitionMap.set('version', literal('17.0.0'));
|
|
31496
31719
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
31497
31720
|
definitionMap.set('type', meta.type.value);
|
|
31498
31721
|
// We only generate the keys in the metadata if the arrays contain values.
|
|
@@ -31543,7 +31766,7 @@ function compileDeclarePipeFromMetadata(meta) {
|
|
|
31543
31766
|
function createPipeDefinitionMap(meta) {
|
|
31544
31767
|
const definitionMap = new DefinitionMap();
|
|
31545
31768
|
definitionMap.set('minVersion', literal(MINIMUM_PARTIAL_LINKER_VERSION));
|
|
31546
|
-
definitionMap.set('version', literal('17.0.0
|
|
31769
|
+
definitionMap.set('version', literal('17.0.0'));
|
|
31547
31770
|
definitionMap.set('ngImport', importExpr(Identifiers.core));
|
|
31548
31771
|
// e.g. `type: MyPipe`
|
|
31549
31772
|
definitionMap.set('type', meta.type.value);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-eslint/bundled-angular-compiler",
|
|
3
|
-
"version": "17.0.0
|
|
3
|
+
"version": "17.0.0",
|
|
4
4
|
"description": "A CJS bundled version of @angular/compiler",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -15,5 +15,5 @@
|
|
|
15
15
|
"package.json",
|
|
16
16
|
"README.md"
|
|
17
17
|
],
|
|
18
|
-
"gitHead": "
|
|
18
|
+
"gitHead": "7121d78c95eefc01c306503b22cc9c7526c50633"
|
|
19
19
|
}
|