Socket
Socket
Sign inDemoInstall

@angular/compiler

Package Overview
Dependencies
Maintainers
1
Versions
837
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@angular/compiler - npm Package Compare versions

Comparing version 2.4.4 to 2.4.5

src/i18n/serializers/serializer.metadata.json

2

bundles/compiler-testing.umd.js
/**
* @license Angular v2.4.4
* @license Angular v2.4.5
* (c) 2010-2016 Google, Inc. https://angular.io/

@@ -4,0 +4,0 @@ * License: MIT

@@ -45,3 +45,3 @@ /**

export { ElementSchemaRegistry } from './src/schema/element_schema_registry';
export { Extractor, I18NHtmlParser, MessageBundle, Xliff, Xmb, Xtb } from './src/i18n/index';
export { Extractor, I18NHtmlParser, MessageBundle, Serializer, Xliff, Xmb, Xtb } from './src/i18n/index';
export { DirectiveNormalizer } from './src/directive_normalizer';

@@ -48,0 +48,0 @@ export { TokenType, Lexer, Token, EOF, isIdentifier, isQuote } from './src/expression_parser/lexer';

{
"name": "@angular/compiler",
"version": "2.4.4",
"version": "2.4.5",
"description": "Angular - the compiler library",

@@ -11,3 +11,3 @@ "main": "bundles/compiler.umd.js",

"peerDependencies": {
"@angular/core": "2.4.4"
"@angular/core": "2.4.5"
},

@@ -14,0 +14,0 @@ "repository": {

@@ -9,2 +9,5 @@

*/
/**
* Convenience to throw an Error with 'unimplemented' as the message.
*/
export declare function unimplemented(): any;

@@ -11,0 +14,0 @@ /**

@@ -7,7 +7,3 @@ var __extends = (this && this.__extends) || function (d, b) {

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
* Convenience to throw an Error with 'unimplemented' as the message.
* @return {?}

@@ -14,0 +10,0 @@ */

@@ -47,3 +47,3 @@ /**

var /** @type {?} */ programSymbols = extractProgramSymbols(this.staticSymbolResolver, rootFiles, this.host);
var _a = analyzeAndValidateNgModules(programSymbols, this.host, this.metadataResolver), ngModuleByPipeOrDirective = _a.ngModuleByPipeOrDirective, files = _a.files, ngModules = _a.ngModules;
var _a = analyzeAndValidateNgModules(programSymbols, this.host, this.metadataResolver), files = _a.files, ngModules = _a.ngModules;
return Promise

@@ -50,0 +50,0 @@ .all(ngModules.map(function (ngModule) { return _this.metadataResolver.loadNgModuleDirectiveAndPipeMetadata(ngModule.type.reference, false); }))

@@ -11,2 +11,3 @@ /**

export { MessageBundle } from './message_bundle';
export { Serializer } from './serializers/serializer';
export { Xliff } from './serializers/xliff';

@@ -13,0 +14,0 @@ export { Xmb } from './serializers/xmb';

@@ -128,5 +128,10 @@ /**

PlaceholderRegistry.prototype._generateUniqueName = function (base) {
var /** @type {?} */ next = this._placeHolderNameCounts[base];
this._placeHolderNameCounts[base] = next ? next + 1 : 1;
return next ? base + "_" + next : base;
var /** @type {?} */ seen = this._placeHolderNameCounts.hasOwnProperty(base);
if (!seen) {
this._placeHolderNameCounts[base] = 1;
return base;
}
var /** @type {?} */ id = this._placeHolderNameCounts[base];
this._placeHolderNameCounts[base] = id + 1;
return base + "_" + id;
};

@@ -133,0 +138,0 @@ return PlaceholderRegistry;

@@ -9,8 +9,19 @@ /**

import * as i18n from '../i18n_ast';
export interface Serializer {
write(messages: i18n.Message[]): string;
load(content: string, url: string): {
export declare abstract class Serializer {
abstract write(messages: i18n.Message[]): string;
abstract load(content: string, url: string): {
[msgId: string]: i18n.Node[];
};
digest(message: i18n.Message): string;
abstract digest(message: i18n.Message): string;
createNameMapper(message: i18n.Message): PlaceholderMapper;
}
/**
* A `PlaceholderMapper` converts placeholder names from internal to serialized representation and
* back.
*
* It should be used for serialization format that put constraints on the placeholder names.
*/
export interface PlaceholderMapper {
toPublicName(internalName: string): string;
toInternalName(publicName: string): string;
}

@@ -8,2 +8,34 @@ /**

*/
/**
* @abstract
*/
export var Serializer = (function () {
function Serializer() {
}
/**
* @abstract
* @param {?} messages
* @return {?}
*/
Serializer.prototype.write = function (messages) { };
/**
* @abstract
* @param {?} content
* @param {?} url
* @return {?}
*/
Serializer.prototype.load = function (content, url) { };
/**
* @abstract
* @param {?} message
* @return {?}
*/
Serializer.prototype.digest = function (message) { };
/**
* @param {?} message
* @return {?}
*/
Serializer.prototype.createNameMapper = function (message) { return null; };
return Serializer;
}());
//# sourceMappingURL=serializer.js.map
import * as i18n from '../i18n_ast';
import { Serializer } from './serializer';
export declare class Xliff implements Serializer {
export declare class Xliff extends Serializer {
write(messages: i18n.Message[]): string;

@@ -5,0 +5,0 @@ load(content: string, url: string): {

@@ -8,2 +8,7 @@ /**

*/
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
import * as ml from '../../ml_parser/ast';

@@ -14,2 +19,3 @@ import { XmlParser } from '../../ml_parser/xml_parser';

import { I18nError } from '../parse_util';
import { Serializer } from './serializer';
import * as xml from './xml_helper';

@@ -24,4 +30,6 @@ var /** @type {?} */ _VERSION = '1.2';

var /** @type {?} */ _UNIT_TAG = 'trans-unit';
export var Xliff = (function () {
export var Xliff = (function (_super) {
__extends(Xliff, _super);
function Xliff() {
_super.apply(this, arguments);
}

@@ -89,3 +97,3 @@ /**

return Xliff;
}());
}(Serializer));
var _WriteVisitor = (function () {

@@ -92,0 +100,0 @@ function _WriteVisitor() {

@@ -1,1 +0,1 @@

[{"__symbolic":"module","version":3,"metadata":{"Xliff":{"__symbolic":"class","members":{"write":[{"__symbolic":"method"}],"load":[{"__symbolic":"method"}],"digest":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"Xliff":{"__symbolic":"class","members":{"write":[{"__symbolic":"method"}],"load":[{"__symbolic":"method"}],"digest":[{"__symbolic":"method"}]}}}}]
[{"__symbolic":"module","version":3,"metadata":{"Xliff":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"./serializer","name":"Serializer"},"members":{"write":[{"__symbolic":"method"}],"load":[{"__symbolic":"method"}],"digest":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"Xliff":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"./serializer","name":"Serializer"},"members":{"write":[{"__symbolic":"method"}],"load":[{"__symbolic":"method"}],"digest":[{"__symbolic":"method"}]}}}}]
import * as i18n from '../i18n_ast';
import { Serializer } from './serializer';
export declare class Xmb implements Serializer {
import { PlaceholderMapper, Serializer } from './serializer';
export declare class Xmb extends Serializer {
write(messages: i18n.Message[]): string;

@@ -9,3 +9,26 @@ load(content: string, url: string): {

digest(message: i18n.Message): string;
createNameMapper(message: i18n.Message): PlaceholderMapper;
}
export declare function digest(message: i18n.Message): string;
/**
* XMB/XTB placeholders can only contain A-Z, 0-9 and _
*
* Because such restrictions do not exist on placeholder names generated locally, the
* `PlaceholderMapper` is used to convert internal names to XMB names when the XMB file is
* serialized and back from XTB to internal names when an XTB is loaded.
*/
export declare class XmbPlaceholderMapper implements PlaceholderMapper, i18n.Visitor {
private internalToXmb;
private xmbToNextId;
private xmbToInternal;
constructor(message: i18n.Message);
toPublicName(internalName: string): string;
toInternalName(publicName: string): string;
visitText(text: i18n.Text, ctx?: any): any;
visitContainer(container: i18n.Container, ctx?: any): any;
visitIcu(icu: i18n.Icu, ctx?: any): any;
visitTagPlaceholder(ph: i18n.TagPlaceholder, ctx?: any): any;
visitPlaceholder(ph: i18n.Placeholder, ctx?: any): any;
visitIcuPlaceholder(ph: i18n.IcuPlaceholder, ctx?: any): any;
private addPlaceholder(internalName);
}

@@ -8,3 +8,9 @@ /**

*/
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
import { decimalDigest } from '../digest';
import { Serializer } from './serializer';
import * as xml from './xml_helper';

@@ -16,4 +22,6 @@ var /** @type {?} */ _MESSAGES_TAG = 'messagebundle';

var /** @type {?} */ _DOCTYPE = "<!ELEMENT messagebundle (msg)*>\n<!ATTLIST messagebundle class CDATA #IMPLIED>\n\n<!ELEMENT msg (#PCDATA|ph|source)*>\n<!ATTLIST msg id CDATA #IMPLIED>\n<!ATTLIST msg seq CDATA #IMPLIED>\n<!ATTLIST msg name CDATA #IMPLIED>\n<!ATTLIST msg desc CDATA #IMPLIED>\n<!ATTLIST msg meaning CDATA #IMPLIED>\n<!ATTLIST msg obsolete (obsolete) #IMPLIED>\n<!ATTLIST msg xml:space (default|preserve) \"default\">\n<!ATTLIST msg is_hidden CDATA #IMPLIED>\n\n<!ELEMENT source (#PCDATA)>\n\n<!ELEMENT ph (#PCDATA|ex)*>\n<!ATTLIST ph name CDATA #REQUIRED>\n\n<!ELEMENT ex (#PCDATA)>";
export var Xmb = (function () {
export var Xmb = (function (_super) {
__extends(Xmb, _super);
function Xmb() {
_super.apply(this, arguments);
}

@@ -36,2 +44,3 @@ /**

visited[id] = true;
var /** @type {?} */ mapper = _this.createNameMapper(message);
var /** @type {?} */ attrs = { id: id };

@@ -44,3 +53,3 @@ if (message.description) {

}
rootNode.children.push(new xml.CR(2), new xml.Tag(_MESSAGE_TAG, attrs, visitor.serialize(message.nodes)));
rootNode.children.push(new xml.CR(2), new xml.Tag(_MESSAGE_TAG, attrs, visitor.serialize(message.nodes, { mapper: mapper })));
});

@@ -70,4 +79,11 @@ rootNode.children.push(new xml.CR());

Xmb.prototype.digest = function (message) { return digest(message); };
/**
* @param {?} message
* @return {?}
*/
Xmb.prototype.createNameMapper = function (message) {
return new XmbPlaceholderMapper(message);
};
return Xmb;
}());
}(Serializer));
var _Visitor = (function () {

@@ -78,15 +94,17 @@ function _Visitor() {

* @param {?} text
* @param {?=} context
* @param {?} ctx
* @return {?}
*/
_Visitor.prototype.visitText = function (text, context) { return [new xml.Text(text.value)]; };
_Visitor.prototype.visitText = function (text, ctx) {
return [new xml.Text(text.value)];
};
/**
* @param {?} container
* @param {?=} context
* @param {?} ctx
* @return {?}
*/
_Visitor.prototype.visitContainer = function (container, context) {
_Visitor.prototype.visitContainer = function (container, ctx) {
var _this = this;
var /** @type {?} */ nodes = [];
container.children.forEach(function (node) { return nodes.push.apply(nodes, node.visit(_this)); });
container.children.forEach(function (node) { return nodes.push.apply(nodes, node.visit(_this, ctx)); });
return nodes;

@@ -96,10 +114,10 @@ };

* @param {?} icu
* @param {?=} context
* @param {?} ctx
* @return {?}
*/
_Visitor.prototype.visitIcu = function (icu, context) {
_Visitor.prototype.visitIcu = function (icu, ctx) {
var _this = this;
var /** @type {?} */ nodes = [new xml.Text("{" + icu.expressionPlaceholder + ", " + icu.type + ", ")];
Object.keys(icu.cases).forEach(function (c) {
nodes.push.apply(nodes, [new xml.Text(c + " {")].concat(icu.cases[c].visit(_this), [new xml.Text("} ")]));
nodes.push.apply(nodes, [new xml.Text(c + " {")].concat(icu.cases[c].visit(_this, ctx), [new xml.Text("} ")]));
});

@@ -111,8 +129,9 @@ nodes.push(new xml.Text("}"));

* @param {?} ph
* @param {?=} context
* @param {?} ctx
* @return {?}
*/
_Visitor.prototype.visitTagPlaceholder = function (ph, context) {
_Visitor.prototype.visitTagPlaceholder = function (ph, ctx) {
var /** @type {?} */ startEx = new xml.Tag(_EXEMPLE_TAG, {}, [new xml.Text("<" + ph.tag + ">")]);
var /** @type {?} */ startTagPh = new xml.Tag(_PLACEHOLDER_TAG, { name: ph.startName }, [startEx]);
var /** @type {?} */ name = ctx.mapper.toPublicName(ph.startName);
var /** @type {?} */ startTagPh = new xml.Tag(_PLACEHOLDER_TAG, { name: name }, [startEx]);
if (ph.isVoid) {

@@ -123,28 +142,32 @@ // void tags have no children nor closing tags

var /** @type {?} */ closeEx = new xml.Tag(_EXEMPLE_TAG, {}, [new xml.Text("</" + ph.tag + ">")]);
var /** @type {?} */ closeTagPh = new xml.Tag(_PLACEHOLDER_TAG, { name: ph.closeName }, [closeEx]);
return [startTagPh].concat(this.serialize(ph.children), [closeTagPh]);
name = ctx.mapper.toPublicName(ph.closeName);
var /** @type {?} */ closeTagPh = new xml.Tag(_PLACEHOLDER_TAG, { name: name }, [closeEx]);
return [startTagPh].concat(this.serialize(ph.children, ctx), [closeTagPh]);
};
/**
* @param {?} ph
* @param {?=} context
* @param {?} ctx
* @return {?}
*/
_Visitor.prototype.visitPlaceholder = function (ph, context) {
return [new xml.Tag(_PLACEHOLDER_TAG, { name: ph.name })];
_Visitor.prototype.visitPlaceholder = function (ph, ctx) {
var /** @type {?} */ name = ctx.mapper.toPublicName(ph.name);
return [new xml.Tag(_PLACEHOLDER_TAG, { name: name })];
};
/**
* @param {?} ph
* @param {?=} context
* @param {?} ctx
* @return {?}
*/
_Visitor.prototype.visitIcuPlaceholder = function (ph, context) {
return [new xml.Tag(_PLACEHOLDER_TAG, { name: ph.name })];
_Visitor.prototype.visitIcuPlaceholder = function (ph, ctx) {
var /** @type {?} */ name = ctx.mapper.toPublicName(ph.name);
return [new xml.Tag(_PLACEHOLDER_TAG, { name: name })];
};
/**
* @param {?} nodes
* @param {?} ctx
* @return {?}
*/
_Visitor.prototype.serialize = function (nodes) {
_Visitor.prototype.serialize = function (nodes, ctx) {
var _this = this;
return (_a = []).concat.apply(_a, nodes.map(function (node) { return node.visit(_this); }));
return (_a = []).concat.apply(_a, nodes.map(function (node) { return node.visit(_this, ctx); }));
var _a;

@@ -205,2 +228,113 @@ };

}());
/**
* XMB/XTB placeholders can only contain A-Z, 0-9 and _
*
* Because such restrictions do not exist on placeholder names generated locally, the
* `PlaceholderMapper` is used to convert internal names to XMB names when the XMB file is
* serialized and back from XTB to internal names when an XTB is loaded.
*/
export var XmbPlaceholderMapper = (function () {
/**
* @param {?} message
*/
function XmbPlaceholderMapper(message) {
var _this = this;
this.internalToXmb = {};
this.xmbToNextId = {};
this.xmbToInternal = {};
message.nodes.forEach(function (node) { return node.visit(_this); });
}
/**
* @param {?} internalName
* @return {?}
*/
XmbPlaceholderMapper.prototype.toPublicName = function (internalName) {
return this.internalToXmb.hasOwnProperty(internalName) ? this.internalToXmb[internalName] :
null;
};
/**
* @param {?} publicName
* @return {?}
*/
XmbPlaceholderMapper.prototype.toInternalName = function (publicName) {
return this.xmbToInternal.hasOwnProperty(publicName) ? this.xmbToInternal[publicName] : null;
};
/**
* @param {?} text
* @param {?=} ctx
* @return {?}
*/
XmbPlaceholderMapper.prototype.visitText = function (text, ctx) { return null; };
/**
* @param {?} container
* @param {?=} ctx
* @return {?}
*/
XmbPlaceholderMapper.prototype.visitContainer = function (container, ctx) {
var _this = this;
container.children.forEach(function (child) { return child.visit(_this); });
};
/**
* @param {?} icu
* @param {?=} ctx
* @return {?}
*/
XmbPlaceholderMapper.prototype.visitIcu = function (icu, ctx) {
var _this = this;
Object.keys(icu.cases).forEach(function (k) { icu.cases[k].visit(_this); });
};
/**
* @param {?} ph
* @param {?=} ctx
* @return {?}
*/
XmbPlaceholderMapper.prototype.visitTagPlaceholder = function (ph, ctx) {
var _this = this;
this.addPlaceholder(ph.startName);
ph.children.forEach(function (child) { return child.visit(_this); });
this.addPlaceholder(ph.closeName);
};
/**
* @param {?} ph
* @param {?=} ctx
* @return {?}
*/
XmbPlaceholderMapper.prototype.visitPlaceholder = function (ph, ctx) { this.addPlaceholder(ph.name); };
/**
* @param {?} ph
* @param {?=} ctx
* @return {?}
*/
XmbPlaceholderMapper.prototype.visitIcuPlaceholder = function (ph, ctx) { this.addPlaceholder(ph.name); };
/**
* @param {?} internalName
* @return {?}
*/
XmbPlaceholderMapper.prototype.addPlaceholder = function (internalName) {
if (!internalName || this.internalToXmb.hasOwnProperty(internalName)) {
return;
}
var /** @type {?} */ xmbName = internalName.toUpperCase().replace(/[^A-Z0-9_]/g, '_');
if (this.xmbToInternal.hasOwnProperty(xmbName)) {
// Create a new XMB when it has already been used
var /** @type {?} */ nextId = this.xmbToNextId[xmbName];
this.xmbToNextId[xmbName] = nextId + 1;
xmbName = xmbName + "_" + nextId;
}
else {
this.xmbToNextId[xmbName] = 1;
}
this.internalToXmb[internalName] = xmbName;
this.xmbToInternal[xmbName] = internalName;
};
return XmbPlaceholderMapper;
}());
function XmbPlaceholderMapper_tsickle_Closure_declarations() {
/** @type {?} */
XmbPlaceholderMapper.prototype.internalToXmb;
/** @type {?} */
XmbPlaceholderMapper.prototype.xmbToNextId;
/** @type {?} */
XmbPlaceholderMapper.prototype.xmbToInternal;
}
//# sourceMappingURL=xmb.js.map

@@ -1,1 +0,1 @@

[{"__symbolic":"module","version":3,"metadata":{"Xmb":{"__symbolic":"class","members":{"write":[{"__symbolic":"method"}],"load":[{"__symbolic":"method"}],"digest":[{"__symbolic":"method"}]}},"digest":{"__symbolic":"function","parameters":["message"],"value":{"__symbolic":"call","expression":{"__symbolic":"reference","module":"../digest","name":"decimalDigest"},"arguments":[{"__symbolic":"reference","name":"message"}]}}}},{"__symbolic":"module","version":1,"metadata":{"Xmb":{"__symbolic":"class","members":{"write":[{"__symbolic":"method"}],"load":[{"__symbolic":"method"}],"digest":[{"__symbolic":"method"}]}},"digest":{"__symbolic":"function","parameters":["message"],"value":{"__symbolic":"call","expression":{"__symbolic":"reference","module":"../digest","name":"decimalDigest"},"arguments":[{"__symbolic":"reference","name":"message"}]}}}}]
[{"__symbolic":"module","version":3,"metadata":{"Xmb":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"./serializer","name":"Serializer"},"members":{"write":[{"__symbolic":"method"}],"load":[{"__symbolic":"method"}],"digest":[{"__symbolic":"method"}],"createNameMapper":[{"__symbolic":"method"}]}},"digest":{"__symbolic":"function","parameters":["message"],"value":{"__symbolic":"call","expression":{"__symbolic":"reference","module":"../digest","name":"decimalDigest"},"arguments":[{"__symbolic":"reference","name":"message"}]}},"XmbPlaceholderMapper":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"../i18n_ast","name":"Message"}]}],"toPublicName":[{"__symbolic":"method"}],"toInternalName":[{"__symbolic":"method"}],"visitText":[{"__symbolic":"method"}],"visitContainer":[{"__symbolic":"method"}],"visitIcu":[{"__symbolic":"method"}],"visitTagPlaceholder":[{"__symbolic":"method"}],"visitPlaceholder":[{"__symbolic":"method"}],"visitIcuPlaceholder":[{"__symbolic":"method"}],"addPlaceholder":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"Xmb":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"./serializer","name":"Serializer"},"members":{"write":[{"__symbolic":"method"}],"load":[{"__symbolic":"method"}],"digest":[{"__symbolic":"method"}],"createNameMapper":[{"__symbolic":"method"}]}},"digest":{"__symbolic":"function","parameters":["message"],"value":{"__symbolic":"call","expression":{"__symbolic":"reference","module":"../digest","name":"decimalDigest"},"arguments":[{"__symbolic":"reference","name":"message"}]}},"XmbPlaceholderMapper":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"../i18n_ast","name":"Message"}]}],"toPublicName":[{"__symbolic":"method"}],"toInternalName":[{"__symbolic":"method"}],"visitText":[{"__symbolic":"method"}],"visitContainer":[{"__symbolic":"method"}],"visitIcu":[{"__symbolic":"method"}],"visitTagPlaceholder":[{"__symbolic":"method"}],"visitPlaceholder":[{"__symbolic":"method"}],"visitIcuPlaceholder":[{"__symbolic":"method"}],"addPlaceholder":[{"__symbolic":"method"}]}}}}]
import * as i18n from '../i18n_ast';
import { Serializer } from './serializer';
export declare class Xtb implements Serializer {
import { PlaceholderMapper, Serializer } from './serializer';
export declare class Xtb extends Serializer {
write(messages: i18n.Message[]): string;

@@ -9,2 +9,3 @@ load(content: string, url: string): {

digest(message: i18n.Message): string;
createNameMapper(message: i18n.Message): PlaceholderMapper;
}

@@ -8,2 +8,7 @@ /**

*/
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
import * as ml from '../../ml_parser/ast';

@@ -13,8 +18,11 @@ import { XmlParser } from '../../ml_parser/xml_parser';

import { I18nError } from '../parse_util';
import { digest } from './xmb';
import { Serializer } from './serializer';
import { XmbPlaceholderMapper, digest } from './xmb';
var /** @type {?} */ _TRANSLATIONS_TAG = 'translationbundle';
var /** @type {?} */ _TRANSLATION_TAG = 'translation';
var /** @type {?} */ _PLACEHOLDER_TAG = 'ph';
export var Xtb = (function () {
export var Xtb = (function (_super) {
__extends(Xtb, _super);
function Xtb() {
_super.apply(this, arguments);
}

@@ -53,4 +61,11 @@ /**

Xtb.prototype.digest = function (message) { return digest(message); };
/**
* @param {?} message
* @return {?}
*/
Xtb.prototype.createNameMapper = function (message) {
return new XmbPlaceholderMapper(message);
};
return Xtb;
}());
}(Serializer));
var XtbParser = (function () {

@@ -57,0 +72,0 @@ function XtbParser() {

@@ -1,1 +0,1 @@

[{"__symbolic":"module","version":3,"metadata":{"Xtb":{"__symbolic":"class","members":{"write":[{"__symbolic":"method"}],"load":[{"__symbolic":"method"}],"digest":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"Xtb":{"__symbolic":"class","members":{"write":[{"__symbolic":"method"}],"load":[{"__symbolic":"method"}],"digest":[{"__symbolic":"method"}]}}}}]
[{"__symbolic":"module","version":3,"metadata":{"Xtb":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"./serializer","name":"Serializer"},"members":{"write":[{"__symbolic":"method"}],"load":[{"__symbolic":"method"}],"digest":[{"__symbolic":"method"}],"createNameMapper":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"Xtb":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"./serializer","name":"Serializer"},"members":{"write":[{"__symbolic":"method"}],"load":[{"__symbolic":"method"}],"digest":[{"__symbolic":"method"}],"createNameMapper":[{"__symbolic":"method"}]}}}}]

@@ -10,3 +10,3 @@ /**

import * as i18n from './i18n_ast';
import { Serializer } from './serializers/serializer';
import { PlaceholderMapper, Serializer } from './serializers/serializer';
/**

@@ -18,6 +18,7 @@ * A container for translated messages

digest: (m: i18n.Message) => string;
mapperFactory: (m: i18n.Message) => PlaceholderMapper;
private _i18nToHtml;
constructor(_i18nNodesByMsgId: {
[msgId: string]: i18n.Node[];
}, digest: (m: i18n.Message) => string);
}, digest: (m: i18n.Message) => string, mapperFactory?: (m: i18n.Message) => PlaceholderMapper);
static load(content: string, url: string, serializer: Serializer): TranslationBundle;

@@ -24,0 +25,0 @@ get(srcMsg: i18n.Message): html.Node[];

@@ -17,8 +17,10 @@ /**

* @param {?} digest
* @param {?=} mapperFactory
*/
function TranslationBundle(_i18nNodesByMsgId, digest) {
function TranslationBundle(_i18nNodesByMsgId, digest, mapperFactory) {
if (_i18nNodesByMsgId === void 0) { _i18nNodesByMsgId = {}; }
this._i18nNodesByMsgId = _i18nNodesByMsgId;
this.digest = digest;
this._i18nToHtml = new I18nToHtmlVisitor(_i18nNodesByMsgId, digest);
this.mapperFactory = mapperFactory;
this._i18nToHtml = new I18nToHtmlVisitor(_i18nNodesByMsgId, digest, mapperFactory);
}

@@ -34,3 +36,4 @@ /**

var /** @type {?} */ digestFn = function (m) { return serializer.digest(m); };
return new TranslationBundle(i18nNodesByMsgId, digestFn);
var /** @type {?} */ mapperFactory = function (m) { return serializer.createNameMapper(m); };
return new TranslationBundle(i18nNodesByMsgId, digestFn, mapperFactory);
};

@@ -62,2 +65,4 @@ /**

TranslationBundle.prototype.digest;
/** @type {?} */
TranslationBundle.prototype.mapperFactory;
}

@@ -68,8 +73,10 @@ var I18nToHtmlVisitor = (function () {

* @param {?} _digest
* @param {?} _mapperFactory
*/
function I18nToHtmlVisitor(_i18nNodesByMsgId, _digest) {
function I18nToHtmlVisitor(_i18nNodesByMsgId, _digest, _mapperFactory) {
if (_i18nNodesByMsgId === void 0) { _i18nNodesByMsgId = {}; }
this._i18nNodesByMsgId = _i18nNodesByMsgId;
this._digest = _digest;
this._srcMsgStack = [];
this._mapperFactory = _mapperFactory;
this._contextStack = [];
this._errors = [];

@@ -82,3 +89,3 @@ }

I18nToHtmlVisitor.prototype.convert = function (srcMsg) {
this._srcMsgStack.length = 0;
this._contextStack.length = 0;
this._errors.length = 0;

@@ -131,3 +138,3 @@ // i18n to text

I18nToHtmlVisitor.prototype.visitPlaceholder = function (ph, context) {
var /** @type {?} */ phName = ph.name;
var /** @type {?} */ phName = this._mapper(ph.name);
if (this._srcMsg.placeholders.hasOwnProperty(phName)) {

@@ -155,2 +162,6 @@ return this._srcMsg.placeholders[phName];

/**
* Convert a source message to a translated text string:
* - text nodes are replaced with their translation,
* - placeholders are replaced with their content,
* - ICU nodes are converted to ICU expressions.
* @param {?} srcMsg

@@ -162,8 +173,12 @@ * @return {?}

var /** @type {?} */ digest = this._digest(srcMsg);
var /** @type {?} */ mapper = this._mapperFactory ? this._mapperFactory(srcMsg) : null;
if (this._i18nNodesByMsgId.hasOwnProperty(digest)) {
this._srcMsgStack.push(this._srcMsg);
this._contextStack.push({ msg: this._srcMsg, mapper: this._mapper });
this._srcMsg = srcMsg;
this._mapper = function (name) { return mapper ? mapper.toInternalName(name) : name; };
var /** @type {?} */ nodes = this._i18nNodesByMsgId[digest];
var /** @type {?} */ text = nodes.map(function (node) { return node.visit(_this); }).join('');
this._srcMsg = this._srcMsgStack.pop();
var /** @type {?} */ context = this._contextStack.pop();
this._srcMsg = context.msg;
this._mapper = context.mapper;
return text;

@@ -188,10 +203,14 @@ }

/** @type {?} */
I18nToHtmlVisitor.prototype._srcMsgStack;
I18nToHtmlVisitor.prototype._contextStack;
/** @type {?} */
I18nToHtmlVisitor.prototype._errors;
/** @type {?} */
I18nToHtmlVisitor.prototype._mapper;
/** @type {?} */
I18nToHtmlVisitor.prototype._i18nNodesByMsgId;
/** @type {?} */
I18nToHtmlVisitor.prototype._digest;
/** @type {?} */
I18nToHtmlVisitor.prototype._mapperFactory;
}
//# sourceMappingURL=translation_bundle.js.map

@@ -1,1 +0,1 @@

[{"__symbolic":"module","version":3,"metadata":{"TranslationBundle":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Expression form not supported","line":22,"character":33},{"__symbolic":"error","message":"Expression form not supported","line":23,"character":21}]}],"get":[{"__symbolic":"method"}],"has":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"TranslationBundle":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Expression form not supported","line":22,"character":33},{"__symbolic":"error","message":"Expression form not supported","line":23,"character":21}]}],"get":[{"__symbolic":"method"}],"has":[{"__symbolic":"method"}]}}}}]
[{"__symbolic":"module","version":3,"metadata":{"TranslationBundle":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Expression form not supported","line":22,"character":33},{"__symbolic":"error","message":"Expression form not supported","line":23,"character":21},{"__symbolic":"error","message":"Expression form not supported","line":24,"character":29}]}],"get":[{"__symbolic":"method"}],"has":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"TranslationBundle":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Expression form not supported","line":22,"character":33},{"__symbolic":"error","message":"Expression form not supported","line":23,"character":21},{"__symbolic":"error","message":"Expression form not supported","line":24,"character":29}]}],"get":[{"__symbolic":"method"}],"has":[{"__symbolic":"method"}]}}}}]

@@ -12,3 +12,4 @@ /**

'(?:\\.([-\\w]+))|' +
'(?:\\[([.-\\w*]+)(?:=([^\\]]*))?\\])|' +
// "-" should appear first in the regexp below as FF31 parses "[.-\w]" as a range
'(?:\\[([-.\\w*]+)(?:=([^\\]]*))?\\])|' +
'(\\))|' +

@@ -15,0 +16,0 @@ '(\\s*,\\s*)', // ","

@@ -12,3 +12,3 @@ /**

*/
export var /** @type {?} */ VERSION = new Version('2.4.4');
export var /** @type {?} */ VERSION = new Version('2.4.5');
//# sourceMappingURL=version.js.map

@@ -1,1 +0,1 @@

[{"__symbolic":"module","version":3,"metadata":{"VERSION":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"Version"},"arguments":["2.4.4"]}}},{"__symbolic":"module","version":1,"metadata":{"VERSION":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"Version"},"arguments":["2.4.4"]}}}]
[{"__symbolic":"module","version":3,"metadata":{"VERSION":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"Version"},"arguments":["2.4.5"]}}},{"__symbolic":"module","version":1,"metadata":{"VERSION":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"Version"},"arguments":["2.4.5"]}}}]

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc