@angular/compiler 16.2.2 → 17.0.0-next.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.
- package/esm2022/src/compiler.mjs +3 -3
- package/esm2022/src/render3/partial/class_metadata.mjs +1 -1
- package/esm2022/src/render3/partial/component.mjs +4 -1
- package/esm2022/src/render3/partial/directive.mjs +1 -1
- 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/r3_ast.mjs +112 -9
- package/esm2022/src/render3/r3_class_metadata_compiler.mjs +55 -1
- package/esm2022/src/render3/r3_control_flow.mjs +332 -0
- package/esm2022/src/render3/r3_deferred_blocks.mjs +16 -9
- package/esm2022/src/render3/r3_deferred_triggers.mjs +33 -19
- package/esm2022/src/render3/r3_identifiers.mjs +18 -1
- package/esm2022/src/render3/r3_template_transform.mjs +28 -7
- package/esm2022/src/render3/view/api.mjs +1 -1
- package/esm2022/src/render3/view/compiler.mjs +12 -2
- package/esm2022/src/render3/view/t2_binder.mjs +66 -5
- package/esm2022/src/render3/view/template.mjs +282 -59
- package/esm2022/src/render3/view/util.mjs +4 -2
- package/esm2022/src/template/pipeline/ir/index.mjs +2 -3
- package/esm2022/src/template/pipeline/ir/src/enums.mjs +41 -3
- package/esm2022/src/template/pipeline/ir/src/expression.mjs +11 -1
- package/esm2022/src/template/pipeline/ir/src/ops/create.mjs +16 -4
- package/esm2022/src/template/pipeline/ir/src/ops/update.mjs +5 -3
- package/esm2022/src/template/pipeline/src/emit.mjs +3 -1
- package/esm2022/src/template/pipeline/src/ingest.mjs +10 -10
- package/esm2022/src/template/pipeline/src/phases/attribute_extraction.mjs +43 -75
- package/esm2022/src/template/pipeline/src/phases/binding_specialization.mjs +2 -2
- package/esm2022/src/template/pipeline/src/phases/const_collection.mjs +90 -13
- package/esm2022/src/template/pipeline/src/phases/parse_extracted_styles.mjs +38 -0
- package/esm2022/src/version.mjs +1 -1
- package/fesm2022/compiler.mjs +1307 -430
- package/fesm2022/compiler.mjs.map +1 -1
- package/fesm2022/testing.mjs +1 -1
- package/index.d.ts +153 -5
- package/package.json +2 -2
- package/testing/index.d.ts +1 -1
- package/esm2022/src/template/pipeline/ir/src/element.mjs +0 -108
package/fesm2022/testing.mjs
CHANGED
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular
|
|
2
|
+
* @license Angular v17.0.0-next.1
|
|
3
3
|
* (c) 2010-2022 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -635,6 +635,27 @@ export declare function compileClassMetadata(metadata: R3ClassMetadata): outputA
|
|
|
635
635
|
|
|
636
636
|
export declare type CompileClassMetadataFn = (metadata: R3ClassMetadata) => outputAst.Expression;
|
|
637
637
|
|
|
638
|
+
/**
|
|
639
|
+
* Wraps the `setClassMetadata` function with extra logic that dynamically
|
|
640
|
+
* loads dependencies from `{#defer}` blocks.
|
|
641
|
+
*
|
|
642
|
+
* Generates a call like this:
|
|
643
|
+
* ```
|
|
644
|
+
* setClassMetadataAsync(type, () => {
|
|
645
|
+
* return [
|
|
646
|
+
* import('./cmp-a').then(m => m.CmpA);
|
|
647
|
+
* import('./cmp-b').then(m => m.CmpB);
|
|
648
|
+
* ];
|
|
649
|
+
* }, (CmpA, CmpB) => {
|
|
650
|
+
* setClassMetadata(type, decorators, ctorParameters, propParameters);
|
|
651
|
+
* });
|
|
652
|
+
* ```
|
|
653
|
+
*
|
|
654
|
+
* Similar to the `setClassMetadata` call, it's wrapped into the `ngDevMode`
|
|
655
|
+
* check to tree-shake away this code in production mode.
|
|
656
|
+
*/
|
|
657
|
+
export declare function compileComponentClassMetadata(metadata: R3ClassMetadata, deferrableTypes: Map<string, string>): outputAst.Expression;
|
|
658
|
+
|
|
638
659
|
/**
|
|
639
660
|
* Compile a component for the render3 runtime as defined by the `R3ComponentMetadata`.
|
|
640
661
|
*/
|
|
@@ -907,7 +928,8 @@ export declare const enum DeclarationListEmitMode {
|
|
|
907
928
|
* directives: function () { return [dirA, dirB].map(ng.resolveForwardRef); },
|
|
908
929
|
* ```
|
|
909
930
|
*/
|
|
910
|
-
ClosureResolved = 2
|
|
931
|
+
ClosureResolved = 2,
|
|
932
|
+
RuntimeResolved = 3
|
|
911
933
|
}
|
|
912
934
|
|
|
913
935
|
export declare interface DeclareComponentTemplateInfo {
|
|
@@ -979,6 +1001,16 @@ export declare interface DeferBlockTemplateDependency {
|
|
|
979
1001
|
importPath: string | null;
|
|
980
1002
|
}
|
|
981
1003
|
|
|
1004
|
+
declare interface DeferredBlockTriggers {
|
|
1005
|
+
when?: TmplAstBoundDeferredTrigger;
|
|
1006
|
+
idle?: TmplAstIdleDeferredTrigger;
|
|
1007
|
+
immediate?: TmplAstImmediateDeferredTrigger;
|
|
1008
|
+
hover?: TmplAstHoverDeferredTrigger;
|
|
1009
|
+
timer?: TmplAstTimerDeferredTrigger;
|
|
1010
|
+
interaction?: TmplAstInteractionDeferredTrigger;
|
|
1011
|
+
viewport?: TmplAstViewportDeferredTrigger;
|
|
1012
|
+
}
|
|
1013
|
+
|
|
982
1014
|
export declare function devOnlyGuardedExpression(expr: outputAst.Expression): outputAst.Expression;
|
|
983
1015
|
|
|
984
1016
|
/**
|
|
@@ -1308,6 +1340,15 @@ declare class FnParam {
|
|
|
1308
1340
|
clone(): FnParam;
|
|
1309
1341
|
}
|
|
1310
1342
|
|
|
1343
|
+
declare interface ForLoopBlockContext {
|
|
1344
|
+
$index?: string;
|
|
1345
|
+
$first?: string;
|
|
1346
|
+
$last?: string;
|
|
1347
|
+
$even?: string;
|
|
1348
|
+
$odd?: string;
|
|
1349
|
+
$count?: string;
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1311
1352
|
/**
|
|
1312
1353
|
* Specifies how a forward ref has been handled in a MaybeForwardRefExpression
|
|
1313
1354
|
*/
|
|
@@ -2889,6 +2930,12 @@ export declare interface R3ComponentMetadata<DeclarationT extends R3TemplateDepe
|
|
|
2889
2930
|
* Strategy used for detecting changes in the component.
|
|
2890
2931
|
*/
|
|
2891
2932
|
changeDetection?: ChangeDetectionStrategy;
|
|
2933
|
+
/**
|
|
2934
|
+
* The imports expression as appears on the component decorate for standalone component. This
|
|
2935
|
+
* field is currently needed only for local compilation, and so in other compilation modes it may
|
|
2936
|
+
* not be set. If component has empty array imports then this field is not set.
|
|
2937
|
+
*/
|
|
2938
|
+
rawImports?: outputAst.Expression;
|
|
2892
2939
|
}
|
|
2893
2940
|
|
|
2894
2941
|
/**
|
|
@@ -3667,6 +3714,21 @@ export declare class R3Identifiers {
|
|
|
3667
3714
|
static resetView: outputAst.ExternalReference;
|
|
3668
3715
|
static templateCreate: outputAst.ExternalReference;
|
|
3669
3716
|
static defer: outputAst.ExternalReference;
|
|
3717
|
+
static deferWhen: outputAst.ExternalReference;
|
|
3718
|
+
static deferOnIdle: outputAst.ExternalReference;
|
|
3719
|
+
static deferOnImmediate: outputAst.ExternalReference;
|
|
3720
|
+
static deferOnTimer: outputAst.ExternalReference;
|
|
3721
|
+
static deferOnHover: outputAst.ExternalReference;
|
|
3722
|
+
static deferOnInteraction: outputAst.ExternalReference;
|
|
3723
|
+
static deferOnViewport: outputAst.ExternalReference;
|
|
3724
|
+
static deferPrefetchWhen: outputAst.ExternalReference;
|
|
3725
|
+
static deferPrefetchOnIdle: outputAst.ExternalReference;
|
|
3726
|
+
static deferPrefetchOnImmediate: outputAst.ExternalReference;
|
|
3727
|
+
static deferPrefetchOnTimer: outputAst.ExternalReference;
|
|
3728
|
+
static deferPrefetchOnHover: outputAst.ExternalReference;
|
|
3729
|
+
static deferPrefetchOnInteraction: outputAst.ExternalReference;
|
|
3730
|
+
static deferPrefetchOnViewport: outputAst.ExternalReference;
|
|
3731
|
+
static conditional: outputAst.ExternalReference;
|
|
3670
3732
|
static text: outputAst.ExternalReference;
|
|
3671
3733
|
static enableBindings: outputAst.ExternalReference;
|
|
3672
3734
|
static disableBindings: outputAst.ExternalReference;
|
|
@@ -3734,6 +3796,7 @@ export declare class R3Identifiers {
|
|
|
3734
3796
|
static resolveWindow: outputAst.ExternalReference;
|
|
3735
3797
|
static resolveDocument: outputAst.ExternalReference;
|
|
3736
3798
|
static resolveBody: outputAst.ExternalReference;
|
|
3799
|
+
static getComponentDepsFactory: outputAst.ExternalReference;
|
|
3737
3800
|
static defineComponent: outputAst.ExternalReference;
|
|
3738
3801
|
static declareComponent: outputAst.ExternalReference;
|
|
3739
3802
|
static setComponentScope: outputAst.ExternalReference;
|
|
@@ -3761,6 +3824,7 @@ export declare class R3Identifiers {
|
|
|
3761
3824
|
static declarePipe: outputAst.ExternalReference;
|
|
3762
3825
|
static declareClassMetadata: outputAst.ExternalReference;
|
|
3763
3826
|
static setClassMetadata: outputAst.ExternalReference;
|
|
3827
|
+
static setClassMetadataAsync: outputAst.ExternalReference;
|
|
3764
3828
|
static queryRefresh: outputAst.ExternalReference;
|
|
3765
3829
|
static viewQuery: outputAst.ExternalReference;
|
|
3766
3830
|
static loadQuery: outputAst.ExternalReference;
|
|
@@ -4460,7 +4524,15 @@ declare namespace t {
|
|
|
4460
4524
|
TmplAstDeferredBlockPlaceholder as DeferredBlockPlaceholder,
|
|
4461
4525
|
TmplAstDeferredBlockLoading as DeferredBlockLoading,
|
|
4462
4526
|
TmplAstDeferredBlockError as DeferredBlockError,
|
|
4527
|
+
DeferredBlockTriggers,
|
|
4463
4528
|
TmplAstDeferredBlock as DeferredBlock,
|
|
4529
|
+
TmplAstSwitchBlock as SwitchBlock,
|
|
4530
|
+
TmplAstSwitchBlockCase as SwitchBlockCase,
|
|
4531
|
+
ForLoopBlockContext,
|
|
4532
|
+
TmplAstForLoopBlock as ForLoopBlock,
|
|
4533
|
+
TmplAstForLoopBlockEmpty as ForLoopBlockEmpty,
|
|
4534
|
+
TmplAstIfBlock as IfBlock,
|
|
4535
|
+
TmplAstIfBlockBranch as IfBlockBranch,
|
|
4464
4536
|
TmplAstTemplate as Template,
|
|
4465
4537
|
TmplAstContent as Content,
|
|
4466
4538
|
TmplAstVariable as Variable,
|
|
@@ -4670,16 +4742,20 @@ export declare class TmplAstContent implements TmplAstNode {
|
|
|
4670
4742
|
|
|
4671
4743
|
export declare class TmplAstDeferredBlock implements TmplAstNode {
|
|
4672
4744
|
children: TmplAstNode[];
|
|
4673
|
-
triggers: TmplAstDeferredTrigger[];
|
|
4674
|
-
prefetchTriggers: TmplAstDeferredTrigger[];
|
|
4675
4745
|
placeholder: TmplAstDeferredBlockPlaceholder | null;
|
|
4676
4746
|
loading: TmplAstDeferredBlockLoading | null;
|
|
4677
4747
|
error: TmplAstDeferredBlockError | null;
|
|
4678
4748
|
sourceSpan: ParseSourceSpan;
|
|
4679
4749
|
startSourceSpan: ParseSourceSpan;
|
|
4680
4750
|
endSourceSpan: ParseSourceSpan | null;
|
|
4681
|
-
|
|
4751
|
+
readonly triggers: Readonly<DeferredBlockTriggers>;
|
|
4752
|
+
readonly prefetchTriggers: Readonly<DeferredBlockTriggers>;
|
|
4753
|
+
private readonly definedTriggers;
|
|
4754
|
+
private readonly definedPrefetchTriggers;
|
|
4755
|
+
constructor(children: TmplAstNode[], triggers: DeferredBlockTriggers, prefetchTriggers: DeferredBlockTriggers, placeholder: TmplAstDeferredBlockPlaceholder | null, loading: TmplAstDeferredBlockLoading | null, error: TmplAstDeferredBlockError | null, sourceSpan: ParseSourceSpan, startSourceSpan: ParseSourceSpan, endSourceSpan: ParseSourceSpan | null);
|
|
4682
4756
|
visit<Result>(visitor: Visitor_3<Result>): Result;
|
|
4757
|
+
visitAll(visitor: Visitor_3<unknown>): void;
|
|
4758
|
+
private visitTriggers;
|
|
4683
4759
|
}
|
|
4684
4760
|
|
|
4685
4761
|
export declare class TmplAstDeferredBlockError implements TmplAstNode {
|
|
@@ -4733,6 +4809,28 @@ export declare class TmplAstElement implements TmplAstNode {
|
|
|
4733
4809
|
visit<Result>(visitor: Visitor_3<Result>): Result;
|
|
4734
4810
|
}
|
|
4735
4811
|
|
|
4812
|
+
export declare class TmplAstForLoopBlock implements TmplAstNode {
|
|
4813
|
+
itemName: string;
|
|
4814
|
+
expression: AST;
|
|
4815
|
+
trackBy: AST;
|
|
4816
|
+
contextVariables: ForLoopBlockContext | null;
|
|
4817
|
+
children: TmplAstNode[];
|
|
4818
|
+
empty: TmplAstForLoopBlockEmpty | null;
|
|
4819
|
+
sourceSpan: ParseSourceSpan;
|
|
4820
|
+
startSourceSpan: ParseSourceSpan;
|
|
4821
|
+
endSourceSpan: ParseSourceSpan | null;
|
|
4822
|
+
constructor(itemName: string, expression: AST, trackBy: AST, contextVariables: ForLoopBlockContext | null, children: TmplAstNode[], empty: TmplAstForLoopBlockEmpty | null, sourceSpan: ParseSourceSpan, startSourceSpan: ParseSourceSpan, endSourceSpan: ParseSourceSpan | null);
|
|
4823
|
+
visit<Result>(visitor: Visitor_3<Result>): Result;
|
|
4824
|
+
}
|
|
4825
|
+
|
|
4826
|
+
export declare class TmplAstForLoopBlockEmpty implements TmplAstNode {
|
|
4827
|
+
children: TmplAstNode[];
|
|
4828
|
+
sourceSpan: ParseSourceSpan;
|
|
4829
|
+
startSourceSpan: ParseSourceSpan;
|
|
4830
|
+
constructor(children: TmplAstNode[], sourceSpan: ParseSourceSpan, startSourceSpan: ParseSourceSpan);
|
|
4831
|
+
visit<Result>(visitor: Visitor_3<Result>): Result;
|
|
4832
|
+
}
|
|
4833
|
+
|
|
4736
4834
|
export declare class TmplAstHoverDeferredTrigger extends TmplAstDeferredTrigger {
|
|
4737
4835
|
}
|
|
4738
4836
|
|
|
@@ -4756,6 +4854,25 @@ export declare class TmplAstIcu implements TmplAstNode {
|
|
|
4756
4854
|
export declare class TmplAstIdleDeferredTrigger extends TmplAstDeferredTrigger {
|
|
4757
4855
|
}
|
|
4758
4856
|
|
|
4857
|
+
export declare class TmplAstIfBlock implements TmplAstNode {
|
|
4858
|
+
branches: TmplAstIfBlockBranch[];
|
|
4859
|
+
sourceSpan: ParseSourceSpan;
|
|
4860
|
+
startSourceSpan: ParseSourceSpan;
|
|
4861
|
+
endSourceSpan: ParseSourceSpan | null;
|
|
4862
|
+
constructor(branches: TmplAstIfBlockBranch[], sourceSpan: ParseSourceSpan, startSourceSpan: ParseSourceSpan, endSourceSpan: ParseSourceSpan | null);
|
|
4863
|
+
visit<Result>(visitor: Visitor_3<Result>): Result;
|
|
4864
|
+
}
|
|
4865
|
+
|
|
4866
|
+
export declare class TmplAstIfBlockBranch implements TmplAstNode {
|
|
4867
|
+
expression: AST | null;
|
|
4868
|
+
children: TmplAstNode[];
|
|
4869
|
+
expressionAlias: string | null;
|
|
4870
|
+
sourceSpan: ParseSourceSpan;
|
|
4871
|
+
startSourceSpan: ParseSourceSpan;
|
|
4872
|
+
constructor(expression: AST | null, children: TmplAstNode[], expressionAlias: string | null, sourceSpan: ParseSourceSpan, startSourceSpan: ParseSourceSpan);
|
|
4873
|
+
visit<Result>(visitor: Visitor_3<Result>): Result;
|
|
4874
|
+
}
|
|
4875
|
+
|
|
4759
4876
|
export declare class TmplAstImmediateDeferredTrigger extends TmplAstDeferredTrigger {
|
|
4760
4877
|
}
|
|
4761
4878
|
|
|
@@ -4776,6 +4893,12 @@ export declare class TmplAstRecursiveVisitor implements Visitor_3<void> {
|
|
|
4776
4893
|
visitDeferredBlockPlaceholder(block: TmplAstDeferredBlockPlaceholder): void;
|
|
4777
4894
|
visitDeferredBlockError(block: TmplAstDeferredBlockError): void;
|
|
4778
4895
|
visitDeferredBlockLoading(block: TmplAstDeferredBlockLoading): void;
|
|
4896
|
+
visitSwitchBlock(block: TmplAstSwitchBlock): void;
|
|
4897
|
+
visitSwitchBlockCase(block: TmplAstSwitchBlockCase): void;
|
|
4898
|
+
visitForLoopBlock(block: TmplAstForLoopBlock): void;
|
|
4899
|
+
visitForLoopBlockEmpty(block: TmplAstForLoopBlockEmpty): void;
|
|
4900
|
+
visitIfBlock(block: TmplAstIfBlock): void;
|
|
4901
|
+
visitIfBlockBranch(block: TmplAstIfBlockBranch): void;
|
|
4779
4902
|
visitContent(content: TmplAstContent): void;
|
|
4780
4903
|
visitVariable(variable: TmplAstVariable): void;
|
|
4781
4904
|
visitReference(reference: TmplAstReference): void;
|
|
@@ -4798,6 +4921,25 @@ export declare class TmplAstReference implements TmplAstNode {
|
|
|
4798
4921
|
visit<Result>(visitor: Visitor_3<Result>): Result;
|
|
4799
4922
|
}
|
|
4800
4923
|
|
|
4924
|
+
export declare class TmplAstSwitchBlock implements TmplAstNode {
|
|
4925
|
+
expression: AST;
|
|
4926
|
+
cases: TmplAstSwitchBlockCase[];
|
|
4927
|
+
sourceSpan: ParseSourceSpan;
|
|
4928
|
+
startSourceSpan: ParseSourceSpan;
|
|
4929
|
+
endSourceSpan: ParseSourceSpan | null;
|
|
4930
|
+
constructor(expression: AST, cases: TmplAstSwitchBlockCase[], sourceSpan: ParseSourceSpan, startSourceSpan: ParseSourceSpan, endSourceSpan: ParseSourceSpan | null);
|
|
4931
|
+
visit<Result>(visitor: Visitor_3<Result>): Result;
|
|
4932
|
+
}
|
|
4933
|
+
|
|
4934
|
+
export declare class TmplAstSwitchBlockCase implements TmplAstNode {
|
|
4935
|
+
expression: AST | null;
|
|
4936
|
+
children: TmplAstNode[];
|
|
4937
|
+
sourceSpan: ParseSourceSpan;
|
|
4938
|
+
startSourceSpan: ParseSourceSpan;
|
|
4939
|
+
constructor(expression: AST | null, children: TmplAstNode[], sourceSpan: ParseSourceSpan, startSourceSpan: ParseSourceSpan);
|
|
4940
|
+
visit<Result>(visitor: Visitor_3<Result>): Result;
|
|
4941
|
+
}
|
|
4942
|
+
|
|
4801
4943
|
export declare class TmplAstTemplate implements TmplAstNode {
|
|
4802
4944
|
tagName: string | null;
|
|
4803
4945
|
attributes: TmplAstTextAttribute[];
|
|
@@ -5181,6 +5323,12 @@ declare interface Visitor_3<Result = any> {
|
|
|
5181
5323
|
visitDeferredBlockError(block: TmplAstDeferredBlockError): Result;
|
|
5182
5324
|
visitDeferredBlockLoading(block: TmplAstDeferredBlockLoading): Result;
|
|
5183
5325
|
visitDeferredTrigger(trigger: TmplAstDeferredTrigger): Result;
|
|
5326
|
+
visitSwitchBlock(block: TmplAstSwitchBlock): Result;
|
|
5327
|
+
visitSwitchBlockCase(block: TmplAstSwitchBlockCase): Result;
|
|
5328
|
+
visitForLoopBlock(block: TmplAstForLoopBlock): Result;
|
|
5329
|
+
visitForLoopBlockEmpty(block: TmplAstForLoopBlockEmpty): Result;
|
|
5330
|
+
visitIfBlock(block: TmplAstIfBlock): Result;
|
|
5331
|
+
visitIfBlockBranch(block: TmplAstIfBlockBranch): Result;
|
|
5184
5332
|
}
|
|
5185
5333
|
|
|
5186
5334
|
export declare class WrappedNodeExpr<T> extends Expression {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular/compiler",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "17.0.0-next.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": "
|
|
14
|
+
"@angular/core": "17.0.0-next.1"
|
|
15
15
|
},
|
|
16
16
|
"peerDependenciesMeta": {
|
|
17
17
|
"@angular/core": {
|
package/testing/index.d.ts
CHANGED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google LLC All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://angular.io/license
|
|
7
|
-
*/
|
|
8
|
-
import { splitNsName } from '../../../../ml_parser/tags';
|
|
9
|
-
import * as o from '../../../../output/output_ast';
|
|
10
|
-
/**
|
|
11
|
-
* Enumeration of the types of attributes which can be applied to an element.
|
|
12
|
-
*/
|
|
13
|
-
export var BindingKind;
|
|
14
|
-
(function (BindingKind) {
|
|
15
|
-
/**
|
|
16
|
-
* Static attributes.
|
|
17
|
-
*/
|
|
18
|
-
BindingKind[BindingKind["Attribute"] = 0] = "Attribute";
|
|
19
|
-
/**
|
|
20
|
-
* Class bindings.
|
|
21
|
-
*/
|
|
22
|
-
BindingKind[BindingKind["ClassName"] = 1] = "ClassName";
|
|
23
|
-
/**
|
|
24
|
-
* Style bindings.
|
|
25
|
-
*/
|
|
26
|
-
BindingKind[BindingKind["StyleProperty"] = 2] = "StyleProperty";
|
|
27
|
-
/**
|
|
28
|
-
* Dynamic property bindings.
|
|
29
|
-
*/
|
|
30
|
-
BindingKind[BindingKind["Property"] = 3] = "Property";
|
|
31
|
-
/**
|
|
32
|
-
* Property or attribute bindings on a template.
|
|
33
|
-
*/
|
|
34
|
-
BindingKind[BindingKind["Template"] = 4] = "Template";
|
|
35
|
-
/**
|
|
36
|
-
* Internationalized attributes.
|
|
37
|
-
*/
|
|
38
|
-
BindingKind[BindingKind["I18n"] = 5] = "I18n";
|
|
39
|
-
/**
|
|
40
|
-
* TODO: Consider how Animations are handled, and if they should be a distinct BindingKind.
|
|
41
|
-
*/
|
|
42
|
-
BindingKind[BindingKind["Animation"] = 6] = "Animation";
|
|
43
|
-
})(BindingKind || (BindingKind = {}));
|
|
44
|
-
const FLYWEIGHT_ARRAY = Object.freeze([]);
|
|
45
|
-
/**
|
|
46
|
-
* Container for all of the various kinds of attributes which are applied on an element.
|
|
47
|
-
*/
|
|
48
|
-
export class ElementAttributes {
|
|
49
|
-
constructor() {
|
|
50
|
-
this.known = new Set();
|
|
51
|
-
this.byKind = new Map;
|
|
52
|
-
this.projectAs = null;
|
|
53
|
-
}
|
|
54
|
-
get attributes() {
|
|
55
|
-
return this.byKind.get(BindingKind.Attribute) ?? FLYWEIGHT_ARRAY;
|
|
56
|
-
}
|
|
57
|
-
get classes() {
|
|
58
|
-
return this.byKind.get(BindingKind.ClassName) ?? FLYWEIGHT_ARRAY;
|
|
59
|
-
}
|
|
60
|
-
get styles() {
|
|
61
|
-
return this.byKind.get(BindingKind.StyleProperty) ?? FLYWEIGHT_ARRAY;
|
|
62
|
-
}
|
|
63
|
-
get bindings() {
|
|
64
|
-
return this.byKind.get(BindingKind.Property) ?? FLYWEIGHT_ARRAY;
|
|
65
|
-
}
|
|
66
|
-
get template() {
|
|
67
|
-
return this.byKind.get(BindingKind.Template) ?? FLYWEIGHT_ARRAY;
|
|
68
|
-
}
|
|
69
|
-
get i18n() {
|
|
70
|
-
return this.byKind.get(BindingKind.I18n) ?? FLYWEIGHT_ARRAY;
|
|
71
|
-
}
|
|
72
|
-
add(kind, name, value) {
|
|
73
|
-
if (this.known.has(name)) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
this.known.add(name);
|
|
77
|
-
const array = this.arrayFor(kind);
|
|
78
|
-
array.push(...getAttributeNameLiterals(name));
|
|
79
|
-
if (kind === BindingKind.Attribute || kind === BindingKind.StyleProperty) {
|
|
80
|
-
if (value === null) {
|
|
81
|
-
throw Error('Attribute & style element attributes must have a value');
|
|
82
|
-
}
|
|
83
|
-
array.push(value);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
arrayFor(kind) {
|
|
87
|
-
if (!this.byKind.has(kind)) {
|
|
88
|
-
this.byKind.set(kind, []);
|
|
89
|
-
}
|
|
90
|
-
return this.byKind.get(kind);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
function getAttributeNameLiterals(name) {
|
|
94
|
-
const [attributeNamespace, attributeName] = splitNsName(name);
|
|
95
|
-
const nameLiteral = o.literal(attributeName);
|
|
96
|
-
if (attributeNamespace) {
|
|
97
|
-
return [
|
|
98
|
-
o.literal(0 /* core.AttributeMarker.NamespaceURI */), o.literal(attributeNamespace), nameLiteral
|
|
99
|
-
];
|
|
100
|
-
}
|
|
101
|
-
return [nameLiteral];
|
|
102
|
-
}
|
|
103
|
-
export function assertIsElementAttributes(attrs) {
|
|
104
|
-
if (!(attrs instanceof ElementAttributes)) {
|
|
105
|
-
throw new Error(`AssertionError: ElementAttributes has already been coalesced into the view constants`);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZWxlbWVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL2NvbXBpbGVyL3NyYy90ZW1wbGF0ZS9waXBlbGluZS9pci9zcmMvZWxlbWVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFHSCxPQUFPLEVBQUMsV0FBVyxFQUFDLE1BQU0sNEJBQTRCLENBQUM7QUFDdkQsT0FBTyxLQUFLLENBQUMsTUFBTSwrQkFBK0IsQ0FBQztBQUVuRDs7R0FFRztBQUNILE1BQU0sQ0FBTixJQUFZLFdBbUNYO0FBbkNELFdBQVksV0FBVztJQUNyQjs7T0FFRztJQUNILHVEQUFTLENBQUE7SUFFVDs7T0FFRztJQUNILHVEQUFTLENBQUE7SUFFVDs7T0FFRztJQUNILCtEQUFhLENBQUE7SUFFYjs7T0FFRztJQUNILHFEQUFRLENBQUE7SUFFUjs7T0FFRztJQUNILHFEQUFRLENBQUE7SUFFUjs7T0FFRztJQUNILDZDQUFJLENBQUE7SUFFSjs7T0FFRztJQUNILHVEQUFTLENBQUE7QUFDWCxDQUFDLEVBbkNXLFdBQVcsS0FBWCxXQUFXLFFBbUN0QjtBQUVELE1BQU0sZUFBZSxHQUFnQyxNQUFNLENBQUMsTUFBTSxDQUFpQixFQUFFLENBQUMsQ0FBQztBQUV2Rjs7R0FFR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