Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added angular_static.dart
Empty file.
23 changes: 19 additions & 4 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ packages:
analyzer:
description: analyzer
source: hosted
version: "0.11.10"
version: "0.12.2"
angular:
description:
path: ".."
Expand All @@ -15,17 +15,28 @@ packages:
description: args
source: hosted
version: "0.9.0"
barback:
description: barback
source: hosted
version: "0.11.1"
browser:
description: browser
source: hosted
version: "0.9.1"
code_transformers:
description: code_transformers
source: hosted
version: "0.0.1-dev.2"
collection:
description: collection
source: hosted
version: "0.9.1"
di:
description: di
source: hosted
description:
ref: null
resolved-ref: "88e0d48101517e1d3bc84f9d38d4a1b619db65aa"
url: "https://github.com/angular/di.dart.git"
source: git
version: "0.0.33"
html5lib:
description: html5lib
Expand All @@ -34,11 +45,15 @@ packages:
intl:
description: intl
source: hosted
version: "0.9.7"
version: "0.8.10+4"
logging:
description: logging
source: hosted
version: "0.9.1+1"
meta:
description: meta
source: hosted
version: "0.8.8"
path:
description: path
source: hosted
Expand Down
13 changes: 13 additions & 0 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,16 @@ dependencies:
path: ../
browser: any
unittest: any

transformers:
- angular:
dart_entries:
- web/todo.dart
- web/bouncing_balls.dart
html_files: # Need to split out to per-entry assets
- web/todo.html
- web/bouncing_balls.html

dependency_overrides:
di:
git: https://github.com/angular/di.dart.git
15 changes: 5 additions & 10 deletions example/web/animation.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
library animation;

import 'package:angular/angular.dart';
import 'package:angular/angular_dynamic.dart';
import 'package:angular/animate/module.dart';

// This annotation allows Dart to shake away any classes
// not used from Dart code nor listed in another @MirrorsUsed.
//
// If you create classes that are referenced from the Angular
// expressions, you must include a library target in @MirrorsUsed.
@MirrorsUsed(override: '*')
import 'dart:mirrors';

part 'animation/repeat_demo.dart';
part 'animation/visibility_demo.dart';
part 'animation/stress_demo.dart';
Expand All @@ -25,11 +18,13 @@ class AnimationDemoController {
}

main() {
ngBootstrap(module: new Module()
new NgDynamicApp()
.addModule(new Module()
..install(new NgAnimateModule())
..type(RepeatDemoComponent)
..type(VisibilityDemoComponent)
..type(StressDemoComponent)
..type(CssDemoComponent)
..type(AnimationDemoController));
..type(AnimationDemoController))
.run();
}
26 changes: 10 additions & 16 deletions example/web/bouncing_balls.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import 'package:perf_api/perf_api.dart';
import 'package:angular/angular.dart';
import 'package:angular/angular_dynamic.dart';
import 'package:angular/change_detection/change_detection.dart';
import 'dart:html';
import 'dart:math';
import 'dart:core';
Expand Down Expand Up @@ -30,18 +33,17 @@ class BallModel {
publishAs: 'bounce')
class BounceController {
var lastTime = window.performance.now();
var run = true;
var run = false;
var fps = 0;
var digestTime = 0;
var currentDigestTime = 0;
var balls = [];
final NgZone zone;
final Scope scope;
var ballClassName = 'ball';

BounceController(this.zone, this.scope) {
BounceController(this.scope) {
changeCount(100);
tick();
if (run) tick();
}

void toggleCSS() {
Expand All @@ -54,7 +56,7 @@ class BounceController {
}

void requestAnimationFrame(fn) {
window.requestAnimationFrame((_) => zone.run(fn));
window.requestAnimationFrame((_) => fn());
}

void changeCount(count) {
Expand Down Expand Up @@ -118,20 +120,12 @@ class MyModule extends Module {
MyModule() {
type(BounceController);
type(BallPositionDirective);
value(GetterCache, new GetterCache({
'x': (o) => o.x,
'y': (o) => o.y,
'bounce': (o) => o.bounce,
'fps': (o) => o.fps,
'balls': (o) => o.balls,
'length': (o) => o.length,
'digestTime': (o) => o.digestTime,
'ballClassName': (o) => o.ballClassName
}));
value(ScopeStats, new ScopeStats(report: true));
}
}

main() {
ngBootstrap(module: new MyModule());
new NgDynamicApp()
.addModule(new MyModule())
.run();
}
5 changes: 4 additions & 1 deletion example/web/hello_world.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:angular/angular.dart';
import 'package:angular/angular_dynamic.dart';

// This annotation allows Dart to shake away any classes
// not used from Dart code nor listed in another @MirrorsUsed.
Expand All @@ -16,5 +17,7 @@ class HelloWorldController {
}

main() {
ngBootstrap(module: new Module()..type(HelloWorldController));
new NgDynamicApp()
.addModule(new Module()..type(HelloWorldController))
.run();
}
14 changes: 4 additions & 10 deletions example/web/todo.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
library todo;

import 'package:angular/angular.dart';
import 'package:angular/angular_dynamic.dart';
import 'package:angular/playback/playback_http.dart';
import 'todo.dart';

import 'dart:html';

// This annotation allows Dart to shake away any classes
// not used from Dart code nor listed in another @MirrorsUsed.
//
// If you create classes that are referenced from the Angular
// expressions, you must include a library target in @MirrorsUsed.
@MirrorsUsed(override: '*')
import 'dart:mirrors';

class Item {
String text;
bool done;
Expand All @@ -39,13 +31,15 @@ abstract class ServerController {


// An implementation of ServerController that does nothing.
@NgInjectableService()
class NoServerController implements ServerController {
init(TodoController todo) { }
}


// An implementation of ServerController that fetches items from
// the server over HTTP.
@NgInjectableService()
class HttpServerController implements ServerController {
final Http _http;
HttpServerController(this._http);
Expand Down Expand Up @@ -128,5 +122,5 @@ main() {
module.type(HttpBackend, implementedBy: PlaybackHttpBackend);
}

ngBootstrap(module: module);
new NgDynamicApp().addModule(module).run();
}
2 changes: 1 addition & 1 deletion example/web/todo.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link rel="stylesheet" href="css/todo.css">
<title>Things To Do</title>
<script src="todo.dart" type="application/dart"></script>
<script src="../packages/browser/dart.js"></script>
<script src="packages/browser/dart.js"></script>
</head>
<body ng-app>

Expand Down
40 changes: 0 additions & 40 deletions lib/angular.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,46 +13,8 @@ library angular;
import 'dart:html' as dom;
import 'dart:js' as js;
import 'package:di/di.dart';
import 'package:di/dynamic_injector.dart';
import 'package:intl/date_symbol_data_local.dart';

/**
* If you are writing code accessed from Angular expressions, you must include
* your own @MirrorsUsed annotation or ensure that everything is tagged with
* the Ng annotations.
*
* All programs should also include a @MirrorsUsed(override: '*') which
* tells the compiler that only the explicitly listed libraries will
* be reflected over.
*
* This is a short-term fix until we implement a transformer-based solution
* which does not rely on mirrors.
*/
@MirrorsUsed(targets: const [
'angular',
'angular.animate',
'angular.core',
'angular.core.dom',
'angular.filter',
'angular.perf',
'angular.directive',
'angular.routing',
'angular.core.parser.Parser',
'angular.core.parser.dynamic_parser',
'angular.core.parser.lexer',
'perf_api',
List,
dom.NodeTreeSanitizer,
],
metaTargets: const [
NgInjectableService,
NgDirective,
NgController,
NgComponent,
NgFilter
])
import 'dart:mirrors' show MirrorsUsed;

import 'package:angular/core/module.dart';
import 'package:angular/core_dom/module.dart';
import 'package:angular/directive/module.dart';
Expand All @@ -68,8 +30,6 @@ export 'package:angular/core/parser/lexer.dart';
export 'package:angular/directive/module.dart';
export 'package:angular/filter/module.dart';
export 'package:angular/routing/module.dart';
export 'package:angular/change_detection/dirty_checking_change_detector.dart'
show FieldGetter, GetterCache;

part 'bootstrap.dart';
part 'introspection.dart';
56 changes: 56 additions & 0 deletions lib/angular_dynamic.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
library angular.dynamic;

import 'package:di/dynamic_injector.dart';
import "package:angular/angular.dart";
import 'package:angular/change_detection/change_detection.dart';
import 'package:angular/change_detection/dirty_checking_change_detector_dynamic.dart';
import 'package:angular/core/registry_dynamic.dart';
import 'dart:html' as dom;

/**
* If you are writing code accessed from Angular expressions, you must include
* your own @MirrorsUsed annotation or ensure that everything is tagged with
* the Ng annotations.
*
* All programs should also include a @MirrorsUsed(override: '*') which
* tells the compiler that only the explicitly listed libraries will
* be reflected over.
*
* This is a short-term fix until we implement a transformer-based solution
* which does not rely on mirrors.
*/
@MirrorsUsed(targets: const [
'angular',
'angular.animate',
'angular.core',
'angular.core.dom',
'angular.filter',
'angular.perf',
'angular.directive',
'angular.routing',
'angular.core.parser.Parser',
'angular.core.parser.dynamic_parser',
'angular.core.parser.lexer',
'perf_api',
List,
dom.NodeTreeSanitizer,
],
metaTargets: const [
NgInjectableService,
NgDirective,
NgController,
NgComponent,
NgFilter
])
import 'dart:mirrors' show MirrorsUsed;

class NgDynamicApp extends NgApp {
NgDynamicApp() {
ngModule
..type(MetadataExtractor, implementedBy: DynamicMetadataExtractor)
..type(FieldGetterFactory, implementedBy: DynamicFieldGetterFactory);
}

Injector createInjector()
=> new DynamicInjector(modules: modules);
}
28 changes: 28 additions & 0 deletions lib/angular_static.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
library angular.static;

// REMOVE once all mirrors dependencies are gone.
@MirrorsUsed(override: const ['*'], targets: const [])
import 'dart:mirrors';

import 'package:di/static_injector.dart';
import 'package:angular/angular.dart';
import 'package:angular/core/registry_static.dart';
import 'package:angular/change_detection/change_detection.dart';
import 'package:angular/change_detection/dirty_checking_change_detector_static.dart';

class NgStaticApp extends NgApp {
final Map<Type, TypeFactory> typeFactories;

NgStaticApp(Map<Type, TypeFactory> this.typeFactories,
Map<Type, Object> metadata,
Map<String, FieldGetter> fieldGetters,
ClosureMap closureMap) {
ngModule
..value(MetadataExtractor, new StaticMetadataExtractor(metadata))
..value(FieldGetterFactory, new StaticFieldGetterFactory(fieldGetters))
..value(ClosureMap, closureMap);
}

Injector createInjector()
=> new StaticInjector(modules: modules, typeFactories: typeFactories);
}
Loading