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.
build: fix circular dep between interface and l_node by merging (angu…
…lar#20855) PR Close angular#20855
- Loading branch information
Showing
17 changed files
with
453 additions
and
434 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
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,87 @@ | ||
/** | ||
* @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 | ||
*/ | ||
|
||
import {RendererType2} from '../render/api'; | ||
import {Type} from '../type'; | ||
import {resolveRendererType2} from '../view/util'; | ||
|
||
import {ComponentDef, ComponentDefArgs, DirectiveDef, DirectiveDefArgs} from './definition_interfaces'; | ||
import {componentRefresh, diPublic} from './instructions'; | ||
|
||
|
||
|
||
/** | ||
* Create a component definition object. | ||
* | ||
* | ||
* # Example | ||
* ``` | ||
* class MyDirective { | ||
* // Generated by Angular Template Compiler | ||
* // [Symbol] syntax will not be supported by TypeScript until v2.7 | ||
* static [COMPONENT_DEF_SYMBOL] = defineComponent({ | ||
* ... | ||
* }); | ||
* } | ||
* ``` | ||
*/ | ||
export function defineComponent<T>(componentDefinition: ComponentDefArgs<T>): ComponentDef<T> { | ||
const def = <ComponentDef<any>>{ | ||
type: componentDefinition.type, | ||
diPublic: null, | ||
n: componentDefinition.factory, | ||
tag: (componentDefinition as ComponentDefArgs<T>).tag || null !, | ||
template: (componentDefinition as ComponentDefArgs<T>).template || null !, | ||
r: componentDefinition.refresh || | ||
function(d: number, e: number) { componentRefresh(d, e, componentDefinition.template); }, | ||
inputs: invertObject(componentDefinition.inputs), | ||
outputs: invertObject(componentDefinition.outputs), | ||
methods: invertObject(componentDefinition.methods), | ||
rendererType: resolveRendererType2(componentDefinition.rendererType) || null, | ||
}; | ||
const feature = componentDefinition.features; | ||
feature && feature.forEach((fn) => fn(def)); | ||
return def; | ||
} | ||
|
||
export function NgOnChangesFeature<T>(definition: DirectiveDef<T>) { | ||
// TODO: implement. See: https://app.asana.com/0/443577627818617/465170715764659 | ||
} | ||
|
||
export function PublicFeature<T>(definition: DirectiveDef<T>) { | ||
definition.diPublic = diPublic; | ||
} | ||
|
||
const EMPTY = {}; | ||
|
||
/** Swaps the keys and values of an object. */ | ||
function invertObject(obj: any): any { | ||
if (obj == null) return EMPTY; | ||
const newObj: any = {}; | ||
for (let minifiedKey in obj) { | ||
newObj[obj[minifiedKey]] = minifiedKey; | ||
} | ||
return newObj; | ||
} | ||
|
||
/** | ||
* Create a directive definition object. | ||
* | ||
* # Example | ||
* ``` | ||
* class MyDirective { | ||
* // Generated by Angular Template Compiler | ||
* // [Symbol] syntax will not be supported by TypeScript until v2.7 | ||
* static [DIRECTIVE_DEF_SYMBOL] = defineDirective({ | ||
* ... | ||
* }); | ||
* } | ||
* ``` | ||
*/ | ||
export const defineDirective = defineComponent as<T>(directiveDefinition: DirectiveDefArgs<T>) => | ||
DirectiveDef<T>; |
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.