Skip to content

Commit c0dc6e4

Browse files
author
vakrilov
committed
Migrate to RC2
1 parent 93864b5 commit c0dc6e4

11 files changed

+83
-45
lines changed

Diff for: nativescript-angular/application.ts

+33-20
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,21 @@ import './polyfills/array';
66
import {rendererLog, rendererError} from "./trace";
77
import {SanitizationService} from '@angular/core/src/security';
88
import {isPresent, Type, print} from '@angular/core/src/facade/lang';
9-
import {ReflectiveInjector, reflector, coreLoadAndBootstrap, createPlatform,
10-
getPlatform, assertPlatform, ComponentRef, PlatformRef, PLATFORM_DIRECTIVES, PLATFORM_PIPES} from '@angular/core';
9+
import {ReflectiveInjector, coreLoadAndBootstrap, createPlatform,
10+
getPlatform, assertPlatform, ComponentRef, PlatformRef, PLATFORM_DIRECTIVES, PLATFORM_PIPES} from '@angular/core';
1111
import {bind, provide, Provider} from '@angular/core/src/di';
1212

1313
import {RootRenderer, Renderer} from '@angular/core/src/render/api';
1414
import {NativeScriptRootRenderer, NativeScriptRenderer} from './renderer';
1515
import {NativeScriptDomAdapter, NativeScriptElementSchemaRegistry, NativeScriptSanitizationService} from './dom_adapter';
16-
import {ElementSchemaRegistry, XHR, COMPILER_PROVIDERS} from '@angular/compiler';
16+
import {ElementSchemaRegistry, XHR, COMPILER_PROVIDERS, CompilerConfig} from '@angular/compiler';
1717
import {FileSystemXHR} from './xhr';
1818
import {Parse5DomAdapter} from '@angular/platform-server/src/parse5_adapter';
1919
import {ExceptionHandler} from '@angular/core/src/facade/exception_handler';
2020
import {APPLICATION_COMMON_PROVIDERS} from '@angular/core/src/application_common_providers';
2121
import {PLATFORM_COMMON_PROVIDERS} from '@angular/core/src/platform_common_providers';
2222
import {COMMON_DIRECTIVES, COMMON_PIPES, FORM_PROVIDERS} from "@angular/common";
2323
import {NS_DIRECTIVES} from './directives';
24-
import {ReflectionCapabilities} from '@angular/core/src/reflection/reflection_capabilities';
2524

2625
import {Page} from 'ui/page';
2726
import {TextView} from 'ui/text-view';
@@ -40,12 +39,27 @@ export interface AppOptions {
4039
}
4140

4241
class ConsoleLogger {
43-
log = print;
44-
logError = print;
45-
logGroup = print;
46-
logGroupEnd() {}
42+
log = print;
43+
logError = print;
44+
logGroup = print;
45+
logGroupEnd() { }
4746
}
4847

48+
// See: https://github.com/angular/angular/commit/1745366530266d298306b995ecd23dabd8569e28
49+
export const NS_COMPILER_PROVIDERS: ProviderArray = [
50+
COMPILER_PROVIDERS,
51+
provide(CompilerConfig, {
52+
useFactory: (platformDirectives: any[], platformPipes: any[]) => {
53+
return new CompilerConfig({ platformDirectives, platformPipes });
54+
},
55+
deps: [PLATFORM_DIRECTIVES, PLATFORM_PIPES]
56+
}),
57+
provide(XHR, { useClass: FileSystemXHR }),
58+
provide(PLATFORM_PIPES, { useValue: COMMON_PIPES, multi: true }),
59+
provide(PLATFORM_DIRECTIVES, { useValue: COMMON_DIRECTIVES, multi: true }),
60+
provide(PLATFORM_DIRECTIVES, { useValue: NS_DIRECTIVES, multi: true })
61+
];
62+
4963
export function bootstrap(appComponentType: any,
5064
customProviders: ProviderArray = null): Promise<ComponentRef<any>> {
5165
NativeScriptDomAdapter.makeCurrent();
@@ -57,12 +71,11 @@ export function bootstrap(appComponentType: any,
5771
let defaultAppProviders: ProviderArray = [
5872
APPLICATION_COMMON_PROVIDERS,
5973
FORM_PROVIDERS,
60-
provide(PLATFORM_PIPES, { useValue: COMMON_PIPES, multi: true }),
61-
provide(PLATFORM_DIRECTIVES, { useValue: COMMON_DIRECTIVES, multi: true }),
62-
provide(PLATFORM_DIRECTIVES, { useValue: NS_DIRECTIVES, multi: true }),
63-
provide(ExceptionHandler, { useFactory: () => {
64-
return new ExceptionHandler(new ConsoleLogger(), true)
65-
}, deps: [] }),
74+
provide(ExceptionHandler, {
75+
useFactory: () => {
76+
return new ExceptionHandler(new ConsoleLogger(), true)
77+
}, deps: []
78+
}),
6679

6780
defaultPageProvider,
6881
defaultDeviceProvider,
@@ -72,7 +85,7 @@ export function bootstrap(appComponentType: any,
7285
provide(Renderer, { useClass: NativeScriptRenderer }),
7386
provide(SanitizationService, { useClass: NativeScriptSanitizationService }),
7487
provide(ElementSchemaRegistry, { useClass: NativeScriptElementSchemaRegistry }),
75-
COMPILER_PROVIDERS,
88+
NS_COMPILER_PROVIDERS,
7689
provide(ElementSchemaRegistry, { useClass: NativeScriptElementSchemaRegistry }),
7790
provide(XHR, { useClass: FileSystemXHR }),
7891
]
@@ -82,14 +95,14 @@ export function bootstrap(appComponentType: any,
8295
appProviders.push(customProviders);
8396
}
8497

85-
var platform = getPlatform();
98+
var platform = getPlatform();
8699
if (!isPresent(platform)) {
87100
platform = createPlatform(ReflectiveInjector.resolveAndCreate(platformProviders));
88101
}
89-
90-
reflector.reflectionCapabilities = new ReflectionCapabilities();
102+
103+
// reflector.reflectionCapabilities = new ReflectionCapabilities();
91104
var appInjector = ReflectiveInjector.resolveAndCreate(appProviders, platform.injector);
92-
return coreLoadAndBootstrap(appInjector, appComponentType);
105+
return coreLoadAndBootstrap(appComponentType, appInjector);
93106
}
94107

95108
export function nativeScriptBootstrap(appComponentType: any, customProviders?: ProviderArray, appOptions?: AppOptions): Promise<ComponentRef<any>> {
@@ -105,7 +118,7 @@ export function nativeScriptBootstrap(appComponentType: any, customProviders?: P
105118
page.actionBarHidden = appOptions.startPageActionBarHidden;
106119
}
107120

108-
let onLoadedHandler = function(args) {
121+
let onLoadedHandler = function (args) {
109122
page.off('loaded', onLoadedHandler);
110123
//profiling.stop('application-start');
111124
rendererLog('Page loaded');

Diff for: nativescript-angular/package.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
},
2020
"dependencies": {
2121
"nativescript-intl": "^0.0.2",
22-
"@angular/common": "2.0.0-rc.1",
23-
"@angular/compiler": "2.0.0-rc.1",
24-
"@angular/core": "2.0.0-rc.1",
25-
"@angular/platform-browser": "2.0.0-rc.1",
26-
"@angular/platform-browser-dynamic": "2.0.0-rc.1",
27-
"@angular/platform-server": "2.0.0-rc.1",
28-
"@angular/router-deprecated": "2.0.0-rc.1",
22+
"@angular/common": "2.0.0-rc.2",
23+
"@angular/compiler": "2.0.0-rc.2",
24+
"@angular/core": "2.0.0-rc.2",
25+
"@angular/platform-browser": "2.0.0-rc.2",
26+
"@angular/platform-browser-dynamic": "2.0.0-rc.2",
27+
"@angular/platform-server": "2.0.0-rc.2",
28+
"@angular/router-deprecated": "2.0.0-rc.2",
2929
"rxjs": "5.0.0-beta.6",
3030
"zone.js": "^0.6.12",
3131
"reflect-metadata": "^0.1.3",

Diff for: nativescript-angular/renderer.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import {
55
RenderComponentType,
66
RenderDebugInfo
77
} from '@angular/core/src/render/api';
8+
import { AnimationKeyframe } from '@angular/core/src/animation/animation_keyframe';
9+
import { AnimationPlayer } from '@angular/core/src/animation/animation_player';
10+
import { AnimationStyles } from '@angular/core/src/animation/animation_styles';
811
import {APP_ROOT_VIEW, DEVICE} from "./platform-providers";
912
import {isBlank} from '@angular/core/src/facade/lang';
1013
import {CONTENT_ATTR} from '@angular/platform-browser/src/dom/dom_renderer';
@@ -217,13 +220,17 @@ export class NativeScriptRenderer extends Renderer {
217220
let zonedCallback = (<any>global).Zone.current.wrap(callback);
218221
renderElement.on(eventName, zonedCallback);
219222
if (eventName === View.loadedEvent && renderElement.isLoaded) {
220-
const notifyData = {eventName: View.loadedEvent, object: renderElement};
223+
const notifyData = { eventName: View.loadedEvent, object: renderElement };
221224
zonedCallback(notifyData);
222225
}
223226
return () => renderElement.off(eventName, zonedCallback);
224227
}
225228

226229
public listenGlobal(target: string, eventName: string, callback: Function): Function {
227-
throw new Error('Not implemented.');
230+
throw new Error('NativeScriptRenderer.listenGlobal() - Not implemented.');
231+
}
232+
233+
public animate(element: any, startingStyles: AnimationStyles, keyframes: AnimationKeyframe[], duration: number, delay: number, easing: string): AnimationPlayer {
234+
throw new Error("NativeScriptRenderer.animate() - Not implemented");
228235
}
229236
}

Diff for: nativescript-angular/router/ns-location-strategy.ts

+14-1
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,14 @@ export class NSLocationStrategy extends LocationStrategy {
3030
return internal;
3131
}
3232

33+
3334
pushState(state: any, title: string, url: string, queryParams: string): void {
3435
routerLog(`NSLocationStrategy.pushState state: ${state}, title: ${title}, url: ${url}, queryParams: ${queryParams}`);
36+
this.pushStateInternal(state, title, url, queryParams);
37+
}
38+
39+
pushStateInternal(state: any, title: string, url: string, queryParams: string): void {
40+
routerLog(`NSLocationStrategy.pushState state: ${state}, title: ${title}, url: ${url}, queryParams: ${queryParams}`);
3541

3642
let isNewPage = this._isPageNavigatingForward;
3743
this._isPageNavigatingForward = false;
@@ -47,7 +53,14 @@ export class NSLocationStrategy extends LocationStrategy {
4753

4854
replaceState(state: any, title: string, url: string, queryParams: string): void {
4955
routerLog(`NSLocationStrategy.replaceState state: ${state}, title: ${title}, url: ${url}, queryParams: ${queryParams}`);
50-
throw new Error("Not implemented");
56+
57+
if (this.states.length > 0) {
58+
let oldState = this.states.pop();
59+
routerLog(`NSLocationStrategy.replaceState POP state: ${oldState.state}, title: ${oldState.title}, url: ${oldState.url}, queryParams: ${oldState.queryParams}`);
60+
this.callPopState(oldState, true);
61+
}
62+
63+
this.pushStateInternal(state, title, url, queryParams);
5164
}
5265

5366
forward(): void {

Diff for: nativescript-angular/value-accessors/base-value-accessor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {View} from "ui/core/view";
2-
import {ControlValueAccessor} from '@angular/common/src/forms/directives/control_value_accessor';
2+
import {ControlValueAccessor} from '@angular/common/src/forms-deprecated/directives/control_value_accessor';
33

44
export class BaseValueAccessor<TView> implements ControlValueAccessor {
55
constructor(public view: TView) { }

Diff for: nativescript-angular/value-accessors/checked-value-accessor.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Directive, ElementRef, Renderer, Self, forwardRef, provide} from '@angular/core';
2-
import {NG_VALUE_ACCESSOR} from '@angular/common/src/forms/directives/control_value_accessor';
2+
import {NG_VALUE_ACCESSOR} from '@angular/common/src/forms-deprecated/directives/control_value_accessor';
33
import {isBlank} from '@angular/core/src/facade/lang';
44
import {BaseValueAccessor} from './base-value-accessor';
55
import {Switch} from "ui/switch";
@@ -18,7 +18,7 @@ const CHECKED_VALUE_ACCESSOR = provide(NG_VALUE_ACCESSOR, { useExisting: forward
1818
@Directive({
1919
selector: 'Switch[ngModel]',
2020
host: { '(checkedChange)': 'onChange($event.value)' },
21-
bindings: [CHECKED_VALUE_ACCESSOR]
21+
providers: [CHECKED_VALUE_ACCESSOR]
2222
})
2323
export class CheckedValueAccessor extends BaseValueAccessor<Switch> {
2424
onTouched = () => { };

Diff for: nativescript-angular/value-accessors/date-value-accessor.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Directive, ElementRef, Renderer, Self, forwardRef, provide} from '@angular/core';
2-
import {NG_VALUE_ACCESSOR} from '@angular/common/src/forms/directives/control_value_accessor';
2+
import {NG_VALUE_ACCESSOR} from '@angular/common/src/forms-deprecated/directives/control_value_accessor';
33
import {isBlank, isDate} from '@angular/core/src/facade/lang';
44
import {BaseValueAccessor} from './base-value-accessor';
55
import {DatePicker} from "ui/date-picker";
@@ -18,7 +18,7 @@ const DATE_VALUE_ACCESSOR = provide(NG_VALUE_ACCESSOR, { useExisting: forwardRef
1818
@Directive({
1919
selector: 'DatePicker[ngModel]',
2020
host: { '(dateChange)': 'onChange($event.value)' },
21-
bindings: [DATE_VALUE_ACCESSOR]
21+
providers: [DATE_VALUE_ACCESSOR]
2222
})
2323
export class DateValueAccessor extends BaseValueAccessor<DatePicker> {
2424
onTouched = () => { };
@@ -30,9 +30,12 @@ export class DateValueAccessor extends BaseValueAccessor<DatePicker> {
3030
writeValue(value: any): void {
3131
var normalizedValue = isBlank(value) ? new Date() : value;
3232
if (!isDate(normalizedValue)) {
33-
if (typeof normalizedValue === 'string' || typeof normalizedValue === 'number') {
33+
if (typeof normalizedValue === 'string') {
34+
normalizedValue = new Date(normalizedValue);
35+
} else if (typeof normalizedValue === 'number') {
3436
normalizedValue = new Date(normalizedValue);
3537
}
38+
3639
if (!isDate(normalizedValue)) {
3740
normalizedValue = new Date();
3841
}

Diff for: nativescript-angular/value-accessors/number-value-accessor.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Directive, ElementRef, Renderer, Self, forwardRef, provide} from '@angular/core';
2-
import {NG_VALUE_ACCESSOR} from '@angular/common/src/forms/directives/control_value_accessor';
2+
import {NG_VALUE_ACCESSOR} from '@angular/common/src/forms-deprecated/directives/control_value_accessor';
33
import {isBlank, isNumber} from '@angular/core/src/facade/lang';
44
import {BaseValueAccessor} from './base-value-accessor';
55
import {Slider} from "ui/slider";
@@ -18,7 +18,7 @@ const NUMBER_VALUE_ACCESSOR = provide(NG_VALUE_ACCESSOR, { useExisting: forwardR
1818
@Directive({
1919
selector: 'Slider[ngModel]',
2020
host: { '(valueChange)': 'onChange($event.value)' },
21-
bindings: [NUMBER_VALUE_ACCESSOR]
21+
providers: [NUMBER_VALUE_ACCESSOR]
2222
})
2323
export class NumberValueAccessor extends BaseValueAccessor<Slider> {
2424
onTouched = () => { };

Diff for: nativescript-angular/value-accessors/selectedIndex-value-accessor.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Directive, ElementRef, Renderer, Self, forwardRef, provide} from '@angular/core';
2-
import {NG_VALUE_ACCESSOR} from '@angular/common/src/forms/directives/control_value_accessor';
2+
import {NG_VALUE_ACCESSOR} from '@angular/common/src/forms-deprecated/directives/control_value_accessor';
33
import {isBlank, isNumber} from '@angular/core/src/facade/lang';
44
import {BaseValueAccessor} from './base-value-accessor';
55
import {View} from "ui/core/view";
@@ -21,7 +21,7 @@ export type SelectableView = {selectedIndex: number} & View;
2121
@Directive({
2222
selector: 'SegmentedBar[ngModel], ListPicker[ngModel], TabView[ngModel]',
2323
host: { '(selectedIndexChange)': 'onChange($event.value)' },
24-
bindings: [SELECTED_INDEX_VALUE_ACCESSOR]
24+
providers: [SELECTED_INDEX_VALUE_ACCESSOR]
2525
})
2626
export class SelectedIndexValueAccessor extends BaseValueAccessor<SelectableView> {
2727
onTouched = () => { };

Diff for: nativescript-angular/value-accessors/text-value-accessor.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Directive, ElementRef, Renderer, Self, forwardRef, provide} from '@angular/core';
2-
import {NG_VALUE_ACCESSOR} from '@angular/common/src/forms/directives/control_value_accessor';
2+
import {NG_VALUE_ACCESSOR} from '@angular/common/src/forms-deprecated/directives/control_value_accessor';
33
import {isBlank} from '@angular/core/src/facade/lang';
44
import {BaseValueAccessor} from './base-value-accessor'
55
import {View} from "ui/core/view";
@@ -20,7 +20,7 @@ export type TextView = {text: string} & View;
2020
@Directive({
2121
selector: 'TextField[ngModel], TextView[ngModel], SearchBar[ngModel]',
2222
host: { '(textChange)': 'onChange($event.value)' },
23-
bindings: [TEXT_VALUE_ACCESSOR]
23+
providers: [TEXT_VALUE_ACCESSOR]
2424
})
2525
export class TextValueAccessor extends BaseValueAccessor<TextView> {
2626
onTouched = () => { };

Diff for: nativescript-angular/value-accessors/time-value-accessor.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Directive, ElementRef, Renderer, Self, forwardRef, provide} from '@angular/core';
2-
import {NG_VALUE_ACCESSOR} from '@angular/common/src/forms/directives/control_value_accessor';
2+
import {NG_VALUE_ACCESSOR} from '@angular/common/src/forms-deprecated/directives/control_value_accessor';
33
import {isBlank, isDate} from '@angular/core/src/facade/lang';
44
import {BaseValueAccessor} from './base-value-accessor';
55
import {TimePicker} from "ui/time-picker";
@@ -18,7 +18,7 @@ const TIME_VALUE_ACCESSOR = provide(NG_VALUE_ACCESSOR, { useExisting: forwardRef
1818
@Directive({
1919
selector: 'TimePicker[ngModel]',
2020
host: { '(timeChange)': 'onChange($event.value)' },
21-
bindings: [TIME_VALUE_ACCESSOR]
21+
providers: [TIME_VALUE_ACCESSOR]
2222
})
2323
export class TimeValueAccessor extends BaseValueAccessor<TimePicker> {
2424
onTouched = () => { };
@@ -30,7 +30,9 @@ export class TimeValueAccessor extends BaseValueAccessor<TimePicker> {
3030
writeValue(value: any): void {
3131
var normalizedValue = isBlank(value) ? new Date() : value;
3232
if (!isDate(normalizedValue)) {
33-
if (typeof normalizedValue === 'string' || typeof normalizedValue === 'number') {
33+
if (typeof normalizedValue === 'string') {
34+
normalizedValue = new Date(normalizedValue);
35+
} else if (typeof normalizedValue === 'number') {
3436
normalizedValue = new Date(normalizedValue);
3537
}
3638
if (!isDate(normalizedValue)) {

0 commit comments

Comments
 (0)