forked from angular/angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(compiler): support css stylesheets in offline compiler
- Loading branch information
Showing
38 changed files
with
436 additions
and
388 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
import * as selector from './src/selector'; | ||
import * as pathUtil from './src/output/path_util'; | ||
|
||
export namespace __compiler_private__ { | ||
export type SelectorMatcher = selector.SelectorMatcher; | ||
export var SelectorMatcher = selector.SelectorMatcher; | ||
|
||
export type CssSelector = selector.CssSelector; | ||
export var CssSelector = selector.CssSelector; | ||
|
||
export type AssetUrl = pathUtil.AssetUrl; | ||
export var AssetUrl = pathUtil.AssetUrl; | ||
|
||
export type ImportGenerator = pathUtil.ImportGenerator; | ||
export var ImportGenerator = pathUtil.ImportGenerator; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import {BaseException} from '../../src/facade/exceptions'; | ||
import {isPresent, isBlank, RegExpWrapper, Math} from '../../src/facade/lang'; | ||
import {Injectable} from '@angular/core'; | ||
|
||
import {AssetUrl, ImportGenerator} from './path_util'; | ||
|
||
var _PATH_SEP = '/'; | ||
var _PATH_SEP_RE = /\//g; | ||
|
||
@Injectable() | ||
export class DartImportGenerator implements ImportGenerator { | ||
getImportPath(moduleUrlStr: string, importedUrlStr: string): string { | ||
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); | ||
} else if (importedUrl.firstLevelDir == 'lib') { | ||
return `package:${importedUrl.packageName}/${importedUrl.modulePath}`; | ||
} | ||
throw new BaseException(`Can't import url ${importedUrlStr} from ${moduleUrlStr}`); | ||
} | ||
} | ||
|
||
export function getRelativePath(modulePath: string, importedPath: string): string { | ||
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('..'); | ||
} | ||
for (var i = longestPrefix; i < importedParts.length; i++) { | ||
resultParts.push(importedParts[i]); | ||
} | ||
return resultParts.join(_PATH_SEP); | ||
} | ||
|
||
export function getLongestPathSegmentPrefix(arr1: string[], arr2: string[]): number { | ||
var prefixSize = 0; | ||
var minLen = Math.min(arr1.length, arr2.length); | ||
while (prefixSize < minLen && arr1[prefixSize] == arr2[prefixSize]) { | ||
prefixSize++; | ||
} | ||
return prefixSize; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.