@athletic/capacitor-firebase-realtime 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = 'CapacitorFirebaseRealtime'
7
+ s.version = package['version']
8
+ s.summary = package['description']
9
+ s.license = package['license']
10
+ s.homepage = package['repository']['url']
11
+ s.author = package['author']
12
+ s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
13
+ s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
14
+ s.ios.deployment_target = '13.0'
15
+ s.dependency 'Capacitor'
16
+ s.swift_version = '5.1'
17
+ end
package/README.md ADDED
@@ -0,0 +1,97 @@
1
+ # capacitor-firebase-realtime
2
+
3
+ Capacitor Firebase Realtime plugin
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install capacitor-firebase-realtime
9
+ npx cap sync
10
+ ```
11
+
12
+ ## API
13
+
14
+ <docgen-index>
15
+
16
+ * [`echo(...)`](#echo)
17
+ * [`signOut()`](#signout)
18
+ * [`init(...)`](#init)
19
+ * [`signInWithCustomToken(...)`](#signinwithcustomtoken)
20
+ * [`updateChildren(...)`](#updatechildren)
21
+
22
+ </docgen-index>
23
+
24
+ <docgen-api>
25
+ <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
26
+
27
+ ### echo(...)
28
+
29
+ ```typescript
30
+ echo(options: { value: string; }) => Promise<{ value: string; }>
31
+ ```
32
+
33
+ | Param | Type |
34
+ | ------------- | ------------------------------- |
35
+ | **`options`** | <code>{ value: string; }</code> |
36
+
37
+ **Returns:** <code>Promise&lt;{ value: string; }&gt;</code>
38
+
39
+ --------------------
40
+
41
+
42
+ ### signOut()
43
+
44
+ ```typescript
45
+ signOut() => Promise<null>
46
+ ```
47
+
48
+ **Returns:** <code>Promise&lt;null&gt;</code>
49
+
50
+ --------------------
51
+
52
+
53
+ ### init(...)
54
+
55
+ ```typescript
56
+ init(options: { signedInUserId: number; }) => Promise<{ signedIn: boolean; }>
57
+ ```
58
+
59
+ | Param | Type |
60
+ | ------------- | ---------------------------------------- |
61
+ | **`options`** | <code>{ signedInUserId: number; }</code> |
62
+
63
+ **Returns:** <code>Promise&lt;{ signedIn: boolean; }&gt;</code>
64
+
65
+ --------------------
66
+
67
+
68
+ ### signInWithCustomToken(...)
69
+
70
+ ```typescript
71
+ signInWithCustomToken(options: { token: string; }) => Promise<null>
72
+ ```
73
+
74
+ | Param | Type |
75
+ | ------------- | ------------------------------- |
76
+ | **`options`** | <code>{ token: string; }</code> |
77
+
78
+ **Returns:** <code>Promise&lt;null&gt;</code>
79
+
80
+ --------------------
81
+
82
+
83
+ ### updateChildren(...)
84
+
85
+ ```typescript
86
+ updateChildren(options: { path: string; data: any; }) => Promise<null>
87
+ ```
88
+
89
+ | Param | Type |
90
+ | ------------- | ----------------------------------------- |
91
+ | **`options`** | <code>{ path: string; data: any; }</code> |
92
+
93
+ **Returns:** <code>Promise&lt;null&gt;</code>
94
+
95
+ --------------------
96
+
97
+ </docgen-api>
@@ -0,0 +1,62 @@
1
+ ext {
2
+ junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
3
+ androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.4.2'
4
+ androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.3'
5
+ androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.4.0'
6
+ }
7
+
8
+ buildscript {
9
+ repositories {
10
+ google()
11
+ mavenCentral()
12
+ }
13
+ dependencies {
14
+ classpath 'com.android.tools.build:gradle:7.2.1'
15
+ }
16
+ }
17
+
18
+ apply plugin: 'com.android.library'
19
+
20
+ android {
21
+ compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 32
22
+ defaultConfig {
23
+ minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
24
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 32
25
+ versionCode 1
26
+ versionName "1.0"
27
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
28
+ }
29
+ buildTypes {
30
+ release {
31
+ minifyEnabled false
32
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
33
+ }
34
+ }
35
+ lintOptions {
36
+ abortOnError false
37
+ }
38
+ compileOptions {
39
+ sourceCompatibility JavaVersion.VERSION_11
40
+ targetCompatibility JavaVersion.VERSION_11
41
+ }
42
+ }
43
+
44
+ repositories {
45
+ google()
46
+ mavenCentral()
47
+ }
48
+
49
+
50
+ dependencies {
51
+ implementation platform('com.google.firebase:firebase-bom:30.0.2')
52
+ implementation 'com.google.firebase:firebase-auth'
53
+ implementation 'com.google.firebase:firebase-database'
54
+ implementation 'com.google.code.gson:gson:2.8.6'
55
+
56
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
57
+ implementation project(':capacitor-android')
58
+ implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
59
+ testImplementation "junit:junit:$junitVersion"
60
+ androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
61
+ androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
62
+ }
@@ -0,0 +1,3 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="net.athletic.firebase.realtime">
3
+ </manifest>
@@ -0,0 +1,11 @@
1
+ package net.athletic.firebase.realtime;
2
+
3
+ import android.util.Log;
4
+
5
+ public class CapacitorFirebaseRealtime {
6
+
7
+ public String echo(String value) {
8
+ Log.i("Echo", value);
9
+ return value;
10
+ }
11
+ }
@@ -0,0 +1,231 @@
1
+ package net.athletic.firebase.realtime;
2
+
3
+ import com.getcapacitor.JSObject;
4
+ import com.getcapacitor.Plugin;
5
+ import com.getcapacitor.PluginCall;
6
+ import com.getcapacitor.PluginMethod;
7
+ import com.getcapacitor.annotation.CapacitorPlugin;
8
+
9
+ import java.util.Map;
10
+ import java.util.HashMap;
11
+
12
+ import org.json.JSONObject;
13
+ import org.json.JSONException;
14
+
15
+ import com.google.gson.Gson;
16
+
17
+ import android.util.Log;
18
+
19
+ import androidx.annotation.NonNull;
20
+
21
+ import com.google.android.gms.tasks.OnCompleteListener;
22
+ import com.google.android.gms.tasks.Task;
23
+
24
+ import com.google.firebase.database.FirebaseDatabase;
25
+ import com.google.firebase.database.DatabaseReference;
26
+ import com.google.firebase.database.DatabaseError;
27
+
28
+ import com.google.firebase.auth.FirebaseAuth;
29
+ import com.google.firebase.auth.AuthResult;
30
+ import com.google.firebase.auth.FirebaseUser;
31
+
32
+ /*
33
+ Examples here:
34
+ - https://github.com/hbmartin/cordova-plugin-firebase-realtime-database/blob/master/src/android/FirebaseDatabasePlugin.java
35
+ - https://github.com/firebase/quickstart-android/blob/afa250e1c45ec45f633cfd94878ed3a655d1525e/auth/app/src/main/java/com/google/firebase/quickstart/auth/java/CustomAuthActivity.java#L70-L71
36
+ - https://github.com/capacitor-community/flipper/blob/master/android/src/main/java/com/getcapacitor/community/flipper/Flipper.java
37
+ */
38
+
39
+ @CapacitorPlugin(name = "CapacitorFirebaseRealtime")
40
+ public class CapacitorFirebaseRealtimePlugin extends Plugin {
41
+
42
+ private CapacitorFirebaseRealtime implementation = new CapacitorFirebaseRealtime();
43
+
44
+ @PluginMethod
45
+ public void echo(PluginCall call) {
46
+ String value = call.getString("value");
47
+
48
+ JSObject ret = new JSObject();
49
+ ret.put("value", implementation.echo(value));
50
+ call.resolve(ret);
51
+ }
52
+
53
+ private FirebaseAuth fireAuth;
54
+ private FirebaseDatabase fireDb;
55
+ private FirebaseUser currentUser = null;
56
+
57
+ private static final String TAG = "AnetFirebaseRealtime";
58
+
59
+ @Override
60
+ public void load() {
61
+ super.load();
62
+
63
+ fireAuth = FirebaseAuth.getInstance();
64
+ fireDb = FirebaseDatabase.getInstance();
65
+ currentUser = fireAuth.getCurrentUser();
66
+
67
+ Log.d(TAG, "loaded");
68
+
69
+ fireDb.setPersistenceEnabled(true);
70
+ }
71
+
72
+ @PluginMethod()
73
+ public void init(PluginCall call) {
74
+ JSObject ret = new JSObject();
75
+ int signedInUserId = call.getInt("signedInUserId");
76
+ currentUser = fireAuth.getCurrentUser();
77
+ int fireUserId = currentUser != null ? Integer.parseInt(currentUser.getUid()) : 0;
78
+ boolean fireDBIsSignedIn = fireUserId == signedInUserId;
79
+
80
+ if (fireUserId != signedInUserId && fireUserId > 0) {
81
+ Log.d(TAG, "userId mismatch");
82
+ signOut();
83
+ }
84
+
85
+ Log.d(TAG, "init; signedIn: " + fireDBIsSignedIn);
86
+
87
+ ret.put("signedIn", fireDBIsSignedIn);
88
+ call.resolve(ret);
89
+ }
90
+
91
+ @PluginMethod()
92
+ public void signInWithCustomToken(PluginCall call) {
93
+ String token = call.getString("token");
94
+
95
+ if (currentUser == null) {
96
+ fireAuth.signInWithCustomToken(token)
97
+ .addOnCompleteListener(new OnCompleteListener<AuthResult>() {
98
+ @Override
99
+ public void onComplete(@NonNull Task<AuthResult> task) {
100
+ if (task.isSuccessful()) {
101
+ // Sign in success, update UI with the signed-in user's information
102
+ Log.d(TAG, "signInWithCustomToken:success");
103
+ currentUser = fireAuth.getCurrentUser();
104
+ call.resolve();
105
+ } else {
106
+ // If sign in fails, display a message to the user.
107
+ Log.w(TAG, "signInWithCustomToken:failure", task.getException());
108
+ call.reject("signInWithCustomToken:failure", task.getException());
109
+ }
110
+ }
111
+ });
112
+ }
113
+ }
114
+
115
+ @PluginMethod()
116
+ public void signOut(PluginCall call) {
117
+ Log.d(TAG, "signout triggered");
118
+ signOut();
119
+ call.resolve();
120
+ }
121
+
122
+ private void signOut() {
123
+ fireAuth.signOut();
124
+ currentUser = null;
125
+ Log.d(TAG, "signout");
126
+ }
127
+
128
+ @PluginMethod()
129
+ public void setValue(PluginCall call) {
130
+ String path = call.getString("path");
131
+ JSONObject value = call.getObject("value");
132
+ Log.d(TAG, "userId: " + currentUser.getUid() + ", setValue path: " + path + ", value: " + value.toString());
133
+
134
+ DatabaseReference ref = fireDb.getReference(path);
135
+
136
+ try {
137
+ ref.setValue(jsonObjectToMap(value), getCompletionListener(call));
138
+ } catch (JSONException e) {
139
+ call.reject(e.getMessage());
140
+ }
141
+ }
142
+
143
+ @PluginMethod()
144
+ public void updateChildren(PluginCall call) {
145
+ String path = call.getString("path");
146
+ JSObject data = call.getObject("data");
147
+ Log.d(TAG, "userId: " + currentUser.getUid() + ", updateChildren path: " + path + ", update: " + data.toString());
148
+
149
+ DatabaseReference ref = fireDb.getReference(path);
150
+
151
+ try {
152
+ ref.updateChildren(jsonObjectToMap(data), getCompletionListener(call));
153
+ call.resolve();
154
+ } catch (JSONException e) {
155
+ call.reject(e.getMessage());
156
+ }
157
+ }
158
+
159
+ private DatabaseReference.CompletionListener getCompletionListener(final PluginCall call) {
160
+ return new DatabaseReference.CompletionListener() {
161
+ @Override
162
+ public void onComplete(DatabaseError databaseError, DatabaseReference databaseReference) {
163
+ if (databaseError == null) {
164
+ call.resolve();
165
+ } else {
166
+ call.reject(databaseError.getMessage());
167
+ }
168
+ }
169
+ };
170
+ }
171
+
172
+ private static Map<String, Object> jsonObjectToMap(JSONObject json) throws JSONException {
173
+ Gson gson = new Gson();
174
+ Map<String, Object> map = new HashMap<String, Object>();
175
+ map = (Map<String, Object>) gson.fromJson(json.toString(), map.getClass());
176
+ return map;
177
+ }
178
+
179
+ //
180
+ // @Override
181
+ // protected void handleOnStart() {
182
+ // super.handleOnStart();
183
+ // Log.d(TAG, "handleOnStart");
184
+ // checkCurrentUser();
185
+ // }
186
+ //
187
+ // @Override
188
+ // protected void handleOnRestart() {
189
+ // super.handleOnStart();
190
+ // Log.d(TAG, "handleOnRestart");
191
+ // checkCurrentUser();
192
+ // }
193
+ //
194
+ // @Override
195
+ // protected void handleOnResume() {
196
+ // super.handleOnStart();
197
+ // Log.d(TAG, "handleOnResume");
198
+ // checkCurrentUser();
199
+ // }
200
+ //
201
+ // @Override
202
+ // protected void handleOnPause() {
203
+ // super.handleOnStart();
204
+ // Log.d(TAG, "handleOnPause");
205
+ // checkCurrentUser();
206
+ // }
207
+ //
208
+ // @Override
209
+ // protected void handleOnStop() {
210
+ // super.handleOnStart();
211
+ // Log.d(TAG, "handleOnStop");
212
+ // checkCurrentUser();
213
+ // }
214
+ //
215
+ // @Override
216
+ // protected void handleOnDestroy() {
217
+ // super.handleOnStart();
218
+ // Log.d(TAG, "handleOnDestroy");
219
+ // checkCurrentUser();
220
+ // }
221
+ //
222
+ // private void checkCurrentUser(){
223
+ // if(currentUser != null){
224
+ // Log.d(TAG, "currentUser: " + currentUser.getUid());
225
+ // }
226
+ // else {
227
+ // Log.d(TAG, "currentUser: NULL");
228
+ // }
229
+ // }
230
+
231
+ }
File without changes
package/dist/docs.json ADDED
@@ -0,0 +1,89 @@
1
+ {
2
+ "api": {
3
+ "name": "CapacitorFirebaseRealtimePlugin",
4
+ "slug": "capacitorfirebaserealtimeplugin",
5
+ "docs": "",
6
+ "tags": [],
7
+ "methods": [
8
+ {
9
+ "name": "echo",
10
+ "signature": "(options: { value: string; }) => Promise<{ value: string; }>",
11
+ "parameters": [
12
+ {
13
+ "name": "options",
14
+ "docs": "",
15
+ "type": "{ value: string; }"
16
+ }
17
+ ],
18
+ "returns": "Promise<{ value: string; }>",
19
+ "tags": [],
20
+ "docs": "",
21
+ "complexTypes": [],
22
+ "slug": "echo"
23
+ },
24
+ {
25
+ "name": "signOut",
26
+ "signature": "() => Promise<null>",
27
+ "parameters": [],
28
+ "returns": "Promise<null>",
29
+ "tags": [],
30
+ "docs": "",
31
+ "complexTypes": [],
32
+ "slug": "signout"
33
+ },
34
+ {
35
+ "name": "init",
36
+ "signature": "(options: { signedInUserId: number; }) => Promise<{ signedIn: boolean; }>",
37
+ "parameters": [
38
+ {
39
+ "name": "options",
40
+ "docs": "",
41
+ "type": "{ signedInUserId: number; }"
42
+ }
43
+ ],
44
+ "returns": "Promise<{ signedIn: boolean; }>",
45
+ "tags": [],
46
+ "docs": "",
47
+ "complexTypes": [],
48
+ "slug": "init"
49
+ },
50
+ {
51
+ "name": "signInWithCustomToken",
52
+ "signature": "(options: { token: string; }) => Promise<null>",
53
+ "parameters": [
54
+ {
55
+ "name": "options",
56
+ "docs": "",
57
+ "type": "{ token: string; }"
58
+ }
59
+ ],
60
+ "returns": "Promise<null>",
61
+ "tags": [],
62
+ "docs": "",
63
+ "complexTypes": [],
64
+ "slug": "signinwithcustomtoken"
65
+ },
66
+ {
67
+ "name": "updateChildren",
68
+ "signature": "(options: { path: string; data: any; }) => Promise<null>",
69
+ "parameters": [
70
+ {
71
+ "name": "options",
72
+ "docs": "",
73
+ "type": "{ path: string; data: any; }"
74
+ }
75
+ ],
76
+ "returns": "Promise<null>",
77
+ "tags": [],
78
+ "docs": "",
79
+ "complexTypes": [],
80
+ "slug": "updatechildren"
81
+ }
82
+ ],
83
+ "properties": []
84
+ },
85
+ "interfaces": [],
86
+ "enums": [],
87
+ "typeAliases": [],
88
+ "pluginConfigs": []
89
+ }
@@ -0,0 +1,20 @@
1
+ export interface CapacitorFirebaseRealtimePlugin {
2
+ echo(options: {
3
+ value: string;
4
+ }): Promise<{
5
+ value: string;
6
+ }>;
7
+ signOut(): Promise<null>;
8
+ init(options: {
9
+ signedInUserId: number;
10
+ }): Promise<{
11
+ signedIn: boolean;
12
+ }>;
13
+ signInWithCustomToken(options: {
14
+ token: string;
15
+ }): Promise<null>;
16
+ updateChildren(options: {
17
+ path: string;
18
+ data: any;
19
+ }): Promise<null>;
20
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=definitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export interface CapacitorFirebaseRealtimePlugin {\n echo(options: { value: string }): Promise<{ value: string }>;\n signOut(): Promise<null>;\n init(options: { signedInUserId: number }): Promise<{ signedIn: boolean }>;\n signInWithCustomToken(options: { token: string }): Promise<null>;\n updateChildren(options: { path: string, data: any }): Promise<null>;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { CapacitorFirebaseRealtimePlugin } from './definitions';
2
+ declare const CapacitorFirebaseRealtime: CapacitorFirebaseRealtimePlugin;
3
+ export * from './definitions';
4
+ export { CapacitorFirebaseRealtime };
@@ -0,0 +1,7 @@
1
+ import { registerPlugin } from '@capacitor/core';
2
+ const CapacitorFirebaseRealtime = registerPlugin('CapacitorFirebaseRealtime', {
3
+ web: () => import('./web').then(m => new m.CapacitorFirebaseRealtimeWeb()),
4
+ });
5
+ export * from './definitions';
6
+ export { CapacitorFirebaseRealtime };
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,yBAAyB,GAAG,cAAc,CAAkC,2BAA2B,EAAE;IAC7G,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,4BAA4B,EAAE,CAAC;CAC3E,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,yBAAyB,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { CapacitorFirebaseRealtimePlugin } from './definitions';\n\nconst CapacitorFirebaseRealtime = registerPlugin<CapacitorFirebaseRealtimePlugin>('CapacitorFirebaseRealtime', {\n web: () => import('./web').then(m => new m.CapacitorFirebaseRealtimeWeb()),\n});\n\nexport * from './definitions';\nexport { CapacitorFirebaseRealtime };\n"]}
@@ -0,0 +1,22 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ import type { CapacitorFirebaseRealtimePlugin } from './definitions';
3
+ export declare class CapacitorFirebaseRealtimeWeb extends WebPlugin implements CapacitorFirebaseRealtimePlugin {
4
+ echo(options: {
5
+ value: string;
6
+ }): Promise<{
7
+ value: string;
8
+ }>;
9
+ signOut(): Promise<null>;
10
+ init(options: {
11
+ signedInUserId: number;
12
+ }): Promise<{
13
+ signedIn: boolean;
14
+ }>;
15
+ signInWithCustomToken(options: {
16
+ token: string;
17
+ }): Promise<null>;
18
+ updateChildren(options: {
19
+ path: string;
20
+ data: any;
21
+ }): Promise<null>;
22
+ }
@@ -0,0 +1,22 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ export class CapacitorFirebaseRealtimeWeb extends WebPlugin {
3
+ async echo(options) {
4
+ console.log('ECHO', options);
5
+ return options;
6
+ }
7
+ async signOut() {
8
+ return null;
9
+ }
10
+ async init(options) {
11
+ JSON.stringify(options);
12
+ return { signedIn: false };
13
+ }
14
+ async signInWithCustomToken(options) {
15
+ JSON.stringify(options);
16
+ return null;
17
+ }
18
+ async updateChildren(options) {
19
+ throw ('CapacitorFirebaseRealtimeWeb.updateChildren: Web version has not been implemented ' + JSON.stringify(options));
20
+ }
21
+ }
22
+ //# sourceMappingURL=web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,OAAO,4BAA6B,SAAQ,SAAS;IACzD,KAAK,CAAC,IAAI,CAAC,OAA0B;QACnC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7B,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,KAAK,CAAE,OAAO;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,OAAmC;QAC5C,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACxB,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IAC7B,CAAC;IACD,KAAK,CAAC,qBAAqB,CAAC,OAA0B;QACpD,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,KAAK,CAAC,cAAc,CAAC,OAAoC;QACvD,MAAK,CAAC,oFAAoF,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;IACxH,CAAC;CAEF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { CapacitorFirebaseRealtimePlugin } from './definitions';\n\nexport class CapacitorFirebaseRealtimeWeb extends WebPlugin implements CapacitorFirebaseRealtimePlugin {\n async echo(options: { value: string }): Promise<{ value: string }> {\n console.log('ECHO', options);\n return options;\n }\n\n async signOut(): Promise<null> {\n return null;\n }\n async init(options: { signedInUserId: number }): Promise<{ signedIn: boolean }>{\n JSON.stringify(options);\n return { signedIn: false };\n }\n async signInWithCustomToken(options: { token: string }): Promise<null>{\n JSON.stringify(options);\n return null;\n }\n async updateChildren(options: { path: string, data: any }): Promise<null>{\n throw('CapacitorFirebaseRealtimeWeb.updateChildren: Web version has not been implemented ' + JSON.stringify(options));\n }\n\n}\n"]}
@@ -0,0 +1,38 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var core = require('@capacitor/core');
6
+
7
+ const CapacitorFirebaseRealtime = core.registerPlugin('CapacitorFirebaseRealtime', {
8
+ web: () => Promise.resolve().then(function () { return web; }).then(m => new m.CapacitorFirebaseRealtimeWeb()),
9
+ });
10
+
11
+ class CapacitorFirebaseRealtimeWeb extends core.WebPlugin {
12
+ async echo(options) {
13
+ console.log('ECHO', options);
14
+ return options;
15
+ }
16
+ async signOut() {
17
+ return null;
18
+ }
19
+ async init(options) {
20
+ JSON.stringify(options);
21
+ return { signedIn: false };
22
+ }
23
+ async signInWithCustomToken(options) {
24
+ JSON.stringify(options);
25
+ return null;
26
+ }
27
+ async updateChildren(options) {
28
+ throw ('CapacitorFirebaseRealtimeWeb.updateChildren: Web version has not been implemented ' + JSON.stringify(options));
29
+ }
30
+ }
31
+
32
+ var web = /*#__PURE__*/Object.freeze({
33
+ __proto__: null,
34
+ CapacitorFirebaseRealtimeWeb: CapacitorFirebaseRealtimeWeb
35
+ });
36
+
37
+ exports.CapacitorFirebaseRealtime = CapacitorFirebaseRealtime;
38
+ //# sourceMappingURL=plugin.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\r\nconst CapacitorFirebaseRealtime = registerPlugin('CapacitorFirebaseRealtime', {\r\n web: () => import('./web').then(m => new m.CapacitorFirebaseRealtimeWeb()),\r\n});\r\nexport * from './definitions';\r\nexport { CapacitorFirebaseRealtime };\r\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\r\nexport class CapacitorFirebaseRealtimeWeb extends WebPlugin {\r\n async echo(options) {\r\n console.log('ECHO', options);\r\n return options;\r\n }\r\n async signOut() {\r\n return null;\r\n }\r\n async init(options) {\r\n JSON.stringify(options);\r\n return { signedIn: false };\r\n }\r\n async signInWithCustomToken(options) {\r\n JSON.stringify(options);\r\n return null;\r\n }\r\n async updateChildren(options) {\r\n throw ('CapacitorFirebaseRealtimeWeb.updateChildren: Web version has not been implemented ' + JSON.stringify(options));\r\n }\r\n}\r\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;;;AACK,MAAC,yBAAyB,GAAGA,mBAAc,CAAC,2BAA2B,EAAE;AAC9E,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,4BAA4B,EAAE,CAAC;AAC9E,CAAC;;ACFM,MAAM,4BAA4B,SAASC,cAAS,CAAC;AAC5D,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;AACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACrC,QAAQ,OAAO,OAAO,CAAC;AACvB,KAAK;AACL,IAAI,MAAM,OAAO,GAAG;AACpB,QAAQ,OAAO,IAAI,CAAC;AACpB,KAAK;AACL,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;AACxB,QAAQ,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AAChC,QAAQ,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;AACnC,KAAK;AACL,IAAI,MAAM,qBAAqB,CAAC,OAAO,EAAE;AACzC,QAAQ,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AAChC,QAAQ,OAAO,IAAI,CAAC;AACpB,KAAK;AACL,IAAI,MAAM,cAAc,CAAC,OAAO,EAAE;AAClC,QAAQ,OAAO,oFAAoF,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE;AAC/H,KAAK;AACL;;;;;;;;;"}
package/dist/plugin.js ADDED
@@ -0,0 +1,41 @@
1
+ var capacitorCapacitorFirebaseRealtime = (function (exports, core) {
2
+ 'use strict';
3
+
4
+ const CapacitorFirebaseRealtime = core.registerPlugin('CapacitorFirebaseRealtime', {
5
+ web: () => Promise.resolve().then(function () { return web; }).then(m => new m.CapacitorFirebaseRealtimeWeb()),
6
+ });
7
+
8
+ class CapacitorFirebaseRealtimeWeb extends core.WebPlugin {
9
+ async echo(options) {
10
+ console.log('ECHO', options);
11
+ return options;
12
+ }
13
+ async signOut() {
14
+ return null;
15
+ }
16
+ async init(options) {
17
+ JSON.stringify(options);
18
+ return { signedIn: false };
19
+ }
20
+ async signInWithCustomToken(options) {
21
+ JSON.stringify(options);
22
+ return null;
23
+ }
24
+ async updateChildren(options) {
25
+ throw ('CapacitorFirebaseRealtimeWeb.updateChildren: Web version has not been implemented ' + JSON.stringify(options));
26
+ }
27
+ }
28
+
29
+ var web = /*#__PURE__*/Object.freeze({
30
+ __proto__: null,
31
+ CapacitorFirebaseRealtimeWeb: CapacitorFirebaseRealtimeWeb
32
+ });
33
+
34
+ exports.CapacitorFirebaseRealtime = CapacitorFirebaseRealtime;
35
+
36
+ Object.defineProperty(exports, '__esModule', { value: true });
37
+
38
+ return exports;
39
+
40
+ })({}, capacitorExports);
41
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\r\nconst CapacitorFirebaseRealtime = registerPlugin('CapacitorFirebaseRealtime', {\r\n web: () => import('./web').then(m => new m.CapacitorFirebaseRealtimeWeb()),\r\n});\r\nexport * from './definitions';\r\nexport { CapacitorFirebaseRealtime };\r\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\r\nexport class CapacitorFirebaseRealtimeWeb extends WebPlugin {\r\n async echo(options) {\r\n console.log('ECHO', options);\r\n return options;\r\n }\r\n async signOut() {\r\n return null;\r\n }\r\n async init(options) {\r\n JSON.stringify(options);\r\n return { signedIn: false };\r\n }\r\n async signInWithCustomToken(options) {\r\n JSON.stringify(options);\r\n return null;\r\n }\r\n async updateChildren(options) {\r\n throw ('CapacitorFirebaseRealtimeWeb.updateChildren: Web version has not been implemented ' + JSON.stringify(options));\r\n }\r\n}\r\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,yBAAyB,GAAGA,mBAAc,CAAC,2BAA2B,EAAE;IAC9E,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,4BAA4B,EAAE,CAAC;IAC9E,CAAC;;ICFM,MAAM,4BAA4B,SAASC,cAAS,CAAC;IAC5D,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;IACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,QAAQ,OAAO,OAAO,CAAC;IACvB,KAAK;IACL,IAAI,MAAM,OAAO,GAAG;IACpB,QAAQ,OAAO,IAAI,CAAC;IACpB,KAAK;IACL,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;IACxB,QAAQ,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAChC,QAAQ,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IACnC,KAAK;IACL,IAAI,MAAM,qBAAqB,CAAC,OAAO,EAAE;IACzC,QAAQ,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAChC,QAAQ,OAAO,IAAI,CAAC;IACpB,KAAK;IACL,IAAI,MAAM,cAAc,CAAC,OAAO,EAAE;IAClC,QAAQ,OAAO,oFAAoF,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE;IAC/H,KAAK;IACL;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,8 @@
1
+ import Foundation
2
+
3
+ @objc public class CapacitorFirebaseRealtime: NSObject {
4
+ @objc public func echo(_ value: String) -> String {
5
+ print(value)
6
+ return value
7
+ }
8
+ }
@@ -0,0 +1,10 @@
1
+ #import <UIKit/UIKit.h>
2
+
3
+ //! Project version number for Plugin.
4
+ FOUNDATION_EXPORT double PluginVersionNumber;
5
+
6
+ //! Project version string for Plugin.
7
+ FOUNDATION_EXPORT const unsigned char PluginVersionString[];
8
+
9
+ // In this header, you should import all the public headers of your framework using statements like #import <Plugin/PublicHeader.h>
10
+
@@ -0,0 +1,8 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <Capacitor/Capacitor.h>
3
+
4
+ // Define the plugin using the CAP_PLUGIN Macro, and
5
+ // each method the plugin supports using the CAP_PLUGIN_METHOD macro.
6
+ CAP_PLUGIN(CapacitorFirebaseRealtimePlugin, "CapacitorFirebaseRealtime",
7
+ CAP_PLUGIN_METHOD(echo, CAPPluginReturnPromise);
8
+ )
@@ -0,0 +1,18 @@
1
+ import Foundation
2
+ import Capacitor
3
+
4
+ /**
5
+ * Please read the Capacitor iOS Plugin Development Guide
6
+ * here: https://capacitorjs.com/docs/plugins/ios
7
+ */
8
+ @objc(CapacitorFirebaseRealtimePlugin)
9
+ public class CapacitorFirebaseRealtimePlugin: CAPPlugin {
10
+ private let implementation = CapacitorFirebaseRealtime()
11
+
12
+ @objc func echo(_ call: CAPPluginCall) {
13
+ let value = call.getString("value") ?? ""
14
+ call.resolve([
15
+ "value": implementation.echo(value)
16
+ ])
17
+ }
18
+ }
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CFBundleDevelopmentRegion</key>
6
+ <string>$(DEVELOPMENT_LANGUAGE)</string>
7
+ <key>CFBundleExecutable</key>
8
+ <string>$(EXECUTABLE_NAME)</string>
9
+ <key>CFBundleIdentifier</key>
10
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11
+ <key>CFBundleInfoDictionaryVersion</key>
12
+ <string>6.0</string>
13
+ <key>CFBundleName</key>
14
+ <string>$(PRODUCT_NAME)</string>
15
+ <key>CFBundlePackageType</key>
16
+ <string>FMWK</string>
17
+ <key>CFBundleShortVersionString</key>
18
+ <string>1.0</string>
19
+ <key>CFBundleVersion</key>
20
+ <string>$(CURRENT_PROJECT_VERSION)</string>
21
+ <key>NSPrincipalClass</key>
22
+ <string></string>
23
+ </dict>
24
+ </plist>
package/package.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "@athletic/capacitor-firebase-realtime",
3
+ "version": "0.0.1",
4
+ "description": "Capacitor Firebase Realtime plugin",
5
+ "main": "dist/plugin.cjs.js",
6
+ "module": "dist/esm/index.js",
7
+ "types": "dist/esm/index.d.ts",
8
+ "unpkg": "dist/plugin.js",
9
+ "files": [
10
+ "android/src/main/",
11
+ "android/build.gradle",
12
+ "dist/",
13
+ "ios/Plugin/",
14
+ "CapacitorFirebaseRealtime.podspec"
15
+ ],
16
+ "author": "AthleticNet",
17
+ "license": "MIT",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/AthleticNet/capacitor-firebase-realtime.git"
21
+ },
22
+ "bugs": {
23
+ "url": "https://github.com/AthleticNet/capacitor-firebase-realtime/issues"
24
+ },
25
+ "keywords": [
26
+ "capacitor",
27
+ "plugin",
28
+ "native"
29
+ ],
30
+ "scripts": {
31
+ "verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
32
+ "verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin -destination generic/platform=iOS && cd ..",
33
+ "verify:android": "cd android && ./gradlew clean build test && cd ..",
34
+ "verify:web": "npm run build",
35
+ "lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
36
+ "fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
37
+ "eslint": "eslint . --ext ts",
38
+ "prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
39
+ "swiftlint": "node-swiftlint",
40
+ "docgen": "docgen --api CapacitorFirebaseRealtimePlugin --output-readme README.md --output-json dist/docs.json",
41
+ "build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.js",
42
+ "clean": "rimraf ./dist",
43
+ "watch": "tsc --watch",
44
+ "prepublishOnly": "npm run build"
45
+ },
46
+ "devDependencies": {
47
+ "@capacitor/android": "^4.0.0",
48
+ "@capacitor/core": "^4.0.0",
49
+ "@capacitor/docgen": "^0.0.18",
50
+ "@capacitor/ios": "^4.0.0",
51
+ "@ionic/eslint-config": "^0.3.0",
52
+ "@ionic/prettier-config": "^1.0.1",
53
+ "@ionic/swiftlint-config": "^1.1.2",
54
+ "eslint": "^7.11.0",
55
+ "prettier": "~2.3.0",
56
+ "prettier-plugin-java": "~1.0.2",
57
+ "rimraf": "^3.0.2",
58
+ "rollup": "^2.32.0",
59
+ "swiftlint": "^1.0.1",
60
+ "typescript": "~4.1.5"
61
+ },
62
+ "peerDependencies": {
63
+ "@capacitor/core": "^4.0.0"
64
+ },
65
+ "prettier": "@ionic/prettier-config",
66
+ "swiftlint": "@ionic/swiftlint-config",
67
+ "eslintConfig": {
68
+ "extends": "@ionic/eslint-config/recommended"
69
+ },
70
+ "capacitor": {
71
+ "ios": {
72
+ "src": "ios"
73
+ },
74
+ "android": {
75
+ "src": "android"
76
+ }
77
+ }
78
+ }