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

Commit 6b8209d

Browse files
committed
chore: latest updates
1 parent 5038204 commit 6b8209d

21 files changed

+1555
-1030
lines changed

publish/scripts/installer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var directories = {
1313

1414
console.log('NativeScript Firebase Plugin Installation');
1515

16-
var appRoot = "../../";
16+
var appRoot = "../../../";
1717
var pluginConfigFile = "firebase.nativescript.json";
1818
var pluginConfigPath = path.join(appRoot, pluginConfigFile);
1919
var config = {};

src/.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
*.map
22
*.ts
33
!*.d.ts
4+
ns-transform-native-classes.*
45
tsconfig.json
56
references.d.ts
67
platforms/android/libraryproject/
@@ -11,3 +12,4 @@ platforms/android/typings/
1112
platforms/web
1213
platforms/ios/Podfile
1314
platforms/android/include.gradle
15+
*.tgz

src/admob/admob.ios.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ function _getBannerType(size): any {
343343
}
344344
}
345345

346+
@NativeClass()
346347
class GADInterstitialDelegateImpl extends NSObject implements GADInterstitialDelegate {
347348
public static ObjCProtocols = [];
348349
private options: InterstitialOptions;
@@ -381,6 +382,7 @@ class GADInterstitialDelegateImpl extends NSObject implements GADInterstitialDel
381382
}
382383
}
383384

385+
@NativeClass()
384386
class GADBannerViewDelegateImpl extends NSObject implements GADBannerViewDelegate {
385387
public static ObjCProtocols = [];
386388
private onAdCloseCallback: () => void;
@@ -419,6 +421,7 @@ class GADBannerViewDelegateImpl extends NSObject implements GADBannerViewDelegat
419421
}
420422
}
421423

424+
@NativeClass()
422425
class GADRewardBasedVideoAdDelegateImpl extends NSObject implements GADRewardBasedVideoAdDelegate {
423426
public static ObjCProtocols = [];
424427
_loaded: () => void;

src/app/auth/index.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
import * as firebase from "../../firebase";
2-
import { FirebaseEmailLinkActionCodeSettings, LoginType, User, Unsubscribe } from "../../firebase";
1+
import { firebase } from "../../firebase";
32

43
export namespace auth {
54
export class Auth {
65
private authStateChangedHandler;
76
private authStateOnErrorHandler;
8-
public currentUser: User;
7+
public currentUser: firebase.User;
98
public languageCode: string | null;
109

1110
private loginHelper(options: firebase.LoginOptions) {
1211
return new Promise((resolve, reject) => {
1312
firebase.login(options)
14-
.then((user: User) => {
13+
.then((user: firebase.User) => {
1514
this.currentUser = user;
1615
this.authStateChangedHandler && this.authStateChangedHandler(user);
1716
resolve({
@@ -45,7 +44,7 @@ export namespace auth {
4544

4645
// Completed will never be called, but it is here to closely follow the web api interface.
4746
// When called, the callback handler will be passed in the currentUser or undefined if not signed in
48-
public onAuthStateChanged(handler: (user: User) => void, error?: (err) => any, completed?: Unsubscribe): Unsubscribe {
47+
public onAuthStateChanged(handler: (user: firebase.User) => void, error?: (err) => any, completed?: firebase.Unsubscribe): firebase.Unsubscribe {
4948
this.authStateChangedHandler = handler;
5049
if (error) this.authStateOnErrorHandler = error;
5150
console.log(">> added onAuthStateChanged handler");
@@ -92,7 +91,7 @@ export namespace auth {
9291

9392
public signInWithEmailAndPassword(email: string, password: string): Promise<any> {
9493
const emailOption: firebase.LoginOptions = {
95-
type: LoginType.PASSWORD,
94+
type: firebase.LoginType.PASSWORD,
9695
passwordOptions: {
9796
email: email,
9897
password: password
@@ -103,7 +102,7 @@ export namespace auth {
103102

104103
public signInWithCustomToken(token: string): Promise<any> {
105104
const customTokenOption: firebase.LoginOptions = {
106-
type: LoginType.CUSTOM,
105+
type: firebase.LoginType.CUSTOM,
107106
customOptions: {
108107
token: token
109108
}
@@ -113,14 +112,14 @@ export namespace auth {
113112

114113
public signInAnonymously(): Promise<any> {
115114
const anonymousOption: firebase.LoginOptions = {
116-
type: LoginType.ANONYMOUS
115+
type: firebase.LoginType.ANONYMOUS
117116
};
118117
return this.loginHelper(anonymousOption);
119118
}
120119

121-
public sendSignInLinkToEmail(email: string, actionCodeSettings: FirebaseEmailLinkActionCodeSettings): Promise<any> {
120+
public sendSignInLinkToEmail(email: string, actionCodeSettings: firebase.FirebaseEmailLinkActionCodeSettings): Promise<any> {
122121
const sendSignInLinklOption: firebase.LoginOptions = {
123-
type: LoginType.EMAIL_LINK,
122+
type: firebase.LoginType.EMAIL_LINK,
124123
emailLinkOptions: {
125124
email: email,
126125
url: actionCodeSettings.url,
@@ -140,12 +139,12 @@ export namespace auth {
140139
return this.loginHelper(signInWithEmailOption);
141140
}
142141

143-
public createUserWithEmailAndPassword(email: string, password: string): Promise<User> {
142+
public createUserWithEmailAndPassword(email: string, password: string): Promise<firebase.User> {
144143
return new Promise((resolve, reject) => {
145144
firebase.createUser({
146145
email: email,
147146
password: password
148-
}).then((user: User) => {
147+
}).then((user: firebase.User) => {
149148
this.currentUser = user;
150149
resolve(user);
151150
}).catch(err => reject(err));

src/app/database/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import * as firebase from "../../firebase";
2-
import { AddEventListenerResult, FBData } from "../../firebase";
1+
import { firebase } from "../../firebase";
32
import { nextPushId } from "./util/NextPushId";
43

54
export module database {
@@ -42,7 +41,7 @@ export module database {
4241
};
4342

4443
firebase.addValueEventListener(onValueEvent, this.path).then(
45-
(result: AddEventListenerResult) => {
44+
(result: firebase.AddEventListenerResult) => {
4645
if (!Query.registeredListeners.has(this.path)) {
4746
Query.registeredListeners.set(this.path, []);
4847
}
@@ -85,7 +84,7 @@ export module database {
8584
});
8685
}
8786

88-
private getOnValueEventHandler(): (data: FBData) => void {
87+
private getOnValueEventHandler(): (data: firebase.FBData) => void {
8988
return result => {
9089
const callbacks = Query.registeredCallbacks.get(this.path);
9190
callbacks && callbacks.map(callback => {

src/app/firestore/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as firebase from "../../firebase";
1+
import { firebase } from "../../firebase";
22
// import * as firebaseSdk from 'firebase/app';
33

44
export namespace firestore {

src/app/functions/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as firebase from "../../firebase";
1+
import { firebase } from "../../firebase";
22

33
export namespace functions {
44
// tslint:disable-next-line:class-name

src/app/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Use 'const firebase = require("nativescript-plugin-firebase/app")'
44
*/
55

6-
import * as firebase from "../firebase";
6+
import { firebase } from "../firebase";
77
import { auth as firebaseAuthModule } from "./auth";
88
import { database as firebaseDatabaseModule } from "./database";
99
import { firestore as firebaseFirestoreModule } from "./firestore";

src/firebase-common.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { prompt, ApplicationSettings } from "@nativescript/core";
2-
import { firestore } from "./firebase";
2+
import { firebase as fbNamespace } from "./firebase";
33
import * as admob from "./admob/admob";
44
import * as analytics from "./analytics/analytics";
55
import * as crashlytics from "./crashlytics/crashlytics";
@@ -9,15 +9,15 @@ import * as mlkit from "./mlkit";
99

1010
// note that this implementation is overridden for iOS
1111
export class FieldValue {
12-
constructor(public type: firestore.FieldValueType,
12+
constructor(public type: fbNamespace.firestore.FieldValueType,
1313
public value: any) {
1414
}
1515

1616
static serverTimestamp = () => "SERVER_TIMESTAMP";
1717
static delete = () => "DELETE_FIELD";
1818
static arrayUnion = (...elements: any[]) => new FieldValue("ARRAY_UNION", elements);
1919
static arrayRemove = (...elements: any[]) => new FieldValue("ARRAY_REMOVE", elements);
20-
static increment = (n: number) => new firebase.firestore.FieldValue("INCREMENT", n);
20+
static increment = (n: number) => new fbNamespace.firestore.FieldValue("INCREMENT", n);
2121
}
2222

2323
export class GeoPoint {
@@ -214,18 +214,19 @@ export const firebase: any = {
214214
return result;
215215
}
216216
};
217+
export const firestore = firebase.firestore;
217218

218-
export abstract class DocumentSnapshot implements firestore.DocumentSnapshot {
219-
public data: () => firestore.DocumentData;
219+
export abstract class DocumentSnapshot {
220+
public data: () => firebase.firestore.DocumentData;
220221

221222
constructor(public id: string,
222223
public exists: boolean,
223-
documentData: firestore.DocumentData,
224-
public ref: firestore.DocumentReference) {
224+
documentData: firebase.firestore.DocumentData,
225+
public ref: firebase.firestore.DocumentReference) {
225226
this.data = () => exists ? documentData : undefined;
226227
}
227228
}
228229

229-
export function isDocumentReference(object: any): object is firestore.DocumentReference {
230+
export function isDocumentReference(object: any): object is firebase.firestore.DocumentReference {
230231
return object && object.discriminator === "docRef";
231232
}

0 commit comments

Comments
 (0)