sveltedfire 0.0.3 → 0.0.5
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.
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/sveltedfire/components/SignedIn.svelte +0 -1
- package/dist/sveltedfire/components/SignedOut.svelte +0 -1
- package/dist/sveltedfire/init.js +9 -2
- package/dist/sveltedfire/utilities/fetchDoc.js +1 -0
- package/dist/sveltedfire/utilities/kindlyFetchDoc.d.ts +4 -0
- package/dist/sveltedfire/utilities/kindlyFetchDoc.js +12 -0
- package/dist/sveltedfire/utilities/kindlyFetchDocs.d.ts +10 -0
- package/dist/sveltedfire/utilities/kindlyFetchDocs.js +12 -0
- package/dist/sveltedfire/utilities/listenDoc.js +0 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export { fetchDocs } from './sveltedfire/utilities/fetchDocs.js';
|
|
|
4
4
|
export { signInWithGoogle } from './sveltedfire/auth/signInWithGoogle.js';
|
|
5
5
|
export { signOut } from './sveltedfire/auth/signOut.js';
|
|
6
6
|
export { listenDoc } from './sveltedfire/utilities/listenDoc.js';
|
|
7
|
+
export { kindlyFetchDoc } from './sveltedfire/utilities/kindlyFetchDoc.js';
|
|
8
|
+
export { kindlyFetchDocs } from './sveltedfire/utilities/kindlyFetchDocs.js';
|
|
7
9
|
import SignedIn from './sveltedfire/components/SignedIn.svelte';
|
|
8
10
|
import SignedOut from './sveltedfire/components/SignedOut.svelte';
|
|
9
11
|
export { SignedIn, SignedOut };
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,8 @@ export { fetchDocs } from './sveltedfire/utilities/fetchDocs.js';
|
|
|
5
5
|
export { signInWithGoogle } from './sveltedfire/auth/signInWithGoogle.js';
|
|
6
6
|
export { signOut } from './sveltedfire/auth/signOut.js';
|
|
7
7
|
export { listenDoc } from './sveltedfire/utilities/listenDoc.js';
|
|
8
|
+
export { kindlyFetchDoc } from './sveltedfire/utilities/kindlyFetchDoc.js';
|
|
9
|
+
export { kindlyFetchDocs } from './sveltedfire/utilities/kindlyFetchDocs.js';
|
|
8
10
|
import SignedIn from './sveltedfire/components/SignedIn.svelte';
|
|
9
11
|
import SignedOut from './sveltedfire/components/SignedOut.svelte';
|
|
10
12
|
export { SignedIn, SignedOut };
|
package/dist/sveltedfire/init.js
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { initializeApp } from "firebase/app";
|
|
2
|
+
import { getAuth } from 'firebase/auth';
|
|
3
|
+
import { setLogLevel } from "firebase/firestore";
|
|
2
4
|
export const initFirebase = async (firebaseConfig) => {
|
|
3
5
|
await new Promise((res, rej) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
// setLogLevel('debug')
|
|
7
|
+
const app = initializeApp(firebaseConfig);
|
|
8
|
+
const auth = getAuth(app);
|
|
9
|
+
const unsubscribe = auth.onAuthStateChanged(_ => {
|
|
10
|
+
unsubscribe();
|
|
11
|
+
res(null);
|
|
12
|
+
});
|
|
6
13
|
});
|
|
7
14
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FirebaseError } from "firebase/app";
|
|
2
|
+
import { fetchDoc } from "./fetchDoc.js";
|
|
3
|
+
export const kindlyFetchDoc = async (...args) => {
|
|
4
|
+
return await fetchDoc(...args).then(result => {
|
|
5
|
+
return result;
|
|
6
|
+
}).catch(err => {
|
|
7
|
+
if ((err instanceof FirebaseError) && (err.code == 'permission-denied')) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
throw err;
|
|
11
|
+
});
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FirebaseError } from "firebase/app";
|
|
2
|
+
import { fetchDocs } from "./fetchDocs.js";
|
|
3
|
+
export const kindlyFetchDocs = (...initialArgs) => async (...args) => {
|
|
4
|
+
return await fetchDocs(...initialArgs)(...args).then(result => {
|
|
5
|
+
return result;
|
|
6
|
+
}).catch(err => {
|
|
7
|
+
if ((err instanceof FirebaseError) && (err.code == 'permission-denied')) {
|
|
8
|
+
return { docs: [], count: 0 };
|
|
9
|
+
}
|
|
10
|
+
throw err;
|
|
11
|
+
});
|
|
12
|
+
};
|
|
@@ -9,7 +9,6 @@ export const listenDoc = (...docPath) => {
|
|
|
9
9
|
else {
|
|
10
10
|
theRef = doc(collection(db, docPath[0]), docPath.slice(-1)[0]);
|
|
11
11
|
}
|
|
12
|
-
console.log(theRef);
|
|
13
12
|
const theDoc = readable(null, (set) => {
|
|
14
13
|
const unsubscribe = onSnapshot(theRef, (val) => {
|
|
15
14
|
if (!val.exists()) {
|