feat(dart/transform): Use the render Compiler and the DirectiveParser
Update the `TemplateCompile` step to use the full render `Compiler`. Provide `DirectiveMetadata` for `ViewDefinition` objects and use it to run the `DirectiveParser` step of the render compile pipeline.
This commit is contained in:
@@ -57,6 +57,8 @@ void allTests() {
|
||||
outputs: {
|
||||
'a|web/bar.ng_deps.dart':
|
||||
'simple_annotation_files/expected/bar.ng_deps.dart',
|
||||
'a|web/bar.ng_meta.json':
|
||||
'simple_annotation_files/expected/bar.ng_meta.json',
|
||||
'a|web/index.ng_deps.dart':
|
||||
'simple_annotation_files/expected/index.ng_deps.dart'
|
||||
}),
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"MyComponent":{"id":"MyComponent","selector":"[soup]","compileChildren":true,"hostListeners":{},"hostProperties":{},"properties":{},"readAttributes":[],"type":1,"version":1}}
|
||||
@@ -58,6 +58,32 @@ void allTests() {
|
||||
var output = await processTemplates(reader, new AssetId('a', inputPath));
|
||||
_formatThenExpectEquals(output, expected);
|
||||
});
|
||||
|
||||
it('should parse `View` directives with a single dependency.', () async {
|
||||
var inputPath = 'template_compiler/one_directive_files/hello.ng_deps.dart';
|
||||
var expected = readFile(
|
||||
'template_compiler/one_directive_files/expected/hello.ng_deps.dart');
|
||||
|
||||
var output = await processTemplates(reader, new AssetId('a', inputPath));
|
||||
_formatThenExpectEquals(output, expected);
|
||||
});
|
||||
|
||||
it('should parse `View` directives with a single prefixed dependency.',
|
||||
() async {
|
||||
var inputPath = 'template_compiler/with_prefix_files/hello.ng_deps.dart';
|
||||
var expected = readFile(
|
||||
'template_compiler/with_prefix_files/expected/hello.ng_deps.dart');
|
||||
|
||||
var output = await processTemplates(reader, new AssetId('a', inputPath));
|
||||
_formatThenExpectEquals(output, expected);
|
||||
|
||||
inputPath = 'template_compiler/with_prefix_files/goodbye.ng_deps.dart';
|
||||
expected = readFile(
|
||||
'template_compiler/with_prefix_files/expected/goodbye.ng_deps.dart');
|
||||
|
||||
output = await processTemplates(reader, new AssetId('a', inputPath));
|
||||
_formatThenExpectEquals(output, expected);
|
||||
});
|
||||
}
|
||||
|
||||
void _formatThenExpectEquals(String actual, String expected) {
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"HelloCmp":
|
||||
{
|
||||
"id":"HelloCmp",
|
||||
"selector":"hello-app",
|
||||
"compileChildren":true,
|
||||
"hostListeners":{},
|
||||
"hostProperties":{},
|
||||
"properties":{},
|
||||
"readAttributes":[],
|
||||
"type":1,
|
||||
"version":1
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"HelloCmp":
|
||||
{
|
||||
"id":"HelloCmp",
|
||||
"selector":"hello-app",
|
||||
"compileChildren":true,
|
||||
"hostListeners":{},
|
||||
"hostProperties":{},
|
||||
"properties":{},
|
||||
"readAttributes":[],
|
||||
"type":1,
|
||||
"version":1
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"HelloCmp":
|
||||
{
|
||||
"id":"HelloCmp",
|
||||
"selector":"hello-app",
|
||||
"compileChildren":true,
|
||||
"hostListeners":{},
|
||||
"hostProperties":{},
|
||||
"properties":{},
|
||||
"readAttributes":[],
|
||||
"type":1,
|
||||
"version":1
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
library examples.hello_world.index_common_dart.ng_deps.dart;
|
||||
|
||||
import 'hello.dart';
|
||||
import 'package:angular2/angular2.dart'
|
||||
show bootstrap, Component, Directive, View, NgElement;
|
||||
|
||||
var _visited = false;
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
..registerType(HelloCmp, {
|
||||
'factory': () => new HelloCmp(),
|
||||
'parameters': const [const []],
|
||||
'annotations': const [
|
||||
const Component(selector: 'hello-app'),
|
||||
const View(template: 'goodbye-app', directives: const [GoodbyeCmp])
|
||||
]
|
||||
})
|
||||
..registerType(GoodbyeCmp, {
|
||||
'factory': () => new GoodbyeCmp(),
|
||||
'parameters': const [const []],
|
||||
'annotations': const [
|
||||
const Component(selector: 'goodbye-app'),
|
||||
const View(template: 'Goodbye')
|
||||
]
|
||||
});
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
library examples.hello_world.index_common_dart.ng_deps.dart;
|
||||
|
||||
import 'hello.dart';
|
||||
import 'package:angular2/angular2.dart'
|
||||
show bootstrap, Component, Directive, View, NgElement;
|
||||
|
||||
var _visited = false;
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
..registerType(HelloCmp, {
|
||||
'factory': () => new HelloCmp(),
|
||||
'parameters': const [const []],
|
||||
'annotations': const [
|
||||
const Component(selector: 'hello-app'),
|
||||
const View(template: 'goodbye-app', directives: const [GoodbyeCmp])
|
||||
]
|
||||
})
|
||||
..registerType(GoodbyeCmp, {
|
||||
'factory': () => new GoodbyeCmp(),
|
||||
'parameters': const [const []],
|
||||
'annotations': const [
|
||||
const Component(selector: 'goodbye-app'),
|
||||
const View(template: 'Goodbye')
|
||||
]
|
||||
});
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"HelloCmp":
|
||||
{
|
||||
"id":"HelloCmp",
|
||||
"selector":"hello-app",
|
||||
"compileChildren":true,
|
||||
"hostListeners":{},
|
||||
"hostProperties":{},
|
||||
"properties":{},
|
||||
"readAttributes":[],
|
||||
"type":1,
|
||||
"version":1
|
||||
},
|
||||
"GoodbyeCmp":{
|
||||
"id":"GoodbyeCmp",
|
||||
"selector":"goodbye-app",
|
||||
"compileChildren":true,
|
||||
"hostListeners":{},
|
||||
"hostProperties":{},
|
||||
"properties":{},
|
||||
"readAttributes":[],
|
||||
"type":1,
|
||||
"version":1
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"HelloCmp":
|
||||
{
|
||||
"id":"HelloCmp",
|
||||
"selector":"hello-app",
|
||||
"compileChildren":true,
|
||||
"hostListeners":{},
|
||||
"hostProperties":{},
|
||||
"properties":{},
|
||||
"readAttributes":[],
|
||||
"type":1,
|
||||
"version":1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"HelloCmp":
|
||||
{
|
||||
"id":"HelloCmp",
|
||||
"selector":"hello-app",
|
||||
"compileChildren":true,
|
||||
"hostListeners":{},
|
||||
"hostProperties":{},
|
||||
"properties":{},
|
||||
"readAttributes":[],
|
||||
"type":1,
|
||||
"version":1
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
library examples.hello_world.index_common_dart.ng_deps.dart;
|
||||
|
||||
import 'goodbye.dart';
|
||||
import 'package:angular2/angular2.dart'
|
||||
show bootstrap, Component, Directive, View, NgElement;
|
||||
|
||||
var _visited = false;
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
..registerType(GoodbyeCmp, {
|
||||
'factory': () => new GoodbyeCmp(),
|
||||
'parameters': const [const []],
|
||||
'annotations': const [
|
||||
const Component(selector: 'goodbye-app'),
|
||||
const View(template: 'Goodbye {{name}}')
|
||||
]
|
||||
})
|
||||
..registerGetters({'name': (o) => o.name})
|
||||
..registerSetters({'name': (o, v) => o.name = v});
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
library examples.hello_world.index_common_dart.ng_deps.dart;
|
||||
|
||||
import 'hello.dart';
|
||||
import 'goodbye.dart' as prefix;
|
||||
import 'goodbye.ng_deps.dart' as i0;
|
||||
import 'package:angular2/angular2.dart'
|
||||
show bootstrap, Component, Directive, View, NgElement;
|
||||
|
||||
var _visited = false;
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
..registerType(HelloCmp, {
|
||||
'factory': () => new HelloCmp(),
|
||||
'parameters': const [const []],
|
||||
'annotations': const [
|
||||
const Component(selector: 'hello-app'),
|
||||
const View(
|
||||
template: 'goodbye-app', directives: const [prefix.GoodbyeCmp])
|
||||
]
|
||||
});
|
||||
i0.initReflector(reflector);
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
library examples.hello_world.index_common_dart.ng_deps.dart;
|
||||
|
||||
import 'goodbye.dart';
|
||||
import 'package:angular2/angular2.dart'
|
||||
show bootstrap, Component, Directive, View, NgElement;
|
||||
|
||||
var _visited = false;
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
..registerType(GoodbyeCmp, {
|
||||
'factory': () => new GoodbyeCmp(),
|
||||
'parameters': const [const []],
|
||||
'annotations': const [
|
||||
const Component(selector: 'goodbye-app'),
|
||||
const View(template: 'Goodbye {{name}}')
|
||||
]
|
||||
});
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"GoodbyeCmp":{
|
||||
"id":"GoodbyeCmp",
|
||||
"selector":"goodbye-app",
|
||||
"compileChildren":true,
|
||||
"hostListeners":{},
|
||||
"hostProperties":{},
|
||||
"properties":{},
|
||||
"readAttributes":[],
|
||||
"type":1,
|
||||
"version":1
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
library examples.hello_world.index_common_dart.ng_deps.dart;
|
||||
|
||||
import 'hello.dart';
|
||||
import 'goodbye.dart' as prefix;
|
||||
import 'goodbye.ng_deps.dart' as i0;
|
||||
import 'package:angular2/angular2.dart'
|
||||
show bootstrap, Component, Directive, View, NgElement;
|
||||
|
||||
var _visited = false;
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
..registerType(HelloCmp, {
|
||||
'factory': () => new HelloCmp(),
|
||||
'parameters': const [const []],
|
||||
'annotations': const [
|
||||
const Component(selector: 'hello-app'),
|
||||
const View(
|
||||
template: 'goodbye-app', directives: const [prefix.GoodbyeCmp])
|
||||
]
|
||||
});
|
||||
i0.initReflector(reflector);
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"HelloCmp":
|
||||
{
|
||||
"id":"HelloCmp",
|
||||
"selector":"hello-app",
|
||||
"compileChildren":true,
|
||||
"hostListeners":{},
|
||||
"hostProperties":{},
|
||||
"properties":{},
|
||||
"readAttributes":[],
|
||||
"type":1,
|
||||
"version":1
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user