Skip to content

Commit b376e62

Browse files
authored
Merge branch 'master' into border-outline
2 parents bc92fb7 + 4c5ce60 commit b376e62

File tree

77 files changed

+1147
-1125
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+1147
-1125
lines changed

tns-core-modules/application-settings/application-settings-common.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
export var checkKey = function (key: string): void {
1+
export function checkKey(key: string): void {
22
if (typeof key !== "string") {
33
throw new Error("key: '" + key + "' must be a string");
44
}
55
}
66

7-
export var ensureValidValue = function (value: any, valueType: string): void {
7+
export function ensureValidValue(value: any, valueType: string): void {
88
if (typeof value !== valueType) {
99
throw new Error("value: '" + value + "' must be a " + valueType);
1010
}

tns-core-modules/application-settings/application-settings.android.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as common from "./application-settings-common";
22
import { getNativeApplication } from "../application";
33

4-
var sharedPreferences: android.content.SharedPreferences;
4+
let sharedPreferences: android.content.SharedPreferences;
55
function ensureSharedPreferences() {
66
if (!sharedPreferences) {
77
sharedPreferences = (<android.app.Application>getNativeApplication()).getApplicationContext().getSharedPreferences("prefs.db", 0);
@@ -47,30 +47,30 @@ export function getNumber(key: string, defaultValue?: number): number {
4747
export function setBoolean(key: string, value: boolean): void {
4848
verify(key);
4949
common.ensureValidValue(value, "boolean");
50-
var editor = sharedPreferences.edit();
50+
const editor = sharedPreferences.edit();
5151
editor.putBoolean(key, value);
5252
editor.apply();
5353
}
5454

5555
export function setString(key: string, value: string): void {
5656
verify(key);
5757
common.ensureValidValue(value, "string");
58-
var editor = sharedPreferences.edit();
58+
const editor = sharedPreferences.edit();
5959
editor.putString(key, value);
6060
editor.apply();
6161
}
6262

6363
export function setNumber(key: string, value: number): void {
6464
verify(key);
6565
common.ensureValidValue(value, "number");
66-
var editor = sharedPreferences.edit();
66+
const editor = sharedPreferences.edit();
6767
editor.putFloat(key, float(value));
6868
editor.apply();
6969
}
7070

7171
export function remove(key: string): void {
7272
verify(key);
73-
var editor = sharedPreferences.edit();
73+
const editor = sharedPreferences.edit();
7474
editor.remove(key);
7575
editor.apply();
7676
}
@@ -80,14 +80,14 @@ export function clear(): void {
8080
sharedPreferences.edit().clear().apply();
8181
}
8282

83-
export var flush = function (): boolean {
83+
export function flush(): boolean {
8484
return sharedPreferences.edit().commit();
8585
}
8686

8787
export function getAllKeys(): Array<string> {
88-
var mappedPreferences = sharedPreferences.getAll();
89-
var iterator = mappedPreferences.keySet().iterator();
90-
var result = [];
88+
const mappedPreferences = sharedPreferences.getAll();
89+
const iterator = mappedPreferences.keySet().iterator();
90+
const result = [];
9191
while (iterator.hasNext()) {
9292
let key = iterator.next();
9393
result.push(key);

tns-core-modules/application-settings/application-settings.ios.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,67 +2,71 @@
22

33
import * as utils from "../utils/utils";
44

5-
var userDefaults = NSUserDefaults.standardUserDefaults;
5+
const userDefaults = NSUserDefaults.standardUserDefaults;
66

7-
export var hasKey = function (key: string): boolean {
7+
export function hasKey(key: string): boolean {
88
Common.checkKey(key);
9+
910
return userDefaults.objectForKey(key) !== null;
1011
}
1112

1213
// utils.ios.getters
13-
export var getBoolean = function (key: string, defaultValue?: boolean): boolean {
14+
export function getBoolean(key: string, defaultValue?: boolean): boolean {
1415
Common.checkKey(key);
1516
if (hasKey(key)) {
1617
return userDefaults.boolForKey(key);
1718
}
19+
1820
return defaultValue;
1921
}
2022

21-
export var getString = function (key: string, defaultValue?: string): string {
23+
export function getString(key: string, defaultValue?: string): string {
2224
Common.checkKey(key);
2325
if (hasKey(key)) {
2426
return userDefaults.stringForKey(key);
2527
}
28+
2629
return defaultValue;
2730
}
2831

29-
export var getNumber = function (key: string, defaultValue?: number): number {
32+
export function getNumber(key: string, defaultValue?: number): number {
3033
Common.checkKey(key);
3134
if (hasKey(key)) {
3235
return userDefaults.doubleForKey(key);
3336
}
37+
3438
return defaultValue;
3539
}
3640

3741
// setters
38-
export var setBoolean = function (key: string, value: boolean): void {
42+
export function setBoolean(key: string, value: boolean): void {
3943
Common.checkKey(key);
4044
Common.ensureValidValue(value, "boolean");
4145
userDefaults.setBoolForKey(value, key);
4246
}
4347

44-
export var setString = function (key: string, value: string): void {
48+
export function setString(key: string, value: string): void {
4549
Common.checkKey(key);
4650
Common.ensureValidValue(value, "string");
4751
userDefaults.setObjectForKey(value, key);
4852
}
4953

50-
export var setNumber = function (key: string, value: number): void {
54+
export function setNumber(key: string, value: number): void {
5155
Common.checkKey(key);
5256
Common.ensureValidValue(value, "number");
5357
userDefaults.setDoubleForKey(value, key);
5458
}
5559

56-
export var remove = function (key: string): void {
60+
export function remove(key: string): void {
5761
Common.checkKey(key);
5862
userDefaults.removeObjectForKey(key);
5963
}
6064

61-
export var clear = function (): void {
65+
export function clear(): void {
6266
userDefaults.removePersistentDomainForName(NSBundle.mainBundle.bundleIdentifier);
6367
}
6468

65-
export var flush = function (): boolean {
69+
export function flush(): boolean {
6670
return userDefaults.synchronize();
6771
}
6872

tns-core-modules/application/application.android.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,8 @@ let mainEntry: NavigationEntry;
131131
let started = false;
132132
// NOTE: for backwards compatibility. Remove for 4.0.0.
133133
const createRootFrame = { value: true };
134-
export function start(entry?: NavigationEntry | string) {
135-
console.log("application.start() is deprecated; use application.run() instead");
136134

135+
function _start(entry?: NavigationEntry | string) {
137136
if (started) {
138137
throw new Error("Application is already started.");
139138
}
@@ -146,13 +145,18 @@ export function start(entry?: NavigationEntry | string) {
146145
}
147146
}
148147

148+
export function start(entry?: NavigationEntry | string) {
149+
console.log("application.start() is deprecated; use application.run() instead");
150+
_start(entry);
151+
}
152+
149153
export function shouldCreateRootFrame(): boolean {
150154
return createRootFrame.value;
151155
}
152156

153157
export function run(entry?: NavigationEntry | string) {
154158
createRootFrame.value = false;
155-
start(entry);
159+
_start(entry);
156160
}
157161

158162
const CALLBACKS = "_callbacks";

tns-core-modules/application/application.d.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,47 +11,47 @@ import { NavigationEntry, View, Observable, EventData } from "../ui/frame";
1111
/**
1212
* String value used when hooking to launch event.
1313
*/
14-
export var launchEvent: string;
14+
export const launchEvent: string;
1515

1616
/**
1717
* String value used when hooking to displayed event.
1818
*/
19-
export var displayedEvent: string;
19+
export const displayedEvent: string;
2020

2121
/**
2222
* String value used when hooking to uncaughtError event.
2323
*/
24-
export var uncaughtErrorEvent: string;
24+
export const uncaughtErrorEvent: string;
2525

2626
/**
2727
* String value used when hooking to discardedError event.
2828
*/
29-
export var discardedErrorEvent: string;
29+
export const discardedErrorEvent: string;
3030

3131
/**
3232
* String value used when hooking to suspend event.
3333
*/
34-
export var suspendEvent: string;
34+
export const suspendEvent: string;
3535

3636
/**
3737
* String value used when hooking to resume event.
3838
*/
39-
export var resumeEvent: string;
39+
export const resumeEvent: string;
4040

4141
/**
4242
* String value used when hooking to exit event.
4343
*/
44-
export var exitEvent: string;
44+
export const exitEvent: string;
4545

4646
/**
4747
* String value used when hooking to lowMemory event.
4848
*/
49-
export var lowMemoryEvent: string;
49+
export const lowMemoryEvent: string;
5050

5151
/**
5252
* String value used when hooking to orientationChanged event.
5353
*/
54-
export var orientationChangedEvent: string;
54+
export const orientationChangedEvent: string;
5555

5656
/**
5757
* Event data containing information for the application events.

tns-core-modules/application/application.ios.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const getVisibleViewController = ios.getVisibleViewController;
2626
// NOTE: UIResponder with implementation of window - related to https://github.com/NativeScript/ios-runtime/issues/430
2727
// TODO: Refactor the UIResponder to use Typescript extends when this issue is resolved:
2828
// https://github.com/NativeScript/ios-runtime/issues/1012
29-
var Responder = (<any>UIResponder).extend({
29+
const Responder = (<any>UIResponder).extend({
3030
get window() {
3131
return iosApp ? iosApp.window : undefined;
3232
},
@@ -124,7 +124,7 @@ class IOSApplication implements IOSApplicationDefinition {
124124
}
125125

126126
public removeNotificationObserver(observer: any, notificationName: string) {
127-
var index = this._observers.indexOf(observer);
127+
const index = this._observers.indexOf(observer);
128128
if (index >= 0) {
129129
this._observers.splice(index, 1);
130130
NSNotificationCenter.defaultCenter.removeObserverNameObject(observer, notificationName, null);
@@ -275,16 +275,15 @@ function createRootView(v?: View) {
275275
let rootView = v;
276276
if (!rootView) {
277277
// try to navigate to the mainEntry (if specified)
278-
if (mainEntry) {
278+
if (!mainEntry) {
279+
throw new Error("Main entry is missing. App cannot be started. Verify app bootstrap.");
280+
} else {
279281
if (createRootFrame.value) {
280282
const frame = rootView = new Frame();
281283
frame.navigate(mainEntry);
282284
} else {
283285
rootView = createViewFromEntry(mainEntry);
284286
}
285-
} else {
286-
// TODO: Throw an exception?
287-
throw new Error("A Frame must be used to navigate to a Page.");
288287
}
289288
}
290289

@@ -302,9 +301,7 @@ export function getRootView() {
302301
// NOTE: for backwards compatibility. Remove for 4.0.0.
303302
const createRootFrame = { value: true };
304303
let started: boolean = false;
305-
export function start(entry?: string | NavigationEntry) {
306-
console.log("application.start() is deprecated; use application.run() instead");
307-
304+
function _start(entry?: string | NavigationEntry) {
308305
mainEntry = typeof entry === "string" ? { moduleName: entry } : entry;
309306
started = true;
310307

@@ -336,9 +333,14 @@ export function start(entry?: string | NavigationEntry) {
336333
}
337334
}
338335

336+
export function start(entry?: string | NavigationEntry) {
337+
console.log("application.start() is deprecated; use application.run() instead");
338+
_start(entry);
339+
}
340+
339341
export function run(entry?: string | NavigationEntry) {
340342
createRootFrame.value = false;
341-
start(entry);
343+
_start(entry);
342344
}
343345

344346
export function _resetRootView(entry?: NavigationEntry | string) {

tns-core-modules/color/color-common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export class Color implements definition.Color {
8787
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2] + hex[3] + hex[3];
8888
}
8989

90-
var intVal = parseInt(hex, 16);
90+
let intVal = parseInt(hex, 16);
9191
if (hex.length === 6) {
9292
// add the alpha component since the provided string is RRGGBB
9393
intVal = (intVal & 0x00FFFFFF) + 0xFF000000;

0 commit comments

Comments
 (0)