Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 63edad7

Browse files
Merge pull request #1640 from nstudio/feat/dep-updates
feat(nativescript): v7 updates and compatibility to target es2017+
2 parents 3da75a6 + faaaa7a commit 63edad7

Some content is hidden

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

68 files changed

+1526
-1153
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ package-lock.json
55
*.js
66
!src/*-hooks.js
77
build/
8+
*.tgz
89
*.log.*
910
src/**/*.d.ts
11+
src/**/*.map
1012
src/platforms/ios_lib/TNSMLKitCamera/TNSMLKitCamera.xcodeproj/project.xcworkspace
1113
src/platforms/ios_lib/TNSMLKitCamera/TNSMLKitCamera.xcodeproj/xcuserdata
1214
src/platforms/ios/Podfile

demo/app/app.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
import "./bundle-config";
2-
import * as application from "tns-core-modules/application";
3-
import { UnhandledErrorEventData } from "tns-core-modules/application";
1+
import { Application, UnhandledErrorEventData } from "@nativescript/core";
42

53
// added this here so we can do some wiring
6-
require("nativescript-plugin-firebase");
4+
require("@nativescript/firebase");
75

86
// testing this.. we may be able to hook that up to Crashlytics. Either via docs, or automatically.
9-
application.on(application.uncaughtErrorEvent, (args: UnhandledErrorEventData) => {
7+
Application.on(Application.uncaughtErrorEvent, (args: UnhandledErrorEventData) => {
108
console.log("[app.js]: Uncaught NativeScript Error: " + args.error);
119
});
1210

13-
application.run({ moduleName: "main-page" });
11+
Application.run({ moduleName: "main-page" });

demo/app/bundle-config.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

demo/app/main-page.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import * as observable from "tns-core-modules/data/observable";
2-
import * as pages from "tns-core-modules/ui/page";
1+
import { EventData, Page } from "@nativescript/core";
32
import { HelloWorldModel } from "./main-view-model";
43

54
const model = new HelloWorldModel();
65

76
// Event handler for Page 'loaded' event attached in main-page.xml
8-
export function pageLoaded(args: observable.EventData) {
7+
export function pageLoaded(args: EventData) {
98
// Get the event sender
10-
let page = <pages.Page>args.object;
9+
let page = <Page>args.object;
1110
page.bindingContext = model;
1211
}

demo/app/main-view-model.ts

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
import * as firebase from "nativescript-plugin-firebase";
2-
import { AddEventListenerResult, admob as firebaseAdMob, crashlytics as firebaseCrashlytics, GetRemoteConfigResult, IdTokenResult, LogComplexEventTypeParameter, performance as firebasePerformance, storage as firebaseStorage, User } from "nativescript-plugin-firebase";
3-
import { RewardedVideoAdReward } from "nativescript-plugin-firebase/admob/admob";
4-
import { FirebaseTrace } from "nativescript-plugin-firebase/performance/performance";
5-
import { Observable } from "tns-core-modules/data/observable";
6-
import * as fs from "tns-core-modules/file-system";
7-
import { isAndroid, isIOS } from "tns-core-modules/platform";
8-
import { alert, prompt } from "tns-core-modules/ui/dialogs";
1+
import { firebase, AddEventListenerResult, admob as firebaseAdMob, crashlytics as firebaseCrashlytics, GetRemoteConfigResult, IdTokenResult, LogComplexEventTypeParameter, performance as firebasePerformance, storage as firebaseStorage, User } from "@nativescript/firebase";
2+
import { RewardedVideoAdReward } from "@nativescript/firebase/admob/admob";
3+
import { FirebaseTrace } from "@nativescript/firebase/performance/performance";
4+
import { Observable, isAndroid, isIOS, Dialogs, knownFolders, File } from "@nativescript/core";
95
import { UploadMetadata } from "../../src/storage/storage";
106
import { MessagingViewModel } from "./messaging-view-model";
117

12-
const firebaseWebApi = require("nativescript-plugin-firebase/app");
8+
const firebaseWebApi = require("@nativescript/firebase/app");
139

1410
declare const Crashlytics: any;
1511

@@ -309,7 +305,7 @@ export class HelloWorldModel extends Observable {
309305

310306
public doWebUploadFile(): void {
311307
// let's first create a File object using the tns file module
312-
const appPath = fs.knownFolders.currentApp().path;
308+
const appPath = knownFolders.currentApp().path;
313309
const logoPath = appPath + "/images/telerik-logo.png";
314310

315311
const storageRef = firebaseWebApi.storage().ref();
@@ -324,7 +320,7 @@ export class HelloWorldModel extends Observable {
324320
}
325321
};
326322

327-
childRef.put(fs.File.fromPath(logoPath), metadata).then(
323+
childRef.put(File.fromPath(logoPath), metadata).then(
328324
uploadedFile => {
329325
console.log("Uploaded! " + JSON.stringify(uploadedFile));
330326
this.set("storageFeedback", "Uploaded!");
@@ -341,7 +337,7 @@ export class HelloWorldModel extends Observable {
341337
const childRef = storageRef.child("uploads/images/telerik-logo-uploaded.png");
342338

343339
// let's first determine where we'll create the file using the 'file-system' module
344-
const documents = fs.knownFolders.documents();
340+
const documents = knownFolders.documents();
345341
const logoPath = documents.path + "/telerik-logo-downloaded.png";
346342

347343
childRef.download(logoPath)
@@ -1666,7 +1662,7 @@ export class HelloWorldModel extends Observable {
16661662

16671663
public doUploadFile(): void {
16681664
// let's first create a File object using the tns file module
1669-
const appPath = fs.knownFolders.currentApp().path;
1665+
const appPath = knownFolders.currentApp().path;
16701666
const logoPath = appPath + "/images/telerik-logo.png";
16711667

16721668
const metadata: UploadMetadata = {
@@ -1680,7 +1676,7 @@ export class HelloWorldModel extends Observable {
16801676

16811677
firebaseStorage.uploadFile({
16821678
remoteFullPath: 'uploads/images/telerik-logo-uploaded.png',
1683-
localFile: fs.File.fromPath(logoPath), // use this (a file-system module File object)
1679+
localFile: File.fromPath(logoPath), // use this (a file-system module File object)
16841680
// localFullPath: logoPath, // or this, a full file path
16851681
onProgress: status => {
16861682
console.log("Uploaded fraction: " + status.fractionCompleted + " (" + status.percentageCompleted + "%)");
@@ -1702,7 +1698,7 @@ export class HelloWorldModel extends Observable {
17021698

17031699
public doDownloadFile(): void {
17041700
// let's first determine where we'll create the file using the 'file-system' module
1705-
const documents = fs.knownFolders.documents();
1701+
const documents = knownFolders.documents();
17061702
const logoPath = documents.path + "/telerik-logo-downloaded.png";
17071703

17081704
// this will create or overwrite a local file in the app's documents folder

demo/app/messaging-view-model.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { alert } from "tns-core-modules/ui/dialogs";
2-
import * as platform from "tns-core-modules/platform";
3-
import * as firebase from "nativescript-plugin-firebase";
4-
import { messaging } from "nativescript-plugin-firebase/messaging";
1+
import { Dialogs } from "@nativescript/core";
2+
import { firebase } from "@nativescript/firebase";
3+
import { messaging } from "@nativescript/firebase/messaging";
54

65
const getCircularReplacer = () => {
76
const seen = new WeakSet;
@@ -21,7 +20,7 @@ export class MessagingViewModel {
2120
firebase.getCurrentPushToken().then(token => {
2221
// may be null if not known yet
2322
console.log("Current push token: " + token);
24-
alert({
23+
Dialogs.alert({
2524
title: "Current Push Token",
2625
message: (token === null ? "Not received yet" : token + ("\n\nSee the console log if you want to copy-paste it.")),
2726
okButtonText: "OK, thx"
@@ -30,7 +29,7 @@ export class MessagingViewModel {
3029
}
3130

3231
public doRegisterForInteractivePush(): void {
33-
if (platform.isIOS) {
32+
if (global.isIOS) {
3433
const model = new messaging.PushNotificationModel();
3534
model.iosSettings = new messaging.IosPushSettings();
3635
model.iosSettings.badge = false;

demo/app/package.json

Lines changed: 0 additions & 110 deletions
This file was deleted.

demo/app/tests/tests.native-api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const firebase = require("nativescript-plugin-firebase");
1+
const firebase = require("@nativescript/firebase");
22

33
// TODO make this slightly more useful :P
44

demo/app/tests/tests.web-api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const firebaseWebApi = require("nativescript-plugin-firebase/app");
1+
const firebaseWebApi = require("@nativescript/firebase/app");
22

33
// TODO make this slightly more useful :P
44

demo/nativescript.config.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { NativeScriptConfig } from '@nativescript/core'
2+
3+
export default {
4+
id: 'org.nativescript.firebasedemo',
5+
appResourcesPath: 'app_resources',
6+
android: {
7+
v8Flags: '--expose_gc',
8+
markingMode: 'none',
9+
},
10+
discardUncaughtJsExceptions: false,
11+
appPath: 'app',
12+
} as NativeScriptConfig

0 commit comments

Comments
 (0)