Skip to content

Commit 0cba0f9

Browse files
cpetrovChristian Petrov
authored andcommitted
Update and bundle type definitions
Analogically to tabris-plugin-barcode-scanner, bundle the type definitions in the plugin. Migrate and update "@types/tabris-plugin-firebase" to include the newly introduced "requestPermissions()" method. Removal of the "@types/tabris-plugin-firebase" package to be requested [1] after the new plugin version has been released. [1]: https://github.com/DefinitelyTyped/DefinitelyTyped#removing-a-package Change-Id: I017cbc00e5aa8937e946a677701f79e879933759
1 parent 8e1b9bd commit 0cba0f9

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
"name": "tabris-plugin-firebase",
33
"version": "2.0.0",
44
"description": "A firebase plugin for Tabris.js",
5+
"types": "./types/index.d.ts",
6+
"peerDependencies": {
7+
"tabris": "~2.5.1"
8+
},
59
"cordova": {
610
"id": "tabris-plugin-firebase",
711
"platforms": [

types/index.d.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { EventObject, Widget, WidgetEvents, WidgetProperties, NativeObject, PropertyChangedEvent } from 'tabris';
2+
3+
declare global {
4+
namespace firebase {
5+
const Analytics: Analytics;
6+
const Messaging: Messaging;
7+
const MessagingEvents: MessagingEvents;
8+
const MessageEvent: MessageEvent;
9+
type AnalyticsProperties = Partial<PropertyMixins.Analytics>;
10+
11+
interface Analytics extends NativeObject, PropertyMixins.Analytics {
12+
logEvent(eventName: string, parameters?: { [key: string]: string }): void;
13+
setUserProperty(propertyName: string, value: string): void;
14+
set(properties: AnalyticsProperties): this;
15+
set(property: string, value: any): this;
16+
}
17+
18+
interface Messaging extends NativeObject {
19+
readonly instanceId: string;
20+
readonly token: string;
21+
readonly launchData: object;
22+
resetInstanceId(): void;
23+
requestPermissions(): void;
24+
on(type: string, listener: (event: any) => void, context?: object): this;
25+
on(listeners: MessagingEvents): this;
26+
off(type: string, listener: (event: any) => void, context?: object): this;
27+
off(listeners: MessagingEvents): this;
28+
once(type: string, listener: (event: any) => void, context?: object): this;
29+
once(listeners: MessagingEvents): this;
30+
}
31+
32+
interface MessagingEvents {
33+
instanceIdChanged?(event: PropertyChangedEvent<Messaging, string>): void;
34+
tokenChanged?(event: PropertyChangedEvent<Messaging, string>): void;
35+
message?(event: MessageEvent): void;
36+
}
37+
38+
interface MessageEvent extends EventObject<Messaging> {
39+
data: any;
40+
}
41+
42+
namespace PropertyMixins {
43+
interface Analytics {
44+
analyticsCollectionEnabled: boolean;
45+
screenName: string;
46+
userId: string;
47+
}
48+
}
49+
}
50+
}
51+
52+
export {};

0 commit comments

Comments
 (0)