Socket
Socket
Sign inDemoInstall

@angular/compiler

Package Overview
Dependencies
Maintainers
1
Versions
843
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 0.0.0-6 to 0.0.0-7

5

esm/private_export.d.ts
import * as selector from './src/selector';
import * as pathUtil from './src/output/path_util';
export declare namespace __compiler_private__ {

@@ -7,2 +8,6 @@ type SelectorMatcher = selector.SelectorMatcher;

var CssSelector: typeof selector.CssSelector;
type AssetUrl = pathUtil.AssetUrl;
var AssetUrl: typeof pathUtil.AssetUrl;
type ImportGenerator = pathUtil.ImportGenerator;
var ImportGenerator: typeof pathUtil.ImportGenerator;
}

3

esm/private_export.js
import * as selector from './src/selector';
import * as pathUtil from './src/output/path_util';
export var __compiler_private__;

@@ -6,3 +7,5 @@ (function (__compiler_private__) {

__compiler_private__.CssSelector = selector.CssSelector;
__compiler_private__.AssetUrl = pathUtil.AssetUrl;
__compiler_private__.ImportGenerator = pathUtil.ImportGenerator;
})(__compiler_private__ || (__compiler_private__ = {}));
//# sourceMappingURL=private_export.js.map

4

esm/src/compile_metadata.d.ts

@@ -205,4 +205,3 @@ import { ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core';

ngContentSelectors: string[];
baseUrl: string;
constructor({encapsulation, template, templateUrl, styles, styleUrls, ngContentSelectors, baseUrl}?: {
constructor({encapsulation, template, templateUrl, styles, styleUrls, ngContentSelectors}?: {
encapsulation?: ViewEncapsulation;

@@ -214,3 +213,2 @@ template?: string;

ngContentSelectors?: string[];
baseUrl?: string;
});

@@ -217,0 +215,0 @@ static fromJson(data: {

@@ -308,3 +308,3 @@ import { ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core';

export class CompileTemplateMetadata {
constructor({ encapsulation, template, templateUrl, styles, styleUrls, ngContentSelectors, baseUrl } = {}) {
constructor({ encapsulation, template, templateUrl, styles, styleUrls, ngContentSelectors } = {}) {
this.encapsulation = isPresent(encapsulation) ? encapsulation : ViewEncapsulation.Emulated;

@@ -316,3 +316,2 @@ this.template = template;

this.ngContentSelectors = isPresent(ngContentSelectors) ? ngContentSelectors : [];
this.baseUrl = baseUrl;
}

@@ -328,4 +327,3 @@ static fromJson(data) {

styleUrls: data['styleUrls'],
ngContentSelectors: data['ngContentSelectors'],
baseUrl: data['baseUrl']
ngContentSelectors: data['ngContentSelectors']
});

@@ -340,4 +338,3 @@ }

'styleUrls': this.styleUrls,
'ngContentSelectors': this.ngContentSelectors,
'baseUrl': this.baseUrl
'ngContentSelectors': this.ngContentSelectors
};

@@ -344,0 +341,0 @@ }

@@ -45,6 +45,6 @@ import { Injectable, ViewEncapsulation } from '@angular/core';

if (isPresent(template.template)) {
return PromiseWrapper.resolve(this.normalizeLoadedTemplate(directiveType, template, template.template, template.baseUrl));
return PromiseWrapper.resolve(this.normalizeLoadedTemplate(directiveType, template, template.template, directiveType.moduleUrl));
}
else if (isPresent(template.templateUrl)) {
var sourceAbsUrl = this._urlResolver.resolve(template.baseUrl, template.templateUrl);
var sourceAbsUrl = this._urlResolver.resolve(directiveType.moduleUrl, template.templateUrl);
return this._xhr.get(sourceAbsUrl)

@@ -69,3 +69,3 @@ .then(templateContent => this.normalizeLoadedTemplate(directiveType, template, templateContent, sourceAbsUrl));

.concat(templateMeta.styleUrls.filter(isStyleUrlResolvable)
.map(url => this._urlResolver.resolve(templateMeta.baseUrl, url)));
.map(url => this._urlResolver.resolve(directiveType.moduleUrl, url)));
var allResolvedStyles = allStyles.map(style => {

@@ -72,0 +72,0 @@ var styleWithImports = extractStyleUrls(this._urlResolver, templateAbsUrl, style);

@@ -63,4 +63,3 @@ import { AttributeMetadata, OptionalMetadata, ComponentMetadata, SelfMetadata, HostMetadata, SkipSelfMetadata, Provider, PLATFORM_DIRECTIVES, PLATFORM_PIPES, reflector, Injectable, Inject, Optional, QueryMetadata, resolveForwardRef, InjectMetadata } from '@angular/core';

styles: viewMeta.styles,
styleUrls: viewMeta.styleUrls,
baseUrl: calcTemplateBaseUrl(this._reflector, directiveType, cmpMeta)
styleUrls: viewMeta.styleUrls
});

@@ -86,3 +85,5 @@ changeDetectionStrategy = cmpMeta.changeDetection;

isComponent: isPresent(templateMeta),
type: this.getTypeMetadata(directiveType, staticTypeModuleUrl(directiveType)),
type: this.getTypeMetadata(directiveType, isPresent(cmpMeta) ?
componentModuleUrl(this._reflector, directiveType, cmpMeta) :
staticTypeModuleUrl(dirMeta)),
template: templateMeta,

@@ -364,3 +365,3 @@ changeDetection: changeDetectionStrategy,

function isStaticType(value) {
return isStringMap(value) && isPresent(value['name']) && isPresent(value['moduleId']);
return isStringMap(value) && isPresent(value['name']) && isPresent(value['filePath']);
}

@@ -371,7 +372,7 @@ function isValidType(value) {

function staticTypeModuleUrl(value) {
return isStaticType(value) ? value['moduleId'] : null;
return isStaticType(value) ? value['filePath'] : null;
}
function calcTemplateBaseUrl(reflector, type, cmpMetadata) {
function componentModuleUrl(reflector, type, cmpMetadata) {
if (isStaticType(type)) {
return type['filePath'];
return staticTypeModuleUrl(type);
}

@@ -378,0 +379,0 @@ if (isPresent(cmpMetadata.moduleId)) {

@@ -7,2 +7,3 @@ import { CompileDirectiveMetadata, CompilePipeMetadata } from './compile_metadata';

import { OutputEmitter } from './output/abstract_emitter';
import { XHR } from './xhr';
export declare class SourceModule {

@@ -13,2 +14,7 @@ moduleUrl: string;

}
export declare class StyleSheetSourceWithImports {
source: SourceModule;
importedUrls: string[];
constructor(source: SourceModule, importedUrls: string[]);
}
export declare class NormalizedComponentWithViewDirectives {

@@ -26,8 +32,10 @@ component: CompileDirectiveMetadata;

private _outputEmitter;
constructor(_directiveNormalizer: DirectiveNormalizer, _templateParser: TemplateParser, _styleCompiler: StyleCompiler, _viewCompiler: ViewCompiler, _outputEmitter: OutputEmitter);
private _xhr;
constructor(_directiveNormalizer: DirectiveNormalizer, _templateParser: TemplateParser, _styleCompiler: StyleCompiler, _viewCompiler: ViewCompiler, _outputEmitter: OutputEmitter, _xhr: XHR);
normalizeDirectiveMetadata(directive: CompileDirectiveMetadata): Promise<CompileDirectiveMetadata>;
compileTemplates(components: NormalizedComponentWithViewDirectives[]): SourceModule;
compileStylesheet(stylesheetUrl: string, cssText: string): SourceModule[];
loadAndCompileStylesheet(stylesheetUrl: string, shim: boolean, suffix: string): Promise<StyleSheetSourceWithImports>;
private _compileComponent(compMeta, directives, pipes, targetStatements);
private _codgenStyles(inputUrl, shim, suffix, stylesCompileResult);
private _codegenSourceModule(moduleUrl, statements, exportedVars);
}

@@ -6,3 +6,3 @@ import { ComponentFactory } from '@angular/core';

import * as o from './output/output_ast';
import { MODULE_SUFFIX, assetUrl } from './util';
import { assetUrl } from './util';
var _COMPONENT_FACTORY_IDENTIFIER = new CompileIdentifierMetadata({

@@ -19,2 +19,8 @@ name: 'ComponentFactory',

}
export class StyleSheetSourceWithImports {
constructor(source, importedUrls) {
this.source = source;
this.importedUrls = importedUrls;
}
}
export class NormalizedComponentWithViewDirectives {

@@ -28,3 +34,3 @@ constructor(component, directives, pipes) {

export class OfflineCompiler {
constructor(_directiveNormalizer, _templateParser, _styleCompiler, _viewCompiler, _outputEmitter) {
constructor(_directiveNormalizer, _templateParser, _styleCompiler, _viewCompiler, _outputEmitter, _xhr) {
this._directiveNormalizer = _directiveNormalizer;

@@ -35,2 +41,3 @@ this._templateParser = _templateParser;

this._outputEmitter = _outputEmitter;
this._xhr = _xhr;
}

@@ -67,9 +74,13 @@ normalizeDirectiveMetadata(directive) {

}
compileStylesheet(stylesheetUrl, cssText) {
var plainStyles = this._styleCompiler.compileStylesheet(stylesheetUrl, cssText, false);
var shimStyles = this._styleCompiler.compileStylesheet(stylesheetUrl, cssText, true);
return [
this._codegenSourceModule(_stylesModuleUrl(stylesheetUrl, false), _resolveStyleStatements(plainStyles), [plainStyles.stylesVar]),
this._codegenSourceModule(_stylesModuleUrl(stylesheetUrl, true), _resolveStyleStatements(shimStyles), [shimStyles.stylesVar])
];
loadAndCompileStylesheet(stylesheetUrl, shim, suffix) {
return this._xhr.get(stylesheetUrl)
.then((cssText) => {
var compileResult = this._styleCompiler.compileStylesheet(stylesheetUrl, cssText, shim);
var importedUrls = [];
compileResult.dependencies.forEach((dep) => {
importedUrls.push(dep.moduleUrl);
dep.valuePlaceholder.moduleUrl = _stylesModuleUrl(dep.moduleUrl, dep.isShimmed, suffix);
});
return new StyleSheetSourceWithImports(this._codgenStyles(stylesheetUrl, shim, suffix, compileResult), importedUrls);
});
}

@@ -80,6 +91,9 @@ _compileComponent(compMeta, directives, pipes, targetStatements) {

var viewResult = this._viewCompiler.compileComponent(compMeta, parsedTemplate, o.variable(styleResult.stylesVar), pipes);
ListWrapper.addAll(targetStatements, _resolveStyleStatements(styleResult));
ListWrapper.addAll(targetStatements, _resolveStyleStatements(compMeta.type.moduleUrl, styleResult));
ListWrapper.addAll(targetStatements, _resolveViewStatements(viewResult));
return viewResult.viewFactoryVar;
}
_codgenStyles(inputUrl, shim, suffix, stylesCompileResult) {
return this._codegenSourceModule(_stylesModuleUrl(inputUrl, shim, suffix), stylesCompileResult.statements, [stylesCompileResult.stylesVar]);
}
_codegenSourceModule(moduleUrl, statements, exportedVars) {

@@ -93,5 +107,7 @@ return new SourceModule(moduleUrl, this._outputEmitter.emitStatements(moduleUrl, statements, exportedVars));

}
function _resolveStyleStatements(compileResult) {
function _resolveStyleStatements(containingModuleUrl, compileResult) {
var containingSuffix = _splitSuffix(containingModuleUrl)[1];
compileResult.dependencies.forEach((dep) => {
dep.valuePlaceholder.moduleUrl = _stylesModuleUrl(dep.sourceUrl, dep.isShimmed);
dep.valuePlaceholder.moduleUrl =
_stylesModuleUrl(dep.moduleUrl, dep.isShimmed, containingSuffix);
});

@@ -101,8 +117,7 @@ return compileResult.statements;

function _templateModuleUrl(comp) {
var moduleUrl = comp.type.moduleUrl;
var urlWithoutSuffix = moduleUrl.substring(0, moduleUrl.length - MODULE_SUFFIX.length);
return `${urlWithoutSuffix}.ngfactory${MODULE_SUFFIX}`;
var urlWithSuffix = _splitSuffix(comp.type.moduleUrl);
return `${urlWithSuffix[0]}.ngfactory${urlWithSuffix[1]}`;
}
function _stylesModuleUrl(stylesheetUrl, shim) {
return shim ? `${stylesheetUrl}.shim${MODULE_SUFFIX}` : `${stylesheetUrl}${MODULE_SUFFIX}`;
function _stylesModuleUrl(stylesheetUrl, shim, suffix) {
return shim ? `${stylesheetUrl}.shim${suffix}` : `${stylesheetUrl}${suffix}`;
}

@@ -114,2 +129,11 @@ function _assertComponent(meta) {

}
function _splitSuffix(path) {
let lastDot = path.lastIndexOf('.');
if (lastDot !== -1) {
return [path.substring(0, lastDot), path.substring(lastDot)];
}
else {
return [path, ''];
}
}
//# sourceMappingURL=offline_compiler.js.map
import * as o from './output_ast';
import { OutputEmitter } from './abstract_emitter';
import { ImportGenerator } from './path_util';
export declare function debugOutputAstAsDart(ast: o.Statement | o.Expression | o.Type | any[]): string;
export declare class DartEmitter implements OutputEmitter {
constructor();
private _importGenerator;
constructor(_importGenerator: ImportGenerator);
emitStatements(moduleUrl: string, stmts: o.Statement[], exportedVars: string[]): string;
}

@@ -5,3 +5,2 @@ import { isPresent, isBlank, isArray } from '../../src/facade/lang';

import { EmitterVisitorContext, AbstractEmitterVisitor, CATCH_ERROR_VAR, CATCH_STACK_VAR } from './abstract_emitter';
import { getImportModulePath, ImportEnv } from './path_util';
var _debugModuleUrl = 'asset://debug/lib';

@@ -35,3 +34,4 @@ export function debugOutputAstAsDart(ast) {

export class DartEmitter {
constructor() {
constructor(_importGenerator) {
this._importGenerator = _importGenerator;
}

@@ -46,3 +46,3 @@ emitStatements(moduleUrl, stmts, exportedVars) {

converter.importsWithPrefixes.forEach((prefix, importedModuleUrl) => {
srcParts.push(`import '${getImportModulePath(moduleUrl, importedModuleUrl, ImportEnv.Dart)}' as ${prefix};`);
srcParts.push(`import '${this._importGenerator.getImportPath(moduleUrl, importedModuleUrl)}' as ${prefix};`);
});

@@ -49,0 +49,0 @@ srcParts.push(ctx.toSource());

@@ -1,10 +0,14 @@

export declare enum ImportEnv {
Dart = 0,
JS = 1,
}
/**
* Returns the module path to use for an import.
* Interface that defines how import statements should be generated.
*/
export declare function getImportModulePath(moduleUrlStr: string, importedUrlStr: string, importEnv: ImportEnv): string;
export declare function getRelativePath(modulePath: string, importedPath: string, importEnv: ImportEnv): string;
export declare function getLongestPathSegmentPrefix(arr1: string[], arr2: string[]): number;
export declare abstract class ImportGenerator {
static parseAssetUrl(url: string): AssetUrl;
abstract getImportPath(moduleUrlStr: string, importedUrlStr: string): string;
}
export declare class AssetUrl {
packageName: string;
firstLevelDir: string;
modulePath: string;
static parse(url: string, allowNonMatching?: boolean): AssetUrl;
constructor(packageName: string, firstLevelDir: string, modulePath: string);
}
import { BaseException } from '../../src/facade/exceptions';
import { isPresent, isBlank, RegExpWrapper, Math } from '../../src/facade/lang';
import { isPresent, RegExpWrapper } from '../../src/facade/lang';
// asset:<package-name>/<realm>/<path-to-module>
var _ASSET_URL_RE = /asset:([^\/]+)\/([^\/]+)\/(.+)/g;
var _PATH_SEP = '/';
var _PATH_SEP_RE = /\//g;
export var ImportEnv;
(function (ImportEnv) {
ImportEnv[ImportEnv["Dart"] = 0] = "Dart";
ImportEnv[ImportEnv["JS"] = 1] = "JS";
})(ImportEnv || (ImportEnv = {}));
/**
* Returns the module path to use for an import.
* Interface that defines how import statements should be generated.
*/
export function getImportModulePath(moduleUrlStr, importedUrlStr, importEnv) {
var absolutePathPrefix = importEnv === ImportEnv.Dart ? `package:` : '';
var moduleUrl = _AssetUrl.parse(moduleUrlStr, false);
var importedUrl = _AssetUrl.parse(importedUrlStr, true);
if (isBlank(importedUrl)) {
return importedUrlStr;
}
// Try to create a relative path first
if (moduleUrl.firstLevelDir == importedUrl.firstLevelDir &&
moduleUrl.packageName == importedUrl.packageName) {
return getRelativePath(moduleUrl.modulePath, importedUrl.modulePath, importEnv);
}
else if (importedUrl.firstLevelDir == 'lib') {
return `${absolutePathPrefix}${importedUrl.packageName}/${importedUrl.modulePath}`;
}
throw new BaseException(`Can't import url ${importedUrlStr} from ${moduleUrlStr}`);
export class ImportGenerator {
static parseAssetUrl(url) { return AssetUrl.parse(url); }
}
class _AssetUrl {
export class AssetUrl {
constructor(packageName, firstLevelDir, modulePath) {

@@ -38,6 +17,6 @@ this.packageName = packageName;

}
static parse(url, allowNonMatching) {
static parse(url, allowNonMatching = true) {
var match = RegExpWrapper.firstMatch(_ASSET_URL_RE, url);
if (isPresent(match)) {
return new _AssetUrl(match[1], match[2], match[3]);
return new AssetUrl(match[1], match[2], match[3]);
}

@@ -50,27 +29,2 @@ if (allowNonMatching) {

}
export function getRelativePath(modulePath, importedPath, importEnv) {
var moduleParts = modulePath.split(_PATH_SEP_RE);
var importedParts = importedPath.split(_PATH_SEP_RE);
var longestPrefix = getLongestPathSegmentPrefix(moduleParts, importedParts);
var resultParts = [];
var goParentCount = moduleParts.length - 1 - longestPrefix;
for (var i = 0; i < goParentCount; i++) {
resultParts.push('..');
}
if (goParentCount <= 0 && importEnv === ImportEnv.JS) {
resultParts.push('.');
}
for (var i = longestPrefix; i < importedParts.length; i++) {
resultParts.push(importedParts[i]);
}
return resultParts.join(_PATH_SEP);
}
export function getLongestPathSegmentPrefix(arr1, arr2) {
var prefixSize = 0;
var minLen = Math.min(arr1.length, arr2.length);
while (prefixSize < minLen && arr1[prefixSize] == arr2[prefixSize]) {
prefixSize++;
}
return prefixSize;
}
//# sourceMappingURL=path_util.js.map
import * as o from './output_ast';
import { OutputEmitter } from './abstract_emitter';
import { ImportGenerator } from './path_util';
export declare function debugOutputAstAsTypeScript(ast: o.Statement | o.Expression | o.Type | any[]): string;
export declare class TypeScriptEmitter implements OutputEmitter {
constructor();
private _importGenerator;
constructor(_importGenerator: ImportGenerator);
emitStatements(moduleUrl: string, stmts: o.Statement[], exportedVars: string[]): string;
}

@@ -5,3 +5,2 @@ import * as o from './output_ast';

import { EmitterVisitorContext, AbstractEmitterVisitor, CATCH_ERROR_VAR, CATCH_STACK_VAR } from './abstract_emitter';
import { getImportModulePath, ImportEnv } from './path_util';
var _debugModuleUrl = 'asset://debug/lib';

@@ -35,3 +34,4 @@ export function debugOutputAstAsTypeScript(ast) {

export class TypeScriptEmitter {
constructor() {
constructor(_importGenerator) {
this._importGenerator = _importGenerator;
}

@@ -46,3 +46,3 @@ emitStatements(moduleUrl, stmts, exportedVars) {

srcParts.push(`imp` +
`ort * as ${prefix} from '${getImportModulePath(moduleUrl, importedModuleUrl, ImportEnv.JS)}';`);
`ort * as ${prefix} from '${this._importGenerator.getImportPath(moduleUrl, importedModuleUrl)}';`);
});

@@ -49,0 +49,0 @@ srcParts.push(ctx.toSource());

@@ -109,4 +109,4 @@ import { Injectable, ComponentFactory } from '@angular/core';

var cssText = cssTexts[i];
var nestedCompileResult = this._styleCompiler.compileStylesheet(dep.sourceUrl, cssText, dep.isShimmed);
nestedCompileResultPromises.push(this._resolveStylesCompileResult(dep.sourceUrl, nestedCompileResult));
var nestedCompileResult = this._styleCompiler.compileStylesheet(dep.moduleUrl, cssText, dep.isShimmed);
nestedCompileResultPromises.push(this._resolveStylesCompileResult(dep.moduleUrl, nestedCompileResult));
}

@@ -130,6 +130,6 @@ return PromiseWrapper.all(nestedCompileResultPromises);

_loadStylesheetDep(dep) {
var cacheKey = `${dep.sourceUrl}${dep.isShimmed ? '.shim' : ''}`;
var cacheKey = `${dep.moduleUrl}${dep.isShimmed ? '.shim' : ''}`;
var cssTextPromise = this._styleCache.get(cacheKey);
if (isBlank(cssTextPromise)) {
cssTextPromise = this._xhr.get(dep.sourceUrl);
cssTextPromise = this._xhr.get(dep.moduleUrl);
this._styleCache.set(cacheKey, cssTextPromise);

@@ -136,0 +136,0 @@ }

@@ -5,6 +5,6 @@ import { CompileIdentifierMetadata, CompileDirectiveMetadata } from './compile_metadata';

export declare class StylesCompileDependency {
sourceUrl: string;
moduleUrl: string;
isShimmed: boolean;
valuePlaceholder: CompileIdentifierMetadata;
constructor(sourceUrl: string, isShimmed: boolean, valuePlaceholder: CompileIdentifierMetadata);
constructor(moduleUrl: string, isShimmed: boolean, valuePlaceholder: CompileIdentifierMetadata);
}

@@ -11,0 +11,0 @@ export declare class StylesCompileResult {

@@ -12,4 +12,4 @@ import { ViewEncapsulation, Injectable } from '@angular/core';

export class StylesCompileDependency {
constructor(sourceUrl, isShimmed, valuePlaceholder) {
this.sourceUrl = sourceUrl;
constructor(moduleUrl, isShimmed, valuePlaceholder) {
this.moduleUrl = moduleUrl;
this.isShimmed = isShimmed;

@@ -16,0 +16,0 @@ this.valuePlaceholder = valuePlaceholder;

{
"name": "@angular/compiler",
"version": "0.0.0-6",
"version": "0.0.0-7",
"description": "",

@@ -11,4 +11,4 @@ "main": "index.js",

"peerDependencies": {
"@angular/core": "0.0.0-6"
"@angular/core": "0.0.0-7"
}
}
import * as selector from './src/selector';
import * as pathUtil from './src/output/path_util';
export declare namespace __compiler_private__ {

@@ -7,2 +8,6 @@ type SelectorMatcher = selector.SelectorMatcher;

var CssSelector: typeof selector.CssSelector;
type AssetUrl = pathUtil.AssetUrl;
var AssetUrl: typeof pathUtil.AssetUrl;
type ImportGenerator = pathUtil.ImportGenerator;
var ImportGenerator: typeof pathUtil.ImportGenerator;
}
"use strict";
var selector = require('./src/selector');
var pathUtil = require('./src/output/path_util');
var __compiler_private__;

@@ -7,3 +8,5 @@ (function (__compiler_private__) {

__compiler_private__.CssSelector = selector.CssSelector;
__compiler_private__.AssetUrl = pathUtil.AssetUrl;
__compiler_private__.ImportGenerator = pathUtil.ImportGenerator;
})(__compiler_private__ = exports.__compiler_private__ || (exports.__compiler_private__ = {}));
//# sourceMappingURL=private_export.js.map

@@ -205,4 +205,3 @@ import { ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core';

ngContentSelectors: string[];
baseUrl: string;
constructor({encapsulation, template, templateUrl, styles, styleUrls, ngContentSelectors, baseUrl}?: {
constructor({encapsulation, template, templateUrl, styles, styleUrls, ngContentSelectors}?: {
encapsulation?: ViewEncapsulation;

@@ -214,3 +213,2 @@ template?: string;

ngContentSelectors?: string[];
baseUrl?: string;
});

@@ -217,0 +215,0 @@ static fromJson(data: {

@@ -393,3 +393,3 @@ "use strict";

function CompileTemplateMetadata(_a) {
var _b = _a === void 0 ? {} : _a, encapsulation = _b.encapsulation, template = _b.template, templateUrl = _b.templateUrl, styles = _b.styles, styleUrls = _b.styleUrls, ngContentSelectors = _b.ngContentSelectors, baseUrl = _b.baseUrl;
var _b = _a === void 0 ? {} : _a, encapsulation = _b.encapsulation, template = _b.template, templateUrl = _b.templateUrl, styles = _b.styles, styleUrls = _b.styleUrls, ngContentSelectors = _b.ngContentSelectors;
this.encapsulation = lang_1.isPresent(encapsulation) ? encapsulation : core_1.ViewEncapsulation.Emulated;

@@ -401,3 +401,2 @@ this.template = template;

this.ngContentSelectors = lang_1.isPresent(ngContentSelectors) ? ngContentSelectors : [];
this.baseUrl = baseUrl;
}

@@ -413,4 +412,3 @@ CompileTemplateMetadata.fromJson = function (data) {

styleUrls: data['styleUrls'],
ngContentSelectors: data['ngContentSelectors'],
baseUrl: data['baseUrl']
ngContentSelectors: data['ngContentSelectors']
});

@@ -425,4 +423,3 @@ };

'styleUrls': this.styleUrls,
'ngContentSelectors': this.ngContentSelectors,
'baseUrl': this.baseUrl
'ngContentSelectors': this.ngContentSelectors
};

@@ -429,0 +426,0 @@ };

@@ -47,6 +47,6 @@ "use strict";

if (lang_1.isPresent(template.template)) {
return async_1.PromiseWrapper.resolve(this.normalizeLoadedTemplate(directiveType, template, template.template, template.baseUrl));
return async_1.PromiseWrapper.resolve(this.normalizeLoadedTemplate(directiveType, template, template.template, directiveType.moduleUrl));
}
else if (lang_1.isPresent(template.templateUrl)) {
var sourceAbsUrl = this._urlResolver.resolve(template.baseUrl, template.templateUrl);
var sourceAbsUrl = this._urlResolver.resolve(directiveType.moduleUrl, template.templateUrl);
return this._xhr.get(sourceAbsUrl)

@@ -72,3 +72,3 @@ .then(function (templateContent) { return _this.normalizeLoadedTemplate(directiveType, template, templateContent, sourceAbsUrl); });

.concat(templateMeta.styleUrls.filter(style_url_resolver_1.isStyleUrlResolvable)
.map(function (url) { return _this._urlResolver.resolve(templateMeta.baseUrl, url); }));
.map(function (url) { return _this._urlResolver.resolve(directiveType.moduleUrl, url); }));
var allResolvedStyles = allStyles.map(function (style) {

@@ -75,0 +75,0 @@ var styleWithImports = style_url_resolver_1.extractStyleUrls(_this._urlResolver, templateAbsUrl, style);

@@ -69,4 +69,3 @@ "use strict";

styles: viewMeta.styles,
styleUrls: viewMeta.styleUrls,
baseUrl: calcTemplateBaseUrl(this._reflector, directiveType, cmpMeta)
styleUrls: viewMeta.styleUrls
});

@@ -92,3 +91,5 @@ changeDetectionStrategy = cmpMeta.changeDetection;

isComponent: lang_1.isPresent(templateMeta),
type: this.getTypeMetadata(directiveType, staticTypeModuleUrl(directiveType)),
type: this.getTypeMetadata(directiveType, lang_1.isPresent(cmpMeta) ?
componentModuleUrl(this._reflector, directiveType, cmpMeta) :
staticTypeModuleUrl(dirMeta)),
template: templateMeta,

@@ -378,3 +379,3 @@ changeDetection: changeDetectionStrategy,

function isStaticType(value) {
return lang_1.isStringMap(value) && lang_1.isPresent(value['name']) && lang_1.isPresent(value['moduleId']);
return lang_1.isStringMap(value) && lang_1.isPresent(value['name']) && lang_1.isPresent(value['filePath']);
}

@@ -385,7 +386,7 @@ function isValidType(value) {

function staticTypeModuleUrl(value) {
return isStaticType(value) ? value['moduleId'] : null;
return isStaticType(value) ? value['filePath'] : null;
}
function calcTemplateBaseUrl(reflector, type, cmpMetadata) {
function componentModuleUrl(reflector, type, cmpMetadata) {
if (isStaticType(type)) {
return type['filePath'];
return staticTypeModuleUrl(type);
}

@@ -392,0 +393,0 @@ if (lang_1.isPresent(cmpMetadata.moduleId)) {

@@ -7,2 +7,3 @@ import { CompileDirectiveMetadata, CompilePipeMetadata } from './compile_metadata';

import { OutputEmitter } from './output/abstract_emitter';
import { XHR } from './xhr';
export declare class SourceModule {

@@ -13,2 +14,7 @@ moduleUrl: string;

}
export declare class StyleSheetSourceWithImports {
source: SourceModule;
importedUrls: string[];
constructor(source: SourceModule, importedUrls: string[]);
}
export declare class NormalizedComponentWithViewDirectives {

@@ -26,8 +32,10 @@ component: CompileDirectiveMetadata;

private _outputEmitter;
constructor(_directiveNormalizer: DirectiveNormalizer, _templateParser: TemplateParser, _styleCompiler: StyleCompiler, _viewCompiler: ViewCompiler, _outputEmitter: OutputEmitter);
private _xhr;
constructor(_directiveNormalizer: DirectiveNormalizer, _templateParser: TemplateParser, _styleCompiler: StyleCompiler, _viewCompiler: ViewCompiler, _outputEmitter: OutputEmitter, _xhr: XHR);
normalizeDirectiveMetadata(directive: CompileDirectiveMetadata): Promise<CompileDirectiveMetadata>;
compileTemplates(components: NormalizedComponentWithViewDirectives[]): SourceModule;
compileStylesheet(stylesheetUrl: string, cssText: string): SourceModule[];
loadAndCompileStylesheet(stylesheetUrl: string, shim: boolean, suffix: string): Promise<StyleSheetSourceWithImports>;
private _compileComponent(compMeta, directives, pipes, targetStatements);
private _codgenStyles(inputUrl, shim, suffix, stylesCompileResult);
private _codegenSourceModule(moduleUrl, statements, exportedVars);
}

@@ -21,2 +21,10 @@ "use strict";

exports.SourceModule = SourceModule;
var StyleSheetSourceWithImports = (function () {
function StyleSheetSourceWithImports(source, importedUrls) {
this.source = source;
this.importedUrls = importedUrls;
}
return StyleSheetSourceWithImports;
}());
exports.StyleSheetSourceWithImports = StyleSheetSourceWithImports;
var NormalizedComponentWithViewDirectives = (function () {

@@ -32,3 +40,3 @@ function NormalizedComponentWithViewDirectives(component, directives, pipes) {

var OfflineCompiler = (function () {
function OfflineCompiler(_directiveNormalizer, _templateParser, _styleCompiler, _viewCompiler, _outputEmitter) {
function OfflineCompiler(_directiveNormalizer, _templateParser, _styleCompiler, _viewCompiler, _outputEmitter, _xhr) {
this._directiveNormalizer = _directiveNormalizer;

@@ -39,2 +47,3 @@ this._templateParser = _templateParser;

this._outputEmitter = _outputEmitter;
this._xhr = _xhr;
}

@@ -72,9 +81,14 @@ OfflineCompiler.prototype.normalizeDirectiveMetadata = function (directive) {

};
OfflineCompiler.prototype.compileStylesheet = function (stylesheetUrl, cssText) {
var plainStyles = this._styleCompiler.compileStylesheet(stylesheetUrl, cssText, false);
var shimStyles = this._styleCompiler.compileStylesheet(stylesheetUrl, cssText, true);
return [
this._codegenSourceModule(_stylesModuleUrl(stylesheetUrl, false), _resolveStyleStatements(plainStyles), [plainStyles.stylesVar]),
this._codegenSourceModule(_stylesModuleUrl(stylesheetUrl, true), _resolveStyleStatements(shimStyles), [shimStyles.stylesVar])
];
OfflineCompiler.prototype.loadAndCompileStylesheet = function (stylesheetUrl, shim, suffix) {
var _this = this;
return this._xhr.get(stylesheetUrl)
.then(function (cssText) {
var compileResult = _this._styleCompiler.compileStylesheet(stylesheetUrl, cssText, shim);
var importedUrls = [];
compileResult.dependencies.forEach(function (dep) {
importedUrls.push(dep.moduleUrl);
dep.valuePlaceholder.moduleUrl = _stylesModuleUrl(dep.moduleUrl, dep.isShimmed, suffix);
});
return new StyleSheetSourceWithImports(_this._codgenStyles(stylesheetUrl, shim, suffix, compileResult), importedUrls);
});
};

@@ -85,6 +99,9 @@ OfflineCompiler.prototype._compileComponent = function (compMeta, directives, pipes, targetStatements) {

var viewResult = this._viewCompiler.compileComponent(compMeta, parsedTemplate, o.variable(styleResult.stylesVar), pipes);
collection_1.ListWrapper.addAll(targetStatements, _resolveStyleStatements(styleResult));
collection_1.ListWrapper.addAll(targetStatements, _resolveStyleStatements(compMeta.type.moduleUrl, styleResult));
collection_1.ListWrapper.addAll(targetStatements, _resolveViewStatements(viewResult));
return viewResult.viewFactoryVar;
};
OfflineCompiler.prototype._codgenStyles = function (inputUrl, shim, suffix, stylesCompileResult) {
return this._codegenSourceModule(_stylesModuleUrl(inputUrl, shim, suffix), stylesCompileResult.statements, [stylesCompileResult.stylesVar]);
};
OfflineCompiler.prototype._codegenSourceModule = function (moduleUrl, statements, exportedVars) {

@@ -100,5 +117,7 @@ return new SourceModule(moduleUrl, this._outputEmitter.emitStatements(moduleUrl, statements, exportedVars));

}
function _resolveStyleStatements(compileResult) {
function _resolveStyleStatements(containingModuleUrl, compileResult) {
var containingSuffix = _splitSuffix(containingModuleUrl)[1];
compileResult.dependencies.forEach(function (dep) {
dep.valuePlaceholder.moduleUrl = _stylesModuleUrl(dep.sourceUrl, dep.isShimmed);
dep.valuePlaceholder.moduleUrl =
_stylesModuleUrl(dep.moduleUrl, dep.isShimmed, containingSuffix);
});

@@ -108,8 +127,7 @@ return compileResult.statements;

function _templateModuleUrl(comp) {
var moduleUrl = comp.type.moduleUrl;
var urlWithoutSuffix = moduleUrl.substring(0, moduleUrl.length - util_1.MODULE_SUFFIX.length);
return urlWithoutSuffix + ".ngfactory" + util_1.MODULE_SUFFIX;
var urlWithSuffix = _splitSuffix(comp.type.moduleUrl);
return urlWithSuffix[0] + ".ngfactory" + urlWithSuffix[1];
}
function _stylesModuleUrl(stylesheetUrl, shim) {
return shim ? stylesheetUrl + ".shim" + util_1.MODULE_SUFFIX : "" + stylesheetUrl + util_1.MODULE_SUFFIX;
function _stylesModuleUrl(stylesheetUrl, shim, suffix) {
return shim ? stylesheetUrl + ".shim" + suffix : "" + stylesheetUrl + suffix;
}

@@ -121,2 +139,11 @@ function _assertComponent(meta) {

}
function _splitSuffix(path) {
var lastDot = path.lastIndexOf('.');
if (lastDot !== -1) {
return [path.substring(0, lastDot), path.substring(lastDot)];
}
else {
return [path, ''];
}
}
//# sourceMappingURL=offline_compiler.js.map
import * as o from './output_ast';
import { OutputEmitter } from './abstract_emitter';
import { ImportGenerator } from './path_util';
export declare function debugOutputAstAsDart(ast: o.Statement | o.Expression | o.Type | any[]): string;
export declare class DartEmitter implements OutputEmitter {
constructor();
private _importGenerator;
constructor(_importGenerator: ImportGenerator);
emitStatements(moduleUrl: string, stmts: o.Statement[], exportedVars: string[]): string;
}

@@ -11,3 +11,2 @@ "use strict";

var abstract_emitter_1 = require('./abstract_emitter');
var path_util_1 = require('./path_util');
var _debugModuleUrl = 'asset://debug/lib';

@@ -42,5 +41,7 @@ function debugOutputAstAsDart(ast) {

var DartEmitter = (function () {
function DartEmitter() {
function DartEmitter(_importGenerator) {
this._importGenerator = _importGenerator;
}
DartEmitter.prototype.emitStatements = function (moduleUrl, stmts, exportedVars) {
var _this = this;
var srcParts = [];

@@ -53,3 +54,3 @@ // Note: We are not creating a library here as Dart does not need it.

converter.importsWithPrefixes.forEach(function (prefix, importedModuleUrl) {
srcParts.push("import '" + path_util_1.getImportModulePath(moduleUrl, importedModuleUrl, path_util_1.ImportEnv.Dart) + "' as " + prefix + ";");
srcParts.push("import '" + _this._importGenerator.getImportPath(moduleUrl, importedModuleUrl) + "' as " + prefix + ";");
});

@@ -56,0 +57,0 @@ srcParts.push(ctx.toSource());

@@ -1,10 +0,14 @@

export declare enum ImportEnv {
Dart = 0,
JS = 1,
}
/**
* Returns the module path to use for an import.
* Interface that defines how import statements should be generated.
*/
export declare function getImportModulePath(moduleUrlStr: string, importedUrlStr: string, importEnv: ImportEnv): string;
export declare function getRelativePath(modulePath: string, importedPath: string, importEnv: ImportEnv): string;
export declare function getLongestPathSegmentPrefix(arr1: string[], arr2: string[]): number;
export declare abstract class ImportGenerator {
static parseAssetUrl(url: string): AssetUrl;
abstract getImportPath(moduleUrlStr: string, importedUrlStr: string): string;
}
export declare class AssetUrl {
packageName: string;
firstLevelDir: string;
modulePath: string;
static parse(url: string, allowNonMatching?: boolean): AssetUrl;
constructor(packageName: string, firstLevelDir: string, modulePath: string);
}

@@ -6,32 +6,14 @@ "use strict";

var _ASSET_URL_RE = /asset:([^\/]+)\/([^\/]+)\/(.+)/g;
var _PATH_SEP = '/';
var _PATH_SEP_RE = /\//g;
(function (ImportEnv) {
ImportEnv[ImportEnv["Dart"] = 0] = "Dart";
ImportEnv[ImportEnv["JS"] = 1] = "JS";
})(exports.ImportEnv || (exports.ImportEnv = {}));
var ImportEnv = exports.ImportEnv;
/**
* Returns the module path to use for an import.
* Interface that defines how import statements should be generated.
*/
function getImportModulePath(moduleUrlStr, importedUrlStr, importEnv) {
var absolutePathPrefix = importEnv === ImportEnv.Dart ? "package:" : '';
var moduleUrl = _AssetUrl.parse(moduleUrlStr, false);
var importedUrl = _AssetUrl.parse(importedUrlStr, true);
if (lang_1.isBlank(importedUrl)) {
return importedUrlStr;
var ImportGenerator = (function () {
function ImportGenerator() {
}
// Try to create a relative path first
if (moduleUrl.firstLevelDir == importedUrl.firstLevelDir &&
moduleUrl.packageName == importedUrl.packageName) {
return getRelativePath(moduleUrl.modulePath, importedUrl.modulePath, importEnv);
}
else if (importedUrl.firstLevelDir == 'lib') {
return "" + absolutePathPrefix + importedUrl.packageName + "/" + importedUrl.modulePath;
}
throw new exceptions_1.BaseException("Can't import url " + importedUrlStr + " from " + moduleUrlStr);
}
exports.getImportModulePath = getImportModulePath;
var _AssetUrl = (function () {
function _AssetUrl(packageName, firstLevelDir, modulePath) {
ImportGenerator.parseAssetUrl = function (url) { return AssetUrl.parse(url); };
return ImportGenerator;
}());
exports.ImportGenerator = ImportGenerator;
var AssetUrl = (function () {
function AssetUrl(packageName, firstLevelDir, modulePath) {
this.packageName = packageName;

@@ -41,6 +23,7 @@ this.firstLevelDir = firstLevelDir;

}
_AssetUrl.parse = function (url, allowNonMatching) {
AssetUrl.parse = function (url, allowNonMatching) {
if (allowNonMatching === void 0) { allowNonMatching = true; }
var match = lang_1.RegExpWrapper.firstMatch(_ASSET_URL_RE, url);
if (lang_1.isPresent(match)) {
return new _AssetUrl(match[1], match[2], match[3]);
return new AssetUrl(match[1], match[2], match[3]);
}

@@ -52,31 +35,5 @@ if (allowNonMatching) {

};
return _AssetUrl;
return AssetUrl;
}());
function getRelativePath(modulePath, importedPath, importEnv) {
var moduleParts = modulePath.split(_PATH_SEP_RE);
var importedParts = importedPath.split(_PATH_SEP_RE);
var longestPrefix = getLongestPathSegmentPrefix(moduleParts, importedParts);
var resultParts = [];
var goParentCount = moduleParts.length - 1 - longestPrefix;
for (var i = 0; i < goParentCount; i++) {
resultParts.push('..');
}
if (goParentCount <= 0 && importEnv === ImportEnv.JS) {
resultParts.push('.');
}
for (var i = longestPrefix; i < importedParts.length; i++) {
resultParts.push(importedParts[i]);
}
return resultParts.join(_PATH_SEP);
}
exports.getRelativePath = getRelativePath;
function getLongestPathSegmentPrefix(arr1, arr2) {
var prefixSize = 0;
var minLen = lang_1.Math.min(arr1.length, arr2.length);
while (prefixSize < minLen && arr1[prefixSize] == arr2[prefixSize]) {
prefixSize++;
}
return prefixSize;
}
exports.getLongestPathSegmentPrefix = getLongestPathSegmentPrefix;
exports.AssetUrl = AssetUrl;
//# sourceMappingURL=path_util.js.map
import * as o from './output_ast';
import { OutputEmitter } from './abstract_emitter';
import { ImportGenerator } from './path_util';
export declare function debugOutputAstAsTypeScript(ast: o.Statement | o.Expression | o.Type | any[]): string;
export declare class TypeScriptEmitter implements OutputEmitter {
constructor();
private _importGenerator;
constructor(_importGenerator: ImportGenerator);
emitStatements(moduleUrl: string, stmts: o.Statement[], exportedVars: string[]): string;
}

@@ -11,3 +11,2 @@ "use strict";

var abstract_emitter_1 = require('./abstract_emitter');
var path_util_1 = require('./path_util');
var _debugModuleUrl = 'asset://debug/lib';

@@ -42,5 +41,7 @@ function debugOutputAstAsTypeScript(ast) {

var TypeScriptEmitter = (function () {
function TypeScriptEmitter() {
function TypeScriptEmitter(_importGenerator) {
this._importGenerator = _importGenerator;
}
TypeScriptEmitter.prototype.emitStatements = function (moduleUrl, stmts, exportedVars) {
var _this = this;
var converter = new _TsEmitterVisitor(moduleUrl);

@@ -53,3 +54,3 @@ var ctx = abstract_emitter_1.EmitterVisitorContext.createRoot(exportedVars);

srcParts.push("imp" +
("ort * as " + prefix + " from '" + path_util_1.getImportModulePath(moduleUrl, importedModuleUrl, path_util_1.ImportEnv.JS) + "';"));
("ort * as " + prefix + " from '" + _this._importGenerator.getImportPath(moduleUrl, importedModuleUrl) + "';"));
});

@@ -56,0 +57,0 @@ srcParts.push(ctx.toSource());

@@ -113,4 +113,4 @@ "use strict";

var cssText = cssTexts[i];
var nestedCompileResult = _this._styleCompiler.compileStylesheet(dep.sourceUrl, cssText, dep.isShimmed);
nestedCompileResultPromises.push(_this._resolveStylesCompileResult(dep.sourceUrl, nestedCompileResult));
var nestedCompileResult = _this._styleCompiler.compileStylesheet(dep.moduleUrl, cssText, dep.isShimmed);
nestedCompileResultPromises.push(_this._resolveStylesCompileResult(dep.moduleUrl, nestedCompileResult));
}

@@ -134,6 +134,6 @@ return async_1.PromiseWrapper.all(nestedCompileResultPromises);

RuntimeCompiler.prototype._loadStylesheetDep = function (dep) {
var cacheKey = "" + dep.sourceUrl + (dep.isShimmed ? '.shim' : '');
var cacheKey = "" + dep.moduleUrl + (dep.isShimmed ? '.shim' : '');
var cssTextPromise = this._styleCache.get(cacheKey);
if (lang_1.isBlank(cssTextPromise)) {
cssTextPromise = this._xhr.get(dep.sourceUrl);
cssTextPromise = this._xhr.get(dep.moduleUrl);
this._styleCache.set(cacheKey, cssTextPromise);

@@ -140,0 +140,0 @@ }

@@ -5,6 +5,6 @@ import { CompileIdentifierMetadata, CompileDirectiveMetadata } from './compile_metadata';

export declare class StylesCompileDependency {
sourceUrl: string;
moduleUrl: string;
isShimmed: boolean;
valuePlaceholder: CompileIdentifierMetadata;
constructor(sourceUrl: string, isShimmed: boolean, valuePlaceholder: CompileIdentifierMetadata);
constructor(moduleUrl: string, isShimmed: boolean, valuePlaceholder: CompileIdentifierMetadata);
}

@@ -11,0 +11,0 @@ export declare class StylesCompileResult {

@@ -13,4 +13,4 @@ "use strict";

var StylesCompileDependency = (function () {
function StylesCompileDependency(sourceUrl, isShimmed, valuePlaceholder) {
this.sourceUrl = sourceUrl;
function StylesCompileDependency(moduleUrl, isShimmed, valuePlaceholder) {
this.moduleUrl = moduleUrl;
this.isShimmed = isShimmed;

@@ -17,0 +17,0 @@ this.valuePlaceholder = valuePlaceholder;

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

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