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 | (function (factory) {
|
---|
9 | if (typeof module === "object" && typeof module.exports === "object") {
|
---|
10 | var v = factory(require, exports);
|
---|
11 | if (v !== undefined) module.exports = v;
|
---|
12 | }
|
---|
13 | else if (typeof define === "function" && define.amd) {
|
---|
14 | define("@angular/compiler/src/i18n/serializers/placeholder", ["require", "exports"], factory);
|
---|
15 | }
|
---|
16 | })(function (require, exports) {
|
---|
17 | "use strict";
|
---|
18 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
19 | exports.PlaceholderRegistry = void 0;
|
---|
20 | var TAG_TO_PLACEHOLDER_NAMES = {
|
---|
21 | 'A': 'LINK',
|
---|
22 | 'B': 'BOLD_TEXT',
|
---|
23 | 'BR': 'LINE_BREAK',
|
---|
24 | 'EM': 'EMPHASISED_TEXT',
|
---|
25 | 'H1': 'HEADING_LEVEL1',
|
---|
26 | 'H2': 'HEADING_LEVEL2',
|
---|
27 | 'H3': 'HEADING_LEVEL3',
|
---|
28 | 'H4': 'HEADING_LEVEL4',
|
---|
29 | 'H5': 'HEADING_LEVEL5',
|
---|
30 | 'H6': 'HEADING_LEVEL6',
|
---|
31 | 'HR': 'HORIZONTAL_RULE',
|
---|
32 | 'I': 'ITALIC_TEXT',
|
---|
33 | 'LI': 'LIST_ITEM',
|
---|
34 | 'LINK': 'MEDIA_LINK',
|
---|
35 | 'OL': 'ORDERED_LIST',
|
---|
36 | 'P': 'PARAGRAPH',
|
---|
37 | 'Q': 'QUOTATION',
|
---|
38 | 'S': 'STRIKETHROUGH_TEXT',
|
---|
39 | 'SMALL': 'SMALL_TEXT',
|
---|
40 | 'SUB': 'SUBSTRIPT',
|
---|
41 | 'SUP': 'SUPERSCRIPT',
|
---|
42 | 'TBODY': 'TABLE_BODY',
|
---|
43 | 'TD': 'TABLE_CELL',
|
---|
44 | 'TFOOT': 'TABLE_FOOTER',
|
---|
45 | 'TH': 'TABLE_HEADER_CELL',
|
---|
46 | 'THEAD': 'TABLE_HEADER',
|
---|
47 | 'TR': 'TABLE_ROW',
|
---|
48 | 'TT': 'MONOSPACED_TEXT',
|
---|
49 | 'U': 'UNDERLINED_TEXT',
|
---|
50 | 'UL': 'UNORDERED_LIST',
|
---|
51 | };
|
---|
52 | /**
|
---|
53 | * Creates unique names for placeholder with different content.
|
---|
54 | *
|
---|
55 | * Returns the same placeholder name when the content is identical.
|
---|
56 | */
|
---|
57 | var PlaceholderRegistry = /** @class */ (function () {
|
---|
58 | function PlaceholderRegistry() {
|
---|
59 | // Count the occurrence of the base name top generate a unique name
|
---|
60 | this._placeHolderNameCounts = {};
|
---|
61 | // Maps signature to placeholder names
|
---|
62 | this._signatureToName = {};
|
---|
63 | }
|
---|
64 | PlaceholderRegistry.prototype.getStartTagPlaceholderName = function (tag, attrs, isVoid) {
|
---|
65 | var signature = this._hashTag(tag, attrs, isVoid);
|
---|
66 | if (this._signatureToName[signature]) {
|
---|
67 | return this._signatureToName[signature];
|
---|
68 | }
|
---|
69 | var upperTag = tag.toUpperCase();
|
---|
70 | var baseName = TAG_TO_PLACEHOLDER_NAMES[upperTag] || "TAG_" + upperTag;
|
---|
71 | var name = this._generateUniqueName(isVoid ? baseName : "START_" + baseName);
|
---|
72 | this._signatureToName[signature] = name;
|
---|
73 | return name;
|
---|
74 | };
|
---|
75 | PlaceholderRegistry.prototype.getCloseTagPlaceholderName = function (tag) {
|
---|
76 | var signature = this._hashClosingTag(tag);
|
---|
77 | if (this._signatureToName[signature]) {
|
---|
78 | return this._signatureToName[signature];
|
---|
79 | }
|
---|
80 | var upperTag = tag.toUpperCase();
|
---|
81 | var baseName = TAG_TO_PLACEHOLDER_NAMES[upperTag] || "TAG_" + upperTag;
|
---|
82 | var name = this._generateUniqueName("CLOSE_" + baseName);
|
---|
83 | this._signatureToName[signature] = name;
|
---|
84 | return name;
|
---|
85 | };
|
---|
86 | PlaceholderRegistry.prototype.getPlaceholderName = function (name, content) {
|
---|
87 | var upperName = name.toUpperCase();
|
---|
88 | var signature = "PH: " + upperName + "=" + content;
|
---|
89 | if (this._signatureToName[signature]) {
|
---|
90 | return this._signatureToName[signature];
|
---|
91 | }
|
---|
92 | var uniqueName = this._generateUniqueName(upperName);
|
---|
93 | this._signatureToName[signature] = uniqueName;
|
---|
94 | return uniqueName;
|
---|
95 | };
|
---|
96 | PlaceholderRegistry.prototype.getUniquePlaceholder = function (name) {
|
---|
97 | return this._generateUniqueName(name.toUpperCase());
|
---|
98 | };
|
---|
99 | // Generate a hash for a tag - does not take attribute order into account
|
---|
100 | PlaceholderRegistry.prototype._hashTag = function (tag, attrs, isVoid) {
|
---|
101 | var start = "<" + tag;
|
---|
102 | var strAttrs = Object.keys(attrs).sort().map(function (name) { return " " + name + "=" + attrs[name]; }).join('');
|
---|
103 | var end = isVoid ? '/>' : "></" + tag + ">";
|
---|
104 | return start + strAttrs + end;
|
---|
105 | };
|
---|
106 | PlaceholderRegistry.prototype._hashClosingTag = function (tag) {
|
---|
107 | return this._hashTag("/" + tag, {}, false);
|
---|
108 | };
|
---|
109 | PlaceholderRegistry.prototype._generateUniqueName = function (base) {
|
---|
110 | var seen = this._placeHolderNameCounts.hasOwnProperty(base);
|
---|
111 | if (!seen) {
|
---|
112 | this._placeHolderNameCounts[base] = 1;
|
---|
113 | return base;
|
---|
114 | }
|
---|
115 | var id = this._placeHolderNameCounts[base];
|
---|
116 | this._placeHolderNameCounts[base] = id + 1;
|
---|
117 | return base + "_" + id;
|
---|
118 | };
|
---|
119 | return PlaceholderRegistry;
|
---|
120 | }());
|
---|
121 | exports.PlaceholderRegistry = PlaceholderRegistry;
|
---|
122 | });
|
---|
123 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGxhY2Vob2xkZXIuanMiLCJzb3VyY2VSb290Ijoi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