├── .gitbook
└── assets
│ ├── react-firebase-tutorial-auth-2-gif.gif
│ ├── react-firebase-tutorial-auth-3-loading-gif.gif
│ ├── react-firebase-tutorial-auth-4-error-handling-gif.gif
│ ├── react-firebase-tutorial-fig (1).gif
│ ├── react-firebase-tutorial-fig.gif
│ ├── screen-shot-2018-08-20-at-2.04.01-pm.png
│ ├── screen-shot-2018-08-20-at-2.22.20-pm.png
│ ├── screen-shot-2018-08-20-at-4.45.59-pm.png
│ └── screen-shot-2018-08-21-at-11.48.50-am.png
├── .gitignore
├── .opensource
└── project.json
├── .vscode
└── last.sql
├── README.md
├── modules
├── auth
│ ├── .gitignore
│ ├── README.md
│ ├── __tests__
│ │ └── index.test.tsx
│ ├── package.json
│ ├── rollup.config.js
│ ├── src
│ │ ├── demo
│ │ │ ├── app.tsx
│ │ │ ├── index.html
│ │ │ └── index.js
│ │ ├── index.tsx
│ │ ├── initialize-firebase-app.ts
│ │ └── types.ts
│ ├── tsconfig.json
│ └── yarn.lock
├── database
│ ├── .gitignore
│ ├── README.md
│ ├── __tests__
│ │ ├── FirebaseDatabaseMutation.test.tsx
│ │ ├── FirebaseDatabaseNode.test.tsx
│ │ ├── FirebaseDatabaseTranasaction.test.tsx
│ │ └── reducers.test.ts
│ ├── cypress.json
│ ├── cypress
│ │ ├── fixtures
│ │ │ └── example.json
│ │ ├── integration
│ │ │ └── database.test.js
│ │ ├── plugins
│ │ │ └── index.js
│ │ └── support
│ │ │ ├── commands.js
│ │ │ └── index.js
│ ├── doczrc.js
│ ├── package.json
│ ├── rollup.config.js
│ ├── src
│ │ ├── Context.ts
│ │ ├── components
│ │ │ ├── FirebaseDatabaseMutation.tsx
│ │ │ ├── FirebaseDatabaseNode.tsx
│ │ │ ├── FirebaseDatabaseNodeLifeCycle.tsx
│ │ │ ├── FirebaseDatabaseNodes.tsx
│ │ │ ├── FirebaseDatabaseProvider.tsx
│ │ │ └── FirebaseDatabaseTransaction.tsx
│ │ ├── demo
│ │ │ ├── app.tsx
│ │ │ ├── index.html
│ │ │ ├── index.tsx
│ │ │ └── mui.min.css
│ │ ├── docs
│ │ │ ├── FirebaseDatabaseNode.mdx
│ │ │ └── index.tsx
│ │ ├── get-firebase-query.ts
│ │ ├── index.tsx
│ │ ├── initialize-firebase-app.ts
│ │ ├── reducers.ts
│ │ ├── test-cases
│ │ │ ├── MutationExamplePush.tsx
│ │ │ ├── MutationExampleUpdate.tsx
│ │ │ ├── NodeExampleBasic.tsx
│ │ │ └── TransactionExampleBasic.tsx
│ │ ├── test-utils.ts
│ │ ├── types.ts
│ │ └── utils.ts
│ ├── tsconfig.json
│ └── yarn.lock
├── firestore
│ ├── .gitignore
│ ├── README.md
│ ├── __tests__
│ │ ├── components
│ │ │ ├── FirestoreBatchedWrite.test.tsx
│ │ │ ├── FirestoreCollection.test.tsx
│ │ │ ├── FirestoreDocument.test.tsx
│ │ │ └── FirestoreTransaction.test.tsx
│ │ └── e2e
│ │ │ └── App.test.tsx
│ ├── package.json
│ ├── rollup.config.js
│ ├── src
│ │ ├── Context.ts
│ │ ├── components
│ │ │ ├── FirestoreBatchedWrite.tsx
│ │ │ ├── FirestoreCollection.tsx
│ │ │ ├── FirestoreCollectionContextConsumerWithLifecycle.tsx
│ │ │ ├── FirestoreDocument.tsx
│ │ │ ├── FirestoreDocumentContextConsumerWithLifecycle.tsx
│ │ │ ├── FirestoreMutation.tsx
│ │ │ ├── FirestoreProvider.tsx
│ │ │ └── FirestoreTransaction.tsx
│ │ ├── demo
│ │ │ ├── AddToCollection.tsx
│ │ │ ├── App.tsx
│ │ │ ├── BatchedWrite.tsx
│ │ │ ├── DeleteDocument.tsx
│ │ │ ├── RenderInfiniteList.tsx
│ │ │ ├── SetDocument.tsx
│ │ │ ├── UpdateDocument.tsx
│ │ │ ├── firestore-schema.js
│ │ │ ├── index.html
│ │ │ ├── index.tsx
│ │ │ └── test-credentials.ts
│ │ ├── get-firestore-query.ts
│ │ ├── index.tsx
│ │ ├── initialize-firebase-app.ts
│ │ ├── state-reducer.ts
│ │ ├── test-utils.ts
│ │ └── types.ts
│ ├── tsconfig.json
│ └── yarn.lock
├── generate-firebase-data
│ ├── .gitignore
│ ├── README.md
│ ├── example-schemas
│ │ └── schema-one.js
│ ├── package.json
│ ├── rollup.config.js
│ ├── src
│ │ ├── cli.ts
│ │ ├── index.ts
│ │ └── test.ts
│ ├── tsconfig.json
│ └── yarn.lock
├── generate-firestore-data
│ ├── .gitignore
│ ├── README.md
│ ├── example-schemas
│ │ └── schema-one.js
│ ├── package.json
│ ├── rollup.config.js
│ ├── src
│ │ ├── cli.ts
│ │ ├── index.ts
│ │ └── test.ts
│ ├── tsconfig.json
│ └── yarn.lock
├── generate-json
│ ├── .gitignore
│ ├── README.md
│ ├── __tests__
│ │ ├── __snapshots__
│ │ │ ├── generate-data.test.ts.snap
│ │ │ └── generate-json.test.ts.snap
│ │ ├── generate-data.test.ts
│ │ └── generate-json.test.ts
│ ├── example-schemas-output
│ │ ├── keys.json
│ │ ├── tree.json
│ │ └── values.json
│ ├── example-schemas
│ │ └── schema-one.js
│ ├── package.json
│ ├── rollup.config.js
│ ├── src
│ │ ├── cli.ts
│ │ ├── index.ts
│ │ └── utils.ts
│ ├── tsconfig.json
│ └── yarn.lock
├── hooks
│ ├── .gitignore
│ ├── README.md
│ ├── package.json
│ ├── rollup.config.js
│ ├── src
│ │ ├── index.tsx
│ │ └── types.ts
│ ├── tsconfig.json
│ └── yarn.lock
├── react-firebase-docs
│ ├── .gitignore
│ ├── docs
│ │ ├── README.md
│ │ ├── SUMMARY.md
│ │ ├── assets
│ │ │ ├── data-shape-in-firebase.png
│ │ │ ├── react-firebase-tutorial-auth-2-gif.gif
│ │ │ ├── react-firebase-tutorial-auth-3-loading-gif.gif
│ │ │ ├── react-firebase-tutorial-auth-4-error-handling-gif.gif
│ │ │ ├── react-firebase-tutorial-dumb-ui-gif.gif
│ │ │ ├── react-firebase-tutorial-fig.gif
│ │ │ ├── react-firebase-tutorial-result-gif.gif
│ │ │ ├── user-input-ui.png
│ │ │ ├── wireframe-authed-2.png
│ │ │ ├── wireframe-authed.png
│ │ │ ├── wireframe-unauthed-2.png
│ │ │ ├── wireframe-unauthed-breakdown.png
│ │ │ └── wireframe-unauthed.png
│ │ ├── generate-firebase-data.md
│ │ ├── generate-firestore-data.md
│ │ ├── generate-json-data.md
│ │ ├── generate-json-data
│ │ │ ├── README.md
│ │ │ ├── setup.md
│ │ │ └── usage.md
│ │ ├── guides
│ │ │ ├── README.md
│ │ │ └── build-a-react-app-with-firebase-auth-and-realtime-database
│ │ │ │ ├── README.md
│ │ │ │ ├── add-firebase.md
│ │ │ │ ├── add-google-and-anonymous-auth.md
│ │ │ │ ├── add-react-and-react-dom.md
│ │ │ │ ├── implementing-the-ui.md
│ │ │ │ ├── listen-to-auth.md
│ │ │ │ ├── read-data.md
│ │ │ │ ├── setup-the-development-environment.md
│ │ │ │ └── write-data.md
│ │ ├── react-firebase-auth
│ │ │ ├── api.md
│ │ │ └── getting-started.md
│ │ ├── react-firebase-realtime-database
│ │ │ ├── api.md
│ │ │ └── getting-started.md
│ │ ├── react-firestore-database
│ │ │ ├── api.md
│ │ │ └── getting-started.md
│ │ ├── try-it-out.md
│ │ └── view-source.md
│ ├── now.json
│ ├── package.json
│ └── website
│ │ ├── blog
│ │ └── 2018-08-23-introducing-react-firebase.md
│ │ ├── core
│ │ └── Footer.js
│ │ ├── package.json
│ │ ├── pages
│ │ └── en
│ │ │ ├── help.js
│ │ │ ├── index.js
│ │ │ └── users.js
│ │ ├── sidebars.json
│ │ ├── siteConfig.js
│ │ └── static
│ │ ├── css
│ │ └── custom.css
│ │ └── img
│ │ ├── docusaurus.svg
│ │ ├── favicon.png
│ │ ├── favicon
│ │ └── favicon.ico
│ │ ├── logo.png
│ │ ├── logo.svg
│ │ └── oss_logo.png
├── sandboxes
│ ├── firebase-auth
│ │ ├── .gitignore
│ │ ├── config.ts
│ │ ├── index.html
│ │ ├── package.json
│ │ ├── src
│ │ │ └── index.tsx
│ │ ├── tsconfig.json
│ │ └── yarn.lock
│ ├── firebase-database-flatlist-infinite-list
│ │ ├── config.js
│ │ ├── index.html
│ │ ├── package.json
│ │ ├── src
│ │ │ └── index.js
│ │ └── yarn.lock
│ ├── firebase-database-infinite-list
│ │ ├── .gitignore
│ │ ├── config.ts
│ │ ├── index.html
│ │ ├── package.json
│ │ ├── src
│ │ │ └── index.tsx
│ │ ├── tsconfig.json
│ │ └── yarn.lock
│ ├── firebase-database-mutation
│ │ ├── .gitignore
│ │ ├── config.ts
│ │ ├── index.html
│ │ ├── package.json
│ │ ├── src
│ │ │ └── index.tsx
│ │ ├── tsconfig.json
│ │ └── yarn.lock
│ ├── firebase-database-transaction
│ │ ├── .gitignore
│ │ ├── config.ts
│ │ ├── index.html
│ │ ├── package.json
│ │ ├── src
│ │ │ └── index.tsx
│ │ ├── tsconfig.json
│ │ └── yarn.lock
│ ├── firestore-add-to-collection
│ │ ├── .gitignore
│ │ ├── config.ts
│ │ ├── index.html
│ │ ├── package.json
│ │ ├── src
│ │ │ └── index.tsx
│ │ ├── tsconfig.json
│ │ └── yarn.lock
│ ├── firestore-batched-write
│ │ ├── .gitignore
│ │ ├── config.ts
│ │ ├── index.html
│ │ ├── package.json
│ │ ├── src
│ │ │ └── index.tsx
│ │ ├── tsconfig.json
│ │ └── yarn.lock
│ ├── firestore-collection-example
│ │ ├── .gitignore
│ │ ├── config.ts
│ │ ├── index.html
│ │ ├── package.json
│ │ ├── src
│ │ │ └── index.tsx
│ │ ├── tsconfig.json
│ │ └── yarn.lock
│ ├── firestore-infinite-list
│ │ ├── .gitignore
│ │ ├── config.ts
│ │ ├── index.html
│ │ ├── package.json
│ │ ├── src
│ │ │ └── index.tsx
│ │ ├── tsconfig.json
│ │ └── yarn.lock
│ ├── firestore-mutation-example
│ │ ├── .gitignore
│ │ ├── config.ts
│ │ ├── index.html
│ │ ├── package.json
│ │ ├── src
│ │ │ └── index.tsx
│ │ ├── tsconfig.json
│ │ └── yarn.lock
│ └── firestore-transaction
│ │ ├── .gitignore
│ │ ├── config.ts
│ │ ├── index.html
│ │ ├── package.json
│ │ ├── src
│ │ └── index.tsx
│ │ ├── tsconfig.json
│ │ └── yarn.lock
└── tutorial-bookmarking-app
│ ├── .gitignore
│ ├── package.json
│ ├── src
│ ├── AutoComplete.tsx
│ ├── index.html
│ ├── index.tsx
│ └── test-credentials.ts
│ ├── tsconfig.json
│ └── yarn.lock
├── package.json
├── react-firebase.code-workspace
├── react-native-examples
├── react-native-expo-firebase-example
│ ├── .babelrc
│ ├── .gitignore
│ ├── .watchmanconfig
│ ├── App.js
│ ├── App.test.js
│ ├── README.md
│ ├── app.json
│ ├── package.json
│ ├── test-credentials.js
│ └── yarn.lock
└── react-native-firebase-starter
│ ├── .babelrc
│ ├── .buckconfig
│ ├── .editorconfig
│ ├── .flowconfig
│ ├── .gitattributes
│ ├── .gitignore
│ ├── .opensource
│ └── project.json
│ ├── .watchmanconfig
│ ├── App.js
│ ├── App.test.js
│ ├── LICENSE
│ ├── README.md
│ ├── android
│ ├── .editorconfig
│ ├── app
│ │ ├── BUCK
│ │ ├── build.gradle
│ │ ├── proguard-rules.pro
│ │ └── src
│ │ │ └── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java
│ │ │ └── com
│ │ │ │ └── reactfirebase
│ │ │ │ └── reactfirebaseexample
│ │ │ │ ├── MainActivity.java
│ │ │ │ └── MainApplication.java
│ │ │ └── res
│ │ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ └── ic_launcher.png
│ │ │ └── values
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ ├── gradlew
│ ├── gradlew.bat
│ ├── keystores
│ │ ├── BUCK
│ │ └── debug.keystore.properties
│ └── settings.gradle
│ ├── app.json
│ ├── assets
│ └── RNFirebase.png
│ ├── bin
│ └── rename.js
│ ├── index.js
│ ├── ios
│ ├── GoogleService-Info.plist
│ ├── Podfile
│ ├── Podfile.lock
│ ├── reactfirebaseexample-tvOS
│ │ └── Info.plist
│ ├── reactfirebaseexample-tvOSTests
│ │ └── Info.plist
│ ├── reactfirebaseexample.xcodeproj
│ │ ├── project.pbxproj
│ │ └── xcshareddata
│ │ │ └── xcschemes
│ │ │ ├── reactfirebaseexample-tvOS.xcscheme
│ │ │ └── reactfirebaseexample.xcscheme
│ ├── reactfirebaseexample.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ ├── reactfirebaseexample
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── Base.lproj
│ │ │ └── LaunchScreen.xib
│ │ ├── Images.xcassets
│ │ │ └── AppIcon.appiconset
│ │ │ │ └── Contents.json
│ │ ├── Info.plist
│ │ └── main.m
│ └── reactfirebaseexampleTests
│ │ ├── Info.plist
│ │ └── reactfirebaseexampleTests.m
│ ├── package-lock.json
│ ├── package.json
│ └── yarn.lock
└── yarn.lock
/.gitbook/assets/react-firebase-tutorial-auth-2-gif.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakannimer/react-firebase/ed3db6aba5563c78163b84c94da806a9c9d18dde/.gitbook/assets/react-firebase-tutorial-auth-2-gif.gif
--------------------------------------------------------------------------------
/.gitbook/assets/react-firebase-tutorial-auth-3-loading-gif.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakannimer/react-firebase/ed3db6aba5563c78163b84c94da806a9c9d18dde/.gitbook/assets/react-firebase-tutorial-auth-3-loading-gif.gif
--------------------------------------------------------------------------------
/.gitbook/assets/react-firebase-tutorial-auth-4-error-handling-gif.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakannimer/react-firebase/ed3db6aba5563c78163b84c94da806a9c9d18dde/.gitbook/assets/react-firebase-tutorial-auth-4-error-handling-gif.gif
--------------------------------------------------------------------------------
/.gitbook/assets/react-firebase-tutorial-fig (1).gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakannimer/react-firebase/ed3db6aba5563c78163b84c94da806a9c9d18dde/.gitbook/assets/react-firebase-tutorial-fig (1).gif
--------------------------------------------------------------------------------
/.gitbook/assets/react-firebase-tutorial-fig.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakannimer/react-firebase/ed3db6aba5563c78163b84c94da806a9c9d18dde/.gitbook/assets/react-firebase-tutorial-fig.gif
--------------------------------------------------------------------------------
/.gitbook/assets/screen-shot-2018-08-20-at-2.04.01-pm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakannimer/react-firebase/ed3db6aba5563c78163b84c94da806a9c9d18dde/.gitbook/assets/screen-shot-2018-08-20-at-2.04.01-pm.png
--------------------------------------------------------------------------------
/.gitbook/assets/screen-shot-2018-08-20-at-2.22.20-pm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakannimer/react-firebase/ed3db6aba5563c78163b84c94da806a9c9d18dde/.gitbook/assets/screen-shot-2018-08-20-at-2.22.20-pm.png
--------------------------------------------------------------------------------
/.gitbook/assets/screen-shot-2018-08-20-at-4.45.59-pm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakannimer/react-firebase/ed3db6aba5563c78163b84c94da806a9c9d18dde/.gitbook/assets/screen-shot-2018-08-20-at-4.45.59-pm.png
--------------------------------------------------------------------------------
/.gitbook/assets/screen-shot-2018-08-21-at-11.48.50-am.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakannimer/react-firebase/ed3db6aba5563c78163b84c94da806a9c9d18dde/.gitbook/assets/screen-shot-2018-08-21-at-11.48.50-am.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .vscode
2 | .cache
3 | dist
4 | node_modules
5 | build/
6 | coverage/
7 | .rpt2_cache
--------------------------------------------------------------------------------
/.opensource/project.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "React Firebase",
3 | "type": "library",
4 | "platforms": ["Web", "ReactNative"],
5 | "content": "README.md",
6 | "pages": {
7 | "modules/react-firebase-docs/docs/react-firebase-realtime-database/getting-started.md": "Getting Started with React Firebase Realtime Database",
8 | "modules/react-firebase-docs/docs/react-firebase-auth/getting-started.md": "Getting Started with React Firebase Auth",
9 | "modules/react-firebase-docs/docs/react-firebase-realtime-database/api.md": "React Firebase Realtime Database API",
10 | "modules/react-firebase-docs/docs/react-firebase-auth/api.md": "React Firebase Auth API",
11 | "modules/react-firebase-docs/docs/README.md": "Reference Docs"
12 | },
13 | "related": [
14 | "firebase/firebase-js-sdk",
15 | "firebase/firebase-admin-node",
16 | "invertase/react-native-firebase",
17 | "prescottprue/react-redux-firebase"
18 | ],
19 | "tabs": [
20 | {
21 | "title": "Reference Docs",
22 | "href": "https://react-firebase-js.com"
23 | }
24 | ]
25 | }
26 |
--------------------------------------------------------------------------------
/.vscode/last.sql:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakannimer/react-firebase/ed3db6aba5563c78163b84c94da806a9c9d18dde/.vscode/last.sql
--------------------------------------------------------------------------------
/modules/auth/.gitignore:
--------------------------------------------------------------------------------
1 | .cache
2 | .rpt2_cache
3 | .vscode
4 | build
5 | coverage
6 | dist
7 | node_modules
8 | src/demo/test-credentials.js
9 | dist/
10 | tmp-demo-dir/
11 | src/demo/test-credentials.ts
--------------------------------------------------------------------------------
/modules/auth/README.md:
--------------------------------------------------------------------------------
1 | # @react-firebase/auth
2 |
3 | ## [Getting Started](https://react-firebase-js.com/docs/react-firebase-auth/getting-started)
4 |
5 | ## [API](https://react-firebase-js.com/docs/react-firebase-auth/api)
6 |
--------------------------------------------------------------------------------
/modules/auth/__tests__/index.test.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import {
3 | render,
4 | fireEvent,
5 | cleanup,
6 | waitForElement
7 | } from "react-testing-library";
8 | import { App } from "../src/demo/app";
9 |
10 | test(
11 | "Sign In Anonymously",
12 | async () => {
13 | const { getByText, getByTestId } = render();
14 | await waitForElement(() => getByTestId("signin-anon"));
15 | const signinButton = getByTestId("signin-anon");
16 | fireEvent.click(signinButton);
17 | await waitForElement(() => getByText("You are authenticated"), {
18 | timeout: 10000
19 | });
20 | cleanup();
21 | },
22 | 10000
23 | );
24 |
--------------------------------------------------------------------------------
/modules/auth/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@react-firebase/auth",
3 | "description": "Easily integrate Firebase Authentication in your react(or react-native) app.",
4 | "version": "0.2.10",
5 | "main": "dist/index.cjs.js",
6 | "module": "dist/index.esm.js",
7 | "jsnext:main": "dist/index.esm.js",
8 | "umd": "dist/index.umd.js",
9 | "types": "dist/index.d.ts",
10 | "license": "GPL-3.0-only",
11 | "author": {
12 | "name": "rakannimer",
13 | "email": "rakannimer@gmail.com"
14 | },
15 | "scripts": {
16 | "dev": "parcel src/demo/index.html -d tmp-demo-dir",
17 | "build": "rollup -c",
18 | "test": "tsc && jest",
19 | "prepublish": "npm run build",
20 | "pub": "yarn build && yarn publish --access public"
21 | },
22 | "devDependencies": {
23 | "@types/jest": "^23.3.1",
24 | "@types/lodash.get": "^4.4.4",
25 | "@types/react": "^16.4.11",
26 | "docz": "^0.9.6",
27 | "firebase": "^5.4.0",
28 | "jest": "^23.5.0",
29 | "parcel-bundler": "^1.9.7",
30 | "prettier": "^1.14.2",
31 | "react": "^16.4.2",
32 | "react-dom": "^16.4.2",
33 | "react-testing-library": "^5.0.0",
34 | "rollup": "^0.64.1",
35 | "rollup-plugin-typescript2": "^0.16.1",
36 | "ts-jest": "^23.1.4",
37 | "typescript": "^3.0.1"
38 | },
39 | "dependencies": {
40 | "lodash.get": "^4.4.2",
41 | "render-and-add-props": "^0.5.0"
42 | },
43 | "peerDependencies": {
44 | "firebase": ">=4"
45 | },
46 | "repository": {
47 | "url": "https://github.com/rakannimer/react-firebase"
48 | },
49 | "files": [
50 | "dist/"
51 | ],
52 | "jest": {
53 | "collectCoverageFrom": [
54 | "src/*.tsx"
55 | ],
56 | "transform": {
57 | "^.+\\.tsx?$": "ts-jest"
58 | },
59 | "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
60 | "moduleFileExtensions": [
61 | "ts",
62 | "tsx",
63 | "js",
64 | "jsx",
65 | "json",
66 | "node"
67 | ]
68 | },
69 | "keywords": [
70 | "react",
71 | "firebase",
72 | "auth",
73 | "react-firebase-auth",
74 | "firebase-auth"
75 | ]
76 | }
77 |
--------------------------------------------------------------------------------
/modules/auth/rollup.config.js:
--------------------------------------------------------------------------------
1 | import typescript from "rollup-plugin-typescript2";
2 |
3 | export default [
4 | {
5 | input: "src/index.tsx",
6 | output: [
7 | {
8 | file: "dist/index.umd.js",
9 | format: "umd",
10 | name: "ReactFirebaseAuth"
11 | },
12 | {
13 | file: "dist/index.esm.js",
14 | format: "esm"
15 | },
16 | {
17 | file: "dist/index.cjs.js",
18 | format: "cjs"
19 | }
20 | ],
21 | external: ["react", "render-and-add-props", "immer"],
22 | plugins: [
23 | typescript({
24 | typescript: require("typescript"),
25 | abortOnError: false
26 | })
27 | ]
28 | }
29 | ];
30 |
--------------------------------------------------------------------------------
/modules/auth/src/demo/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/modules/auth/src/demo/index.js:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import { render } from "react-dom";
3 | import {App} from './app'
4 | render(, document.getElementById("root"));
5 |
--------------------------------------------------------------------------------
/modules/auth/src/initialize-firebase-app.ts:
--------------------------------------------------------------------------------
1 | import { InitializeAppArgs } from "./types";
2 | export const initializeFirebaseApp = ({
3 | firebase,
4 | authDomain,
5 | databaseURL,
6 | projectId,
7 | storageBucket,
8 | messagingSenderId,
9 | apiKey,
10 | appId,
11 | measurementId
12 | }: InitializeAppArgs) => {
13 | try {
14 | firebase.initializeApp({
15 | apiKey,
16 | authDomain,
17 | databaseURL,
18 | projectId,
19 | storageBucket,
20 | messagingSenderId,
21 | appId,
22 | measurementId
23 | });
24 | } catch (err) {
25 | if (err.code !== "app/duplicate-app") {
26 | throw err;
27 | }
28 | }
29 | };
30 |
--------------------------------------------------------------------------------
/modules/auth/src/types.ts:
--------------------------------------------------------------------------------
1 | export interface InitializeAppArgs {
2 | authDomain: string;
3 | apiKey: string;
4 | databaseURL: string;
5 | firebase: any;
6 | projectId: string;
7 | messagingSenderId?: string;
8 | storageBucket?: string;
9 | appId?: string;
10 | measurementId?: string;
11 | }
12 | export type FirebaseAuthProviderProps = InitializeAppArgs;
13 | export type AuthEmission = {
14 | isSignedIn: boolean;
15 | providerId: ("none" | "google.com" | string) | null;
16 | user: any;
17 | firebase: any;
18 | };
19 | export type FirebaseAuthProviderState = AuthEmission;
20 |
21 | export type ChildFunction = ((authState: AuthEmission) => any);
22 |
23 | export type RenderableChildren = ChildFunction;
24 |
--------------------------------------------------------------------------------
/modules/auth/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "include": ["./src/"],
3 | "compilerOptions": {
4 | "jsx": "react",
5 | "target": "es5",
6 | "module": "ESNext",
7 | "moduleResolution": "node",
8 | "lib": ["es2018", "dom"],
9 | "outDir": "./build/",
10 | "strict": true,
11 | "declaration": true,
12 | "removeComments": true,
13 | "esModuleInterop": true,
14 | "allowSyntheticDefaultImports": true
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/modules/database/.gitignore:
--------------------------------------------------------------------------------
1 | build
2 | .cache
3 | .rpt2_cache
4 | .vscode
5 | dist
6 | coverage
7 | node_modules
8 | tmp-demo-dir
9 | src/demo/test-credentials.ts
10 | .docz
--------------------------------------------------------------------------------
/modules/database/README.md:
--------------------------------------------------------------------------------
1 | # @react-firebase/database
2 |
3 | ## [Getting Started](https://react-firebase-js.com/docs/react-firebase-realtime-database/getting-started)
4 |
5 | ## [API](https://react-firebase-js.com/docs/react-firebase-realtime-database/api)
6 |
--------------------------------------------------------------------------------
/modules/database/__tests__/FirebaseDatabaseMutation.test.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import {
3 | render,
4 | fireEvent,
5 | waitForElement,
6 | getNodeText,
7 | cleanup
8 | } from "react-testing-library";
9 |
10 | import {
11 | isBoolean,
12 | deleteValueAtPath,
13 | getValueAtPath,
14 | setValueAtPath,
15 | p
16 | } from "../src/test-utils";
17 | import { MutationExamplePush } from "../src/test-cases/MutationExamplePush";
18 | import { MutationExampleUpdate } from "../src/test-cases/MutationExampleUpdate";
19 |
20 | const TEST_TIMEOUT = 10000;
21 |
22 | describe("FirebaseDatabaseMutation", () => {
23 | let testPath = `/__tests__/${Date.now()}/user_bookmarks/testPath`;
24 | let testPathValue = {
25 | ohHai: "Mark"
26 | };
27 | beforeAll(async () => {
28 | await deleteValueAtPath(testPath);
29 | const val = await getValueAtPath(testPath);
30 | expect(val).toBeNull();
31 | await setValueAtPath(testPath, testPathValue);
32 | });
33 | afterAll(async () => {
34 | await deleteValueAtPath(testPath);
35 | const val = await getValueAtPath(testPath);
36 | expect(val).toBeNull();
37 | });
38 | afterEach(async () => {
39 | await cleanup();
40 | });
41 | test(
42 | "push",
43 | async () => {
44 | const { getByTestId } = render(
45 |
46 | );
47 | const pushMutationButton = getByTestId("test-push");
48 | await waitForElement(() => pushMutationButton);
49 | fireEvent.click(pushMutationButton);
50 | await waitForElement(() => getByTestId("test-push-result"));
51 | expect(getNodeText(getByTestId("test-push-result")).length).toBe(20);
52 | },
53 | TEST_TIMEOUT
54 | );
55 | test(
56 | "update",
57 | async () => {
58 | const { getByTestId } = render(
59 |
60 | );
61 | const pushMutationButton = getByTestId("test-push");
62 | await waitForElement(() => pushMutationButton);
63 | fireEvent.click(pushMutationButton);
64 | await waitForElement(() => getByTestId("test-push-result"));
65 | expect(isBoolean(p(getNodeText(getByTestId("test-push-result"))))).toBe(
66 | true
67 | );
68 | },
69 | TEST_TIMEOUT
70 | );
71 | });
72 |
--------------------------------------------------------------------------------
/modules/database/__tests__/FirebaseDatabaseTranasaction.test.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import {
3 | render,
4 | fireEvent,
5 | waitForElement,
6 | cleanup
7 | } from "react-testing-library";
8 | import {
9 | deleteValueAtPath,
10 | getValueAtPath,
11 | setValueAtPath
12 | } from "../src/test-utils";
13 | const TEST_TIMEOUT = 15000;
14 | import { TransactionExample } from "../src/test-cases/TransactionExampleBasic";
15 |
16 | describe("FirebaseDatabaseTransaction", () => {
17 | let testPath = `/__tests__/${Date.now()}/user_bookmarks/testPath`;
18 | let testPathValue = 0;
19 | beforeAll(async () => {
20 | await deleteValueAtPath(testPath);
21 | const val = await getValueAtPath(testPath);
22 | expect(val).toBeNull();
23 | await setValueAtPath(testPath, testPathValue);
24 | });
25 | afterAll(async () => {
26 | await deleteValueAtPath(testPath);
27 | const val = await getValueAtPath(testPath);
28 | expect(val).toBeNull();
29 | });
30 | afterEach(async () => {
31 | await cleanup();
32 | });
33 | test(
34 | "tranasaction basic",
35 | async () => {
36 | const { getByTestId } = render();
37 | const pushMutationButton = getByTestId("test-transaction");
38 | await waitForElement(() => pushMutationButton);
39 | fireEvent.click(pushMutationButton);
40 | await waitForElement(() => getByTestId("test-transaction-result"), {
41 | timeout: TEST_TIMEOUT
42 | });
43 | const val = await getValueAtPath(testPath);
44 | expect(val).toEqual(1);
45 | },
46 | TEST_TIMEOUT
47 | );
48 | });
49 |
--------------------------------------------------------------------------------
/modules/database/__tests__/reducers.test.ts:
--------------------------------------------------------------------------------
1 | import { reducers } from "../src/reducers";
2 | describe("reducers", () => {
3 | test("exist", () => {
4 | expect(reducers).toBeTruthy();
5 | });
6 | test("work", () => {
7 | expect(reducers.setIsLoading(true)({ isLoading: false } as any)).toEqual({
8 | isLoading: true
9 | });
10 | expect(reducers.setPath("posts")({} as any)).toEqual({
11 | path: "posts"
12 | });
13 | expect(reducers.setValue("posts")({} as any)).toEqual({
14 | value: "posts"
15 | });
16 | expect(reducers.addKeyToList("a")({} as any)).toEqual({
17 | value: ["a"]
18 | });
19 | expect(reducers.addKeyToList("a")({ value: [] } as any)).toEqual({
20 | value: ["a"]
21 | });
22 | expect(reducers.addKeyToList("b")({ value: ["a"] } as any)).toEqual({
23 | value: ["a", "b"]
24 | });
25 | expect(reducers.prependKeyToList("c")({ value: ["a"] } as any)).toEqual({
26 | value: ["c", "a"]
27 | });
28 |
29 | expect(reducers.addToList("VAL", "KEY")({} as any).value).toEqual([
30 | {
31 | data: "VAL",
32 | key: "KEY"
33 | }
34 | ]);
35 | expect(
36 | reducers.prependToList("VAL", "KEY")({
37 | value: [{ data: "d", key: "k" }]
38 | } as any).value
39 | ).toEqual([
40 | {
41 | data: "VAL",
42 | key: "KEY"
43 | },
44 | { data: "d", key: "k" }
45 | ]);
46 | });
47 | });
48 |
--------------------------------------------------------------------------------
/modules/database/cypress.json:
--------------------------------------------------------------------------------
1 | {}
2 |
--------------------------------------------------------------------------------
/modules/database/cypress/fixtures/example.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Using fixtures to represent data",
3 | "email": "hello@cypress.io",
4 | "body": "Fixtures are a great way to mock data for responses to routes"
5 | }
--------------------------------------------------------------------------------
/modules/database/cypress/integration/database.test.js:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | context("Database", () => {
4 | beforeEach(() => {
5 | cy.visit("http://localhost:3000");
6 | });
7 | it("should exists", () => {
8 | const list = cy.get("[data-testid=list]");
9 | const item = cy.get("[data-testid=item]");
10 | item.should("have.length", 2);
11 | console.warn(list, item);
12 | });
13 | });
14 |
--------------------------------------------------------------------------------
/modules/database/cypress/plugins/index.js:
--------------------------------------------------------------------------------
1 | // ***********************************************************
2 | // This example plugins/index.js can be used to load plugins
3 | //
4 | // You can change the location of this file or turn off loading
5 | // the plugins file with the 'pluginsFile' configuration option.
6 | //
7 | // You can read more here:
8 | // https://on.cypress.io/plugins-guide
9 | // ***********************************************************
10 |
11 | // This function is called when a project is opened or re-opened (e.g. due to
12 | // the project's config changing)
13 |
14 | module.exports = (on, config) => {
15 | // `on` is used to hook into various events Cypress emits
16 | // `config` is the resolved Cypress config
17 | }
18 |
--------------------------------------------------------------------------------
/modules/database/cypress/support/commands.js:
--------------------------------------------------------------------------------
1 | // ***********************************************
2 | // This example commands.js shows you how to
3 | // create various custom commands and overwrite
4 | // existing commands.
5 | //
6 | // For more comprehensive examples of custom
7 | // commands please read more here:
8 | // https://on.cypress.io/custom-commands
9 | // ***********************************************
10 | //
11 | //
12 | // -- This is a parent command --
13 | // Cypress.Commands.add("login", (email, password) => { ... })
14 | //
15 | //
16 | // -- This is a child command --
17 | // Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
18 | //
19 | //
20 | // -- This is a dual command --
21 | // Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
22 | //
23 | //
24 | // -- This is will overwrite an existing command --
25 | // Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
26 |
--------------------------------------------------------------------------------
/modules/database/cypress/support/index.js:
--------------------------------------------------------------------------------
1 | // ***********************************************************
2 | // This example support/index.js is processed and
3 | // loaded automatically before your test files.
4 | //
5 | // This is a great place to put global configuration and
6 | // behavior that modifies Cypress.
7 | //
8 | // You can change the location of this file or turn off
9 | // automatically serving support files with the
10 | // 'supportFile' configuration option.
11 | //
12 | // You can read more here:
13 | // https://on.cypress.io/configuration
14 | // ***********************************************************
15 |
16 | // Import commands.js using ES2015 syntax:
17 | import './commands'
18 |
19 | // Alternatively you can use CommonJS syntax:
20 | // require('./commands')
21 |
--------------------------------------------------------------------------------
/modules/database/doczrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | typescript: true,
3 | title: "React Firebase Database",
4 | description: "Render your Firebase Data with React"
5 | // dest: "docs",
6 | // hashRouter: false,
7 | // propsParser: false,
8 | // indexHtml: "src/docs/index.html"
9 | // base: "/react-google-charts/"
10 | // themeConfig: {
11 | // logo: {
12 | // src: "/assets/logo.png"
13 | // }
14 | // }
15 | };
16 |
--------------------------------------------------------------------------------
/modules/database/rollup.config.js:
--------------------------------------------------------------------------------
1 | import typescript from "rollup-plugin-typescript2";
2 |
3 | export default {
4 | input: "src/index.tsx",
5 | output: [
6 | {
7 | file: "dist/index.esm.js",
8 | format: "esm"
9 | },
10 | {
11 | file: "dist/index.cjs.js",
12 | format: "cjs"
13 | }
14 | ],
15 | external: ["render-and-add-props", "react"],
16 | plugins: [
17 | typescript({
18 | typescript: require("typescript"),
19 | abortOnError: false
20 | })
21 | ]
22 | };
23 |
--------------------------------------------------------------------------------
/modules/database/src/Context.ts:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import { FirebaseDatabaseProviderState } from "./types";
3 | import memoize from "lodash/memoize";
4 | export const firebaseDatabaseDefaultContext = {
5 | firebase: {}
6 | } as FirebaseDatabaseProviderState;
7 |
8 | export type GetContext = (
9 | createContext?: any
10 | ) => {
11 | FirebaseDatabaseContextProvider: React.Provider<
12 | FirebaseDatabaseProviderState
13 | >;
14 | FirebaseDatabaseContextConsumer: React.Consumer<
15 | FirebaseDatabaseProviderState
16 | >;
17 | };
18 |
19 | export const getContext: GetContext = memoize(
20 | (
21 | createContext = (defaultContext: typeof firebaseDatabaseDefaultContext) =>
22 | React.createContext(defaultContext)
23 | ) => {
24 | const {
25 | Provider: FirebaseDatabaseContextProvider,
26 | Consumer: FirebaseDatabaseContextConsumer
27 | } = createContext(firebaseDatabaseDefaultContext);
28 | return {
29 | FirebaseDatabaseContextProvider,
30 | FirebaseDatabaseContextConsumer
31 | };
32 | },
33 | () => 1
34 | );
35 |
--------------------------------------------------------------------------------
/modules/database/src/components/FirebaseDatabaseNode.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import { getContext } from "../Context";
3 | import { FirebaseDatabaseNodeProps } from "../types";
4 | export { FirebaseDatabaseProvider } from "./FirebaseDatabaseProvider";
5 | import FirebaseDatabaseNodeWithLifeCycle from "./FirebaseDatabaseNodeLifeCycle";
6 |
7 | export class FirebaseDatabaseNode extends React.Component<
8 | FirebaseDatabaseNodeProps
9 | > {
10 | render() {
11 | const { FirebaseDatabaseContextConsumer } = getContext();
12 | return (
13 |
14 | {context => {
15 | return (
16 |
17 |
21 |
22 | );
23 | }}
24 |
25 | );
26 | }
27 | }
28 | export default FirebaseDatabaseNode;
29 |
--------------------------------------------------------------------------------
/modules/database/src/components/FirebaseDatabaseProvider.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import { renderAndAddProps } from "render-and-add-props";
3 | import { initializeFirebaseApp } from "../initialize-firebase-app";
4 | import { getContext } from "../Context";
5 | import {
6 | FirebaseDatabaseProviderState,
7 | FirebaseDatabaseProviderProps
8 | } from "../types";
9 | export class FirebaseDatabaseProvider extends React.Component<
10 | FirebaseDatabaseProviderProps,
11 | FirebaseDatabaseProviderState
12 | > {
13 | __isMounted = true;
14 | constructor(props: FirebaseDatabaseProviderProps) {
15 | super(props);
16 | this.state = {
17 | firebase: props.firebase
18 | };
19 | if (this.props.apiKey) {
20 | initializeFirebaseApp(this.props);
21 | }
22 | }
23 | render() {
24 | const { children, createContext } = this.props;
25 | const { FirebaseDatabaseContextProvider } = getContext(createContext);
26 | return (
27 |
28 | {renderAndAddProps(children, {})}
29 |
30 | );
31 | }
32 | }
33 |
34 | export default FirebaseDatabaseProvider;
35 |
--------------------------------------------------------------------------------
/modules/database/src/demo/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/modules/database/src/demo/index.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import { render } from "react-dom";
3 | import { App } from "./App";
4 |
5 | render(, document.getElementById("root"));
6 |
--------------------------------------------------------------------------------
/modules/database/src/docs/index.tsx:
--------------------------------------------------------------------------------
1 | // import * as React from "react";
2 | // //@ts-ignore
3 | // import Component from "@reach/component-component";
4 | // import * as firebase from "firebase/app";
5 | // import "firebase/database";
6 |
7 | // import { FirebaseDatabaseNode } from "../components/FirebaseDatabaseNode";
8 | // import { FirebaseDatabaseProvider } from "../components/FirebaseDatabaseProvider";
9 | // import { config } from "../demo/test-credentials";
10 | // // import { config } from "../demo/test-credentials.ts";
11 |
12 | // export const Demo = () => (
13 | //
14 | //
15 | // {({ state, setState }) => (
16 | //
17 | //
23 | // {d => {
24 | // return (
25 | //
26 | // Path {d.path}
27 | //
28 | // Value {JSON.stringify(d.value, null, 2)}
29 | //
30 | //
31 | // );
32 | // }}
33 | //
34 | //
35 | //
42 | //
49 | //
50 | //
51 | // )}
52 | //
53 | //
54 | // );
55 |
--------------------------------------------------------------------------------
/modules/database/src/get-firebase-query.ts:
--------------------------------------------------------------------------------
1 | import { FirebaseQuery } from "./types";
2 |
3 | export const getFirebaseQuery = ({
4 | firebase = null,
5 | path,
6 | orderByChild = null,
7 | orderByKey = null,
8 | orderByValue = null,
9 | limitToFirst = null,
10 | limitToLast = null,
11 | startAt = null,
12 | endAt = null,
13 | equalTo = null
14 | }: FirebaseQuery) => {
15 | if (firebase === null) {
16 | throw new Error("Need to supply firebase argument to getFirebaseQuery");
17 | }
18 | if (path === null || typeof path === "undefined") {
19 | throw new Error("Need to supply path argument to getFirebaseQuery");
20 | }
21 | let result = firebase.database().ref(path);
22 | if (orderByChild !== null) {
23 | result = result.orderByChild(orderByChild);
24 | }
25 | if (orderByKey !== null) {
26 | result = result.orderByKey();
27 | }
28 | if (orderByValue !== null) {
29 | result = result.orderByValue();
30 | }
31 | if (limitToFirst !== null) {
32 | result = result.limitToFirst(limitToFirst);
33 | }
34 | if (limitToLast !== null) {
35 | result = result.limitToLast(limitToLast);
36 | }
37 | if (startAt !== null) {
38 | result = result.startAt(startAt);
39 | }
40 | if (endAt !== null) {
41 | result = result.endAt(endAt);
42 | }
43 | if (equalTo !== null) {
44 | result = result.equalTo(equalTo);
45 | }
46 | return result;
47 | };
48 |
--------------------------------------------------------------------------------
/modules/database/src/index.tsx:
--------------------------------------------------------------------------------
1 | export { FirebaseDatabaseNode } from "./components/FirebaseDatabaseNode";
2 | export { FirebaseDatabaseNodes } from "./components/FirebaseDatabaseNodes";
3 | export {
4 | FirebaseDatabaseProvider
5 | } from "./components/FirebaseDatabaseProvider";
6 |
7 | export {
8 | FirebaseDatabaseMutation
9 | } from "./components/FirebaseDatabaseMutation";
10 | export {
11 | FirebaseDatabaseTransaction
12 | } from "./components/FirebaseDatabaseTransaction";
13 |
14 | export { getFirebaseQuery } from "./get-firebase-query";
15 | export { initializeFirebaseApp } from "./initialize-firebase-app";
16 |
--------------------------------------------------------------------------------
/modules/database/src/initialize-firebase-app.ts:
--------------------------------------------------------------------------------
1 | import { InitializeAppArgs } from "./types";
2 | export const initializeFirebaseApp = ({
3 | firebase,
4 | authDomain,
5 | databaseURL,
6 | projectId,
7 | storageBucket,
8 | messagingSenderId,
9 | apiKey,
10 | appId,
11 | measurementId
12 | }: InitializeAppArgs) => {
13 | try {
14 | firebase.initializeApp({
15 | apiKey,
16 | authDomain,
17 | databaseURL,
18 | projectId,
19 | storageBucket,
20 | messagingSenderId,
21 | appId,
22 | measurementId
23 | });
24 | } catch (err) {
25 | if (err.code !== "app/duplicate-app") {
26 | throw err;
27 | }
28 | }
29 | };
30 |
--------------------------------------------------------------------------------
/modules/database/src/test-cases/MutationExamplePush.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import * as firebase from "firebase/app";
3 | import "firebase/database";
4 | import { State } from "react-powerplug";
5 | import { FirebaseDatabaseProvider, FirebaseDatabaseMutation } from "../";
6 | import { config } from "../demo/test-credentials";
7 |
8 | import { IfNotFalsy } from "../test-utils";
9 |
10 | export const MutationExamplePush = ({
11 | path,
12 | value
13 | }: {
14 | path: string;
15 | value: any;
16 | }) => (
17 |
18 |
19 | {({ state, setState }) => (
20 |
21 |
22 | {({ runMutation }) => {
23 | return (
24 |
35 | );
36 | }}
37 |
38 |
39 |
40 | {state.pushedKey}
41 |
42 |
43 | )}
44 |
45 |
46 | );
47 |
--------------------------------------------------------------------------------
/modules/database/src/test-cases/MutationExampleUpdate.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import * as firebase from "firebase/app";
3 | import "firebase/database";
4 | import { State } from "react-powerplug";
5 | import { FirebaseDatabaseProvider, FirebaseDatabaseMutation } from "..";
6 | import { config } from "../demo/test-credentials";
7 |
8 | import { IfNotFalsy, WithTestId, s } from "../test-utils";
9 |
10 | export const MutationExampleUpdate = ({
11 | path,
12 | value
13 | }: {
14 | path: string;
15 | value: any;
16 | }) => (
17 |
18 |
19 | {({ state, setState }) => (
20 |
21 |
22 | {({ runMutation }) => {
23 | return (
24 |
25 |
34 |
35 | );
36 | }}
37 |
38 |
39 |
40 |
41 | {s(state.hasUpdated)}
42 |
43 |
44 |
45 | )}
46 |
47 |
48 | );
49 |
--------------------------------------------------------------------------------
/modules/database/src/test-cases/NodeExampleBasic.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 |
3 | import * as firebase from "firebase/app";
4 | import "firebase/database";
5 | import { FirebaseDatabaseProvider, FirebaseDatabaseNode } from "../";
6 | import { config } from "../demo/test-credentials";
7 |
8 | import { IfNotFalsy, s, WithTestId } from "../test-utils";
9 |
10 | export const NodeExampleBasic = ({
11 | path,
12 | ...otherStuffMaybe
13 | }: {
14 | path: string;
15 | [otherStuffMaybe: string]: any;
16 | }) => (
17 |
18 |
19 | {value => {
20 | return (
21 |
22 |
23 |
24 | {s(value.value)}
25 |
26 |
27 |
28 |
29 | {s(value.path)}
30 |
31 |
32 |
33 |
34 | {s(value.isLoading)}
35 |
36 |
37 |
38 | );
39 | }}
40 |
41 |
42 | );
43 |
--------------------------------------------------------------------------------
/modules/database/src/test-cases/TransactionExampleBasic.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import * as firebase from "firebase/app";
3 | import "firebase/database";
4 | import { State } from "react-powerplug";
5 | import { FirebaseDatabaseProvider, FirebaseDatabaseTransaction } from "../";
6 | import { config } from "../demo/test-credentials";
7 | import { IfNotFalsy } from "../test-utils";
8 |
9 | export const TransactionExample = ({
10 | path,
11 | ...otherStuffMaybe
12 | }: {
13 | path: string;
14 | [otherStuffMaybe: string]: any;
15 | }) => {
16 | return (
17 |
18 |
19 | {({ state, setState }) => {
20 | return (
21 |
22 |
23 |
24 | {state.hasUpdated}
25 |
26 |
27 |
28 | {({ runTransaction }) => (
29 |
30 |
49 |
50 | )}
51 |
52 |
53 | );
54 | }}
55 |
56 |
57 | );
58 | };
59 |
--------------------------------------------------------------------------------
/modules/database/src/utils.ts:
--------------------------------------------------------------------------------
1 | import { FirebaseQuery } from "./types";
2 | const firebaseQueryProperties = [
3 | "path",
4 | "orderByChild",
5 | "orderByKey",
6 | "orderByValue",
7 | "limitToFirst",
8 | "limitToLast",
9 | "startAt",
10 | "endAt",
11 | "equalTo",
12 | "keysOnly"
13 | ] as Array;
14 |
15 | export const getInternalDataPath = (componentID: any, query: FirebaseQuery) => {
16 | return `${componentID}-${firebaseQueryProperties
17 | .map(prop => query[prop])
18 | .join("_")}`;
19 | };
20 |
21 | let id = 0;
22 | export const createID = () => {
23 | return id++;
24 | };
25 |
26 | export const hasFirebaseQueryChanged = (
27 | previousQuery: FirebaseQuery,
28 | currentQuery: FirebaseQuery
29 | ) => {
30 | for (let propName of firebaseQueryProperties) {
31 | if (previousQuery[propName] !== currentQuery[propName]) {
32 | return true;
33 | }
34 | }
35 | return false;
36 | };
37 |
--------------------------------------------------------------------------------
/modules/database/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "include": ["./src/"],
3 | "compilerOptions": {
4 | "jsx": "react",
5 | "target": "es5",
6 | "module": "ESNext",
7 | "moduleResolution": "node",
8 | "lib": ["es2018", "dom"],
9 | "outDir": "./build/",
10 | "strict": true,
11 | "declaration": true,
12 | "removeComments": true,
13 | "esModuleInterop": true,
14 | "allowSyntheticDefaultImports": true,
15 | "skipLibCheck": true
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/modules/firestore/.gitignore:
--------------------------------------------------------------------------------
1 | .cache
2 | .rpt2_cache
3 | .vscode
4 | dist
5 | build
6 | node_modules
7 | tmp-demo-dir
8 | src/demo/test-credentials.js
9 | coverage
--------------------------------------------------------------------------------
/modules/firestore/README.md:
--------------------------------------------------------------------------------
1 | # @react-firebase/firestore
2 |
3 | ## [Getting Started](https://react-firebase-js.com/docs/react-firestore-database/getting-started)
4 |
5 | ## [API](https://react-firebase-js.com/docs/react-firestore-database/api)
6 |
--------------------------------------------------------------------------------
/modules/firestore/__tests__/e2e/App.test.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import {
3 | render,
4 | getNodeText,
5 | fireEvent,
6 | waitForElement
7 | } from "react-testing-library";
8 | import * as firebase from "firebase/app";
9 | import "firebase/firestore";
10 | import {
11 | App,
12 | testDocPath,
13 | testDocValue,
14 | testDocUpdate
15 | } from "../../src/demo/App";
16 |
17 | import {
18 | setValueAtPath,
19 | getValueAtPath,
20 | deleteValueAtPath
21 | } from "../../src/test-utils";
22 |
23 | export const before = async () => {
24 | await deleteValueAtPath(testDocPath);
25 | const val = await getValueAtPath(testDocPath);
26 | expect(val).toEqual(undefined);
27 | await setValueAtPath(testDocPath, { c: "d" });
28 | };
29 |
30 | export const after = async (path = testDocPath) => {
31 | await deleteValueAtPath(testDocPath);
32 | };
33 |
34 | test(
35 | "update-document",
36 | async () => {
37 | await before();
38 | const { getByTestId } = render();
39 | fireEvent.click(getByTestId("update-document"));
40 | await waitForElement(() => getByTestId("update-document-result"), {
41 | timeout: 10000
42 | });
43 | const addedKeys = Object.keys(
44 | JSON.parse(getNodeText(getByTestId("update-document-result")))
45 | );
46 | // throw JSON.parse(getNodeText(getByTestId("update-document-result")));
47 | Object.keys(testDocUpdate).forEach(testKey => {
48 | expect(addedKeys).toContain(testKey);
49 | });
50 | await after();
51 | },
52 | 10000
53 | );
54 |
55 | test(
56 | "set-document",
57 | async () => {
58 | // Initialize
59 | const { getByText, getByTestId } = render();
60 | await deleteValueAtPath(testDocPath);
61 | const val = await getValueAtPath(testDocPath);
62 | expect(val).toEqual(undefined);
63 |
64 | // Set Document
65 | fireEvent.click(getByTestId("set-document"));
66 | await waitForElement(() => getByTestId("set-document-result"), {
67 | timeout: 10000
68 | });
69 | const addedKeys = Object.keys(
70 | JSON.parse(getNodeText(getByTestId("set-document-result")))
71 | );
72 | Object.keys(testDocValue).forEach(testKey => {
73 | expect(addedKeys).toContain(testKey);
74 | });
75 | },
76 | 10000
77 | );
78 |
--------------------------------------------------------------------------------
/modules/firestore/rollup.config.js:
--------------------------------------------------------------------------------
1 | import typescript from "rollup-plugin-typescript2";
2 |
3 | export default {
4 | input: "src/index.tsx",
5 | output: [
6 | {
7 | file: "dist/index.umd.js",
8 | format: "umd",
9 | name: "ReactGoogleCharts"
10 | },
11 | {
12 | file: "dist/index.esm.js",
13 | format: "esm"
14 | },
15 | {
16 | file: "dist/index.cjs.js",
17 | format: "cjs"
18 | }
19 | ],
20 | external: [
21 | "react",
22 | "lodash.get",
23 | "lodash.set",
24 | "firebase",
25 | "render-and-add-props",
26 | "immer"
27 | ],
28 | plugins: [
29 | typescript({
30 | typescript: require("typescript"),
31 | abortOnError: false,
32 | tsconfigOverride: {
33 | compilerOptions: {
34 | module: "ESNext"
35 | }
36 | }
37 | })
38 | ]
39 | };
40 |
--------------------------------------------------------------------------------
/modules/firestore/src/Context.ts:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import { FirestoreProviderState } from "./types";
3 |
4 | export const firestoreDefaultContext = {
5 | listenTo: (a: any) => {},
6 | stopListeningTo: (path: string) => {},
7 | dataTree: {},
8 | firebase: {},
9 | firestore: null as any
10 | } as FirestoreProviderState;
11 |
12 | export const {
13 | Provider: FirestoreContextProvider,
14 | Consumer: FirestoreContextConsumer
15 | } = React.createContext(firestoreDefaultContext);
16 |
--------------------------------------------------------------------------------
/modules/firestore/src/components/FirestoreCollection.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import { renderAndAddProps } from "render-and-add-props";
3 | import get from "lodash/get";
4 | import { FirestoreContextConsumer } from "../Context";
5 | import { FirestoreQuery } from "../types";
6 | import { FirestoreCollectionContextConsumerLifeCycle } from "./FirestoreCollectionContextConsumerWithLifecycle";
7 |
8 | export class FirestoreCollection extends React.Component<
9 | FirestoreQuery & {
10 | children: (
11 | {
12 |
13 | }: {
14 | path: string;
15 | value: any;
16 | ids: string[];
17 | isLoading: boolean;
18 | }
19 | ) => React.ReactNode;
20 | }
21 | > {
22 | render() {
23 | const { children, path } = this.props;
24 | if (path === null) {
25 | console.warn("path not provided to FirestoreNode ! Not rendering.");
26 | return null;
27 | }
28 | return (
29 |
30 | {context => {
31 | return (
32 |
33 |
38 | {renderAndAddProps(children, {
39 | path,
40 | value: get(context, `dataTree[${path}].value`, null),
41 | ids: get(context, `dataTree[${path}].ids`, null),
42 | isLoading: get(context, `dataTree[${path}].isLoading`, true)
43 | })}
44 |
45 | );
46 | }}
47 |
48 | );
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/modules/firestore/src/components/FirestoreCollectionContextConsumerWithLifecycle.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import { FirestoreContextConsumerWithLifeCycleProps } from "../types";
3 | export class FirestoreCollectionContextConsumerLifeCycle extends React.Component<
4 | FirestoreContextConsumerWithLifeCycleProps
5 | > {
6 | listenToNode() {
7 | const { dataTree, path, listenTo } = this.props;
8 | if (path === null) {
9 | return;
10 | }
11 | listenTo(this.props, "collection");
12 | }
13 | stopListeningToNode() {
14 | const { stopListeningTo, path, dataTree } = this.props;
15 | if (path === null || path in dataTree) {
16 | return;
17 | }
18 | stopListeningTo(path);
19 | }
20 | componentDidMount() {
21 | this.listenToNode();
22 | }
23 | shouldComponentUpdate(nextProps: FirestoreContextConsumerWithLifeCycleProps) {
24 | const propsThatCanChange = [
25 | "path",
26 | "limit",
27 | "startAfter",
28 | "startAt",
29 | "endAt",
30 | "endBefore",
31 | "where"
32 | ];
33 | for (let propName of propsThatCanChange) {
34 | //@ts-ignore
35 | if (this.props[propName] !== nextProps[propName]) {
36 | return true;
37 | }
38 | }
39 | return false;
40 | }
41 |
42 | componentDidUpdate() {
43 | this.listenToNode();
44 | }
45 | componentWillUnmount() {
46 | this.stopListeningToNode();
47 | }
48 | render() {
49 | return null;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/modules/firestore/src/components/FirestoreDocument.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import { renderAndAddProps } from "render-and-add-props";
3 |
4 | import { FirestoreContextConsumer } from "../Context";
5 | import { FirestoreQuery } from "../types";
6 | import { FirestoreDocumentContextConsumerLifeCycle } from "./FirestoreDocumentContextConsumerWithLifecycle";
7 |
8 | export class FirestoreDocument extends React.Component<
9 | FirestoreQuery & {
10 | children: (
11 | {
12 |
13 | }: {
14 | path: string;
15 | value: any;
16 | isLoading: boolean;
17 | }
18 | ) => React.ReactNode;
19 | }
20 | > {
21 | render() {
22 | const { children, path } = this.props;
23 | if (path === null) {
24 | console.warn("path not provided to FirestoreNode ! Not rendering.");
25 | return null;
26 | }
27 | return (
28 |
29 | {context => {
30 | return (
31 |
32 |
37 | {renderAndAddProps(children, {
38 | path,
39 | value: context.dataTree[path] && context.dataTree[path].value,
40 | isLoading:
41 | context.dataTree[path] && context.dataTree[path].isLoading
42 | })}
43 |
44 | );
45 | }}
46 |
47 | );
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/modules/firestore/src/components/FirestoreDocumentContextConsumerWithLifecycle.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 |
3 | import { FirestoreContextConsumerWithLifeCycleProps } from "../types";
4 |
5 | export class FirestoreDocumentContextConsumerLifeCycle extends React.Component<
6 | FirestoreContextConsumerWithLifeCycleProps
7 | > {
8 | listenToNodeIfNotInContext() {
9 | const { dataTree, path, listenTo } = this.props;
10 | if (path === null || path in dataTree) {
11 | return;
12 | }
13 | listenTo(this.props, "document");
14 | }
15 | stopListeningToNode() {
16 | const { stopListeningTo, path, dataTree } = this.props;
17 | if (path === null || path in dataTree) {
18 | return;
19 | }
20 | stopListeningTo(path);
21 | }
22 | componentDidMount() {
23 | this.listenToNodeIfNotInContext();
24 | }
25 | componentDidUpdate() {
26 | this.listenToNodeIfNotInContext();
27 | }
28 | componentWillUnmount() {
29 | this.stopListeningToNode();
30 | }
31 | render() {
32 | return null;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/modules/firestore/src/demo/App.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import * as firebase from "firebase/app";
3 | import "firebase/firestore";
4 | import { config } from "./test-credentials";
5 | import { FirestoreProvider } from "../";
6 | import { RenderInfiniteList } from "./RenderInfiniteList";
7 | import { SetDocument } from "./SetDocument";
8 | import { UpdateDocument } from "./UpdateDocument";
9 | import { DeleteDocument } from "./DeleteDocument";
10 | import { AddToCollection } from "./AddToCollection";
11 | import { BatchedWrite } from "./BatchedWrite";
12 |
13 | export const testCollectionPath = "user_bookmarks";
14 | export const testDocPath = `${testCollectionPath}/TEST_USER_ID`;
15 | export const testDocValue = {
16 | nowOnCli: Date.now(),
17 | nowOnServer: firebase.firestore.FieldValue.serverTimestamp(),
18 | some: "data"
19 | };
20 | export const testDocUpdate = {
21 | someOther: "data"
22 | };
23 |
24 | export const s = (v: any) => JSON.stringify(v, null, 2);
25 |
26 | export const App = () => {
27 | return (
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 | );
39 | };
40 |
--------------------------------------------------------------------------------
/modules/firestore/src/demo/BatchedWrite.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import { FirestoreBatchedWrite } from "../";
3 | import { testDocPath } from "./App";
4 | export const BatchedWrite = () => {
5 | return (
6 |
7 |
8 | {({ addMutationToBatch, commit }) => {
9 | // console.log()
10 | return (
11 |
12 |
Batched write
13 |
25 |
35 |
36 | );
37 | }}
38 |
39 |
40 | );
41 | };
42 |
--------------------------------------------------------------------------------
/modules/firestore/src/demo/DeleteDocument.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import { FirestoreDocument, FirestoreMutation } from "../";
3 | import { testDocPath, testDocUpdate, s } from "./App";
4 | export const DeleteDocument = () => (
5 |
6 |
7 | {({ runMutation }) => (
8 | <>
9 |
17 |
18 | {d =>
19 | d.value ? (
20 | {s(d.value)}
21 | ) : null
22 | }
23 |
24 | >
25 | )}
26 |
27 |
28 | );
29 |
--------------------------------------------------------------------------------
/modules/firestore/src/demo/RenderInfiniteList.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import { State } from "react-powerplug";
3 | import { FirestoreCollection } from "../components/FirestoreCollection";
4 | import { testCollectionPath, s } from "./App";
5 | export const RenderInfiniteList = () => (
6 |
7 |
8 | {({ state, setState }) => (
9 |
14 | {({ value, ids }) => {
15 | return (
16 |
17 |
{s({ value, ids })}
18 |
29 |
30 | );
31 | }}
32 |
33 | )}
34 |
35 |
36 | );
37 |
--------------------------------------------------------------------------------
/modules/firestore/src/demo/SetDocument.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import { FirestoreDocument, FirestoreMutation } from "../";
3 | import { testDocPath, testDocValue, s } from "./App";
4 | export const SetDocument = () => (
5 |
6 |
7 | {({ runMutation }) => {
8 | return (
9 |
17 | );
18 | }}
19 |
20 |
21 |
22 |
23 | {d =>
24 | d.value ? (
25 | {s(d.value)}
26 | ) : null
27 | }
28 |
29 |
30 |
31 | );
32 |
--------------------------------------------------------------------------------
/modules/firestore/src/demo/UpdateDocument.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import { FirestoreDocument, FirestoreMutation } from "../";
3 | import { testDocPath, testDocUpdate, s } from "./App";
4 | export const UpdateDocument = () => (
5 |
6 |
7 | {({ runMutation }) => (
8 |
16 | )}
17 |
18 |
19 |
20 | {d =>
21 | d.value && d.value.someOther ? (
22 | {s(d.value)}
23 | ) : null
24 | }
25 |
26 |
27 |
28 | );
29 |
--------------------------------------------------------------------------------
/modules/firestore/src/demo/firestore-schema.js:
--------------------------------------------------------------------------------
1 | // For use with generate-firestore-data
2 | const keyReducers = {};
3 |
4 | const schema = {
5 | // "{env}": {
6 | user_conversations: {
7 | "{conversationID}": {
8 | user_id: "{userID}",
9 | peer_id: "{peerID}",
10 | conversation_id: "{conversationID}",
11 | created_at: "timestamp",
12 | updated_at: "timestamp",
13 | unread_message_count: "number"
14 | }
15 | },
16 | messages: {
17 | "{messageID}": {
18 | conversation_id: "{conversationID}",
19 | sender_id: "{userID}",
20 | recipient_id: "{peerID}",
21 | created_at: "timestamp",
22 | updated_at: "timestamp"
23 | }
24 | }
25 | };
26 |
27 | const count = 20;
28 | module.exports = {
29 | schema,
30 | keyReducers,
31 | count
32 | };
33 |
--------------------------------------------------------------------------------
/modules/firestore/src/demo/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/modules/firestore/src/demo/index.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import { render } from "react-dom";
3 | import { App } from "./App";
4 | render(, document.getElementById("root"));
5 |
--------------------------------------------------------------------------------
/modules/firestore/src/demo/test-credentials.ts:
--------------------------------------------------------------------------------
1 | export const config = {
2 | apiKey: "AIzaSyBIEgdW0FGGxQZ7bbbqIhzmiVAk7nnJB14",
3 | authDomain: "react-firebase-baecd.firebaseapp.com",
4 | databaseURL: "https://react-firebase-baecd.firebaseio.com",
5 | projectId: "react-firebase-baecd",
6 | storageBucket: "react-firebase-baecd.appspot.com",
7 | messagingSenderId: "6611069556"
8 | };
9 |
--------------------------------------------------------------------------------
/modules/firestore/src/index.tsx:
--------------------------------------------------------------------------------
1 | export { FirestoreCollection } from "./components/FirestoreCollection";
2 | export { FirestoreDocument } from "./components/FirestoreDocument";
3 | export { FirestoreProvider } from "./components/FirestoreProvider";
4 |
5 | export { FirestoreMutation } from "./components/FirestoreMutation";
6 | export { FirestoreBatchedWrite } from "./components/FirestoreBatchedWrite";
7 | export { FirestoreTransaction } from "./components/FirestoreTransaction";
8 |
--------------------------------------------------------------------------------
/modules/firestore/src/initialize-firebase-app.ts:
--------------------------------------------------------------------------------
1 | import { InitializeAppArgs } from "./types";
2 | export const initializeFirebaseApp = ({
3 | firebase,
4 | authDomain,
5 | databaseURL,
6 | projectId,
7 | storageBucket,
8 | messagingSenderId,
9 | apiKey,
10 | appId,
11 | measurementId
12 | }: InitializeAppArgs) => {
13 | try {
14 | firebase.initializeApp({
15 | apiKey,
16 | authDomain,
17 | databaseURL,
18 | projectId,
19 | storageBucket,
20 | messagingSenderId,
21 | appId,
22 | measurementId
23 | });
24 | } catch (err) {
25 | if (err.code !== "app/duplicate-app") {
26 | throw err;
27 | }
28 | }
29 | };
30 |
--------------------------------------------------------------------------------
/modules/firestore/src/test-utils.ts:
--------------------------------------------------------------------------------
1 | import * as firebase from "firebase/app";
2 | import "firebase/firestore";
3 | import memoize from "lodash/memoize";
4 | import { config } from "./demo/test-credentials";
5 | import { initializeFirebaseApp } from "./initialize-firebase-app";
6 | import { getFirestoreQuery } from "./get-firestore-query";
7 | import { DocumentReference } from "@google-cloud/firestore";
8 |
9 | const testCollectionPath = "user_bookmarks";
10 | const testDocPath = `${testCollectionPath}/TEST_USER_ID`;
11 |
12 | export const initFirebase = () => {};
13 | export const getFirestore = memoize(
14 | (conf = config) => {
15 | initializeFirebaseApp({ ...conf, firebase });
16 | const firestore = firebase.firestore();
17 | const settings = { timestampsInSnapshots: true };
18 | firestore.settings(settings);
19 | return firestore;
20 | },
21 | () => 1
22 | );
23 |
24 | export const deleteValueAtPath = async (path: string) => {
25 | const firestore = getFirestore();
26 | const ref = getFirestoreQuery({ firestore, path }) as DocumentReference;
27 | await ref.delete();
28 | return path;
29 | };
30 | export const getValueAtPath = async (path: string) => {
31 | const firestore = getFirestore();
32 | const ref = getFirestoreQuery({ firestore, path }) as DocumentReference;
33 | const val = await ref.get();
34 | return val && val.data();
35 | };
36 |
37 | export const setValueAtPath = async (path: string, value: any) => {
38 | const firestore = getFirestore();
39 | const ref = getFirestoreQuery({ firestore, path }) as DocumentReference;
40 | const val = await ref.set(value, { merge: true });
41 | return val;
42 | };
43 |
44 | export const before = async (path = testDocPath) => {
45 | await deleteValueAtPath(path);
46 | const val = await getValueAtPath(path);
47 | // expect(val).toEqual(undefined);
48 | await setValueAtPath(path, { c: "d" });
49 | };
50 |
51 | export const after = async (path = testDocPath) => {
52 | await deleteValueAtPath(path);
53 | };
54 |
--------------------------------------------------------------------------------
/modules/firestore/src/types.ts:
--------------------------------------------------------------------------------
1 | import { DocumentSnapshot } from "@google-cloud/firestore";
2 | export type OrNull = T | null;
3 |
4 | export type PrimitiveType = number | boolean | string;
5 |
6 | export type FirestoreQuery = {
7 | path: OrNull;
8 | where?: OrNull<{
9 | field: string;
10 | operator: "<" | "<=" | "==" | ">" | ">=" | "array-contains";
11 | value: any;
12 | }>;
13 | orderBy?: OrNull<{ field: string; type?: "desc" | "asc" }[]>;
14 | limit?: OrNull;
15 | startAt?: OrNull;
16 | endAt?: OrNull;
17 | startAfter?: OrNull;
18 | endBefore?: OrNull;
19 | };
20 |
21 | export type FirestoreNodeValue = {} | number | boolean | string | null;
22 |
23 | export type FirestoreProviderState = {
24 | firebase: any;
25 | firestore: firebase.firestore.Firestore;
26 | dataTree: {
27 | [path: string]: {
28 | isLoading: boolean;
29 | value: FirestoreNodeValue[];
30 | unsub: () => void;
31 | };
32 | };
33 | listenTo: (
34 | query: FirestoreQuery,
35 | documentOrCollection: "document" | "collection"
36 | ) => void;
37 | stopListeningTo: (path: string) => void;
38 | };
39 |
40 | export type FirestoreContextConsumerWithLifeCycleProps = {} & FirestoreProviderState &
41 | FirestoreQuery;
42 |
43 | export type FirestoreNodeValueContainer = {
44 | val: () => FirestoreNodeValue;
45 | };
46 |
47 | export interface InitializeAppArgs {
48 | authDomain: string;
49 | apiKey: string;
50 | databaseURL: string;
51 | firebase: any;
52 | projectId: string;
53 | messagingSenderId?: string;
54 | storageBucket?: string;
55 | appId?: string;
56 | measurementId?: string;
57 | }
58 |
59 | export type FirestoreProviderProps = InitializeAppArgs;
60 |
--------------------------------------------------------------------------------
/modules/firestore/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "include": ["./src/"],
3 | "compilerOptions": {
4 | "jsx": "react",
5 | "target": "es5",
6 | "module": "commonjs",
7 | "moduleResolution": "node",
8 | "lib": ["es2018", "dom"],
9 | "outDir": "./build/",
10 | "strict": true,
11 | "declaration": true,
12 | "removeComments": true,
13 | "esModuleInterop": true,
14 | "allowSyntheticDefaultImports": true
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/modules/generate-firebase-data/.gitignore:
--------------------------------------------------------------------------------
1 | .rpt2_cache
2 | .vscode
3 | build/
4 | node_modules/
5 | dist/
6 | src/test-credentials.ts
--------------------------------------------------------------------------------
/modules/generate-firebase-data/README.md:
--------------------------------------------------------------------------------
1 | # generate-firebase-data
2 |
3 | ## [Docs](https://react-firebase-js.com/docs/generate-firebase-data)
4 |
--------------------------------------------------------------------------------
/modules/generate-firebase-data/example-schemas/schema-one.js:
--------------------------------------------------------------------------------
1 | const keyReducers = {
2 | "{env}": fakerjs => {
3 | return fakerjs.random.arrayElement(["staging"]);
4 | return fakerjs.random.arrayElement(["prod", "staging"]);
5 | },
6 | "{userID}": fakerjs => {
7 | return fakerjs.random.alphaNumeric(5);
8 | },
9 | "{postID}": fakerjs => {
10 | return fakerjs.random.alphaNumeric(5);
11 | }
12 | };
13 |
14 | const schema = {
15 | "{env}": {
16 | users: {
17 | "{userID}": {
18 | comment_count: "number",
19 | username: "string",
20 | is_verified: "boolean",
21 | created_at: "timestamp"
22 | }
23 | },
24 | posts: {
25 | "{postID}": {
26 | post_title: "string",
27 | post_data: (faker, key) => {
28 | // return faker.random.words(5)
29 | return key.split("/").join("-") + ":post_data";
30 | },
31 | author_id: "{userID}",
32 | created_at: "timestamp"
33 | }
34 | },
35 | comments: {
36 | "{postID}": {
37 | "{commentID}": {
38 | value: "👍",
39 | userID: "{userID}"
40 | }
41 | }
42 | }
43 | }
44 | };
45 |
46 | const count = 5;
47 | module.exports = {
48 | schema,
49 | keyReducers,
50 | count
51 | };
52 |
--------------------------------------------------------------------------------
/modules/generate-firebase-data/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "generate-firebase-data",
3 | "version": "0.1.4",
4 | "main": "dist/index.js",
5 | "module": "dist/index.esm.js",
6 | "jsnext:main": "dist/index.esm.js",
7 | "types": "dist/index.d.ts",
8 | "license": "GPL-3.0-only",
9 | "scripts": {
10 | "dev": "tsc && (concurrently --kill-others \"tsc --watch\" \"nodemon build/index.js\")",
11 | "build": "rollup -c",
12 | "prepublish": "yarn build",
13 | "test": "tsc && node build/test.js"
14 | },
15 | "devDependencies": {
16 | "@types/lodash.chunk": "^4.2.4",
17 | "concurrently": "^3.6.1",
18 | "prettier": "^1.14.2",
19 | "rollup": "^0.64.1",
20 | "rollup-plugin-typescript2": "^0.16.1",
21 | "typescript": "^3.0.1"
22 | },
23 | "dependencies": {
24 | "chunk-and-parallelize": "^0.1.1",
25 | "firebase-admin": "^6.0.0",
26 | "generate-json": "^0.2.2",
27 | "lodash.chunk": "^4.2.0"
28 | },
29 | "files": [
30 | "dist/"
31 | ],
32 | "author": {
33 | "name": "rakannimer",
34 | "email": "rakannimer@gmail.com"
35 | },
36 | "keywords": [
37 | "firebase",
38 | "mock",
39 | "data",
40 | "generate",
41 | "json",
42 | "schema"
43 | ]
44 | }
45 |
--------------------------------------------------------------------------------
/modules/generate-firebase-data/rollup.config.js:
--------------------------------------------------------------------------------
1 | import typescript from "rollup-plugin-typescript2";
2 |
3 | export default [
4 | {
5 | input: "src/index.ts",
6 | output: [
7 | {
8 | file: "dist/index.umd.js",
9 | format: "umd",
10 | name: "JsonDataGenerator"
11 | },
12 | {
13 | file: "dist/index.esm.js",
14 | format: "esm"
15 | },
16 | {
17 | file: "dist/index.js",
18 | format: "cjs"
19 | }
20 | ],
21 | external: ["faker", "flat", "lodash.chunk", "mkdirp", "mri"],
22 | plugins: [
23 | typescript({
24 | typescript: require("typescript"),
25 | abortOnError: false,
26 | tsconfigOverride: {
27 | compilerOptions: {
28 | module: "esnext"
29 | }
30 | }
31 | })
32 | ]
33 | },
34 | {
35 | input: "src/cli.ts",
36 | output: [
37 | {
38 | banner: "#!/usr/bin/env node",
39 | file: "dist/cli.esm.js",
40 | format: "esm"
41 | },
42 | {
43 | banner: "#!/usr/bin/env node",
44 | file: "dist/cli.cjs.js",
45 | format: "cjs"
46 | }
47 | ],
48 | external: ["lru-cache", "document", "store2"],
49 | plugins: [
50 | typescript({
51 | typescript: require("typescript"),
52 | abortOnError: false,
53 | tsconfigOverride: {
54 | compilerOptions: {
55 | module: "esnext"
56 | }
57 | }
58 | })
59 | ]
60 | }
61 | ];
62 |
--------------------------------------------------------------------------------
/modules/generate-firebase-data/src/cli.ts:
--------------------------------------------------------------------------------
1 | const mri = require("mri");
2 | const fs = require("fs");
3 | const firebase = require("firebase-admin");
4 | const { generateFirebaseData } = require("./index");
5 | const pkg = require("../package.json");
6 |
7 | const main = async () => {
8 | console.log(`
9 | Version : ${pkg.version}
10 | `);
11 |
12 | const args = process.argv.slice(2);
13 |
14 | const { _ } = mri(args);
15 |
16 | if (_.length < 2) {
17 | throw new Error(
18 | `Expected 2 arguments, `
19 | );
20 | }
21 |
22 | const [schemaFilePath, credentialsFilePath] = _;
23 | const schemaFile = require(`${process.cwd()}/${schemaFilePath}`);
24 | const credentialsFile = require(`${process.cwd()}/${credentialsFilePath}`);
25 |
26 | const { schema, keyReducers, count } = schemaFile;
27 | const { credential, databaseURL } = credentialsFile;
28 | console.log("Generating Data");
29 | await generateFirebaseData(
30 | { schema, keyReducers, count },
31 | { credential, databaseURL, firebase }
32 | );
33 | console.log("Done");
34 | process.exit(0);
35 | };
36 | (async () => {
37 | await main();
38 | })();
39 |
--------------------------------------------------------------------------------
/modules/generate-firebase-data/src/test.ts:
--------------------------------------------------------------------------------
1 | import firebase from "firebase-admin";
2 | import { credentials } from "./test-credentials";
3 | import { generateFirebaseData } from "./index";
4 | {
5 | const main = async () => {
6 | await generateFirebaseData(
7 | {
8 | schema: {
9 | user_bookmarks: {
10 | "{userID}": {
11 | user_id: "{userID}",
12 | name: "string",
13 | created_on: "timestamp"
14 | }
15 | }
16 | },
17 | count: 25
18 | },
19 | {
20 | databaseURL: credentials.databaseURL,
21 | credential: credentials.credential,
22 | firebase
23 | }
24 | );
25 | };
26 |
27 | if (require.main === module) {
28 | (async () => {
29 | await main();
30 | process.exit(0);
31 | })();
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/modules/generate-firebase-data/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "include": ["./src/"],
3 | "compilerOptions": {
4 | "target": "esnext",
5 | "skipLibCheck": true,
6 | "module": "commonjs",
7 | "moduleResolution": "node",
8 | "lib": ["es2018"],
9 | "outDir": "./build/",
10 | "strict": true,
11 | "declaration": true,
12 | "removeComments": true,
13 | "esModuleInterop": true
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/modules/generate-firestore-data/.gitignore:
--------------------------------------------------------------------------------
1 | .rpt2_cache
2 | .vscode
3 | build/
4 | node_modules/
5 | dist/
6 | src/test-credentials.ts
--------------------------------------------------------------------------------
/modules/generate-firestore-data/README.md:
--------------------------------------------------------------------------------
1 | # generate-firestore-data
2 |
3 | ## [Docs](https://react-firebase-js.com/docs/generate-firestore-data)
4 |
--------------------------------------------------------------------------------
/modules/generate-firestore-data/example-schemas/schema-one.js:
--------------------------------------------------------------------------------
1 | const keyReducers = {
2 | // "{env}": fakerjs => {
3 | // return fakerjs.random.arrayElement(["staging"]);
4 | // return fakerjs.random.arrayElement(["prod", "staging"]);
5 | // },
6 | // "{userID}": fakerjs => {
7 | // return fakerjs.random.alphaNumeric(5);
8 | // },
9 | // "{postID}": fakerjs => {
10 | // return fakerjs.random.alphaNumeric(5);
11 | // }
12 | };
13 |
14 | const schema = {
15 | // "{env}": {
16 | user_conversations: {
17 | "{conversationID}": {
18 | user_id: "{userID}",
19 | peer_id: "{peerID}",
20 | conversation_id: "{conversationID}",
21 | created_at: "timestamp",
22 | updated_at: "timestamp",
23 | unread_message_count: "number"
24 | }
25 | },
26 | messages: {
27 | "{messageID}": {
28 | conversation_id: "{conversationID}",
29 | sender_id: "{userID}",
30 | peer_id: "{peerID}",
31 | created_at: "timestamp",
32 | updated_at: "timestamp"
33 | }
34 | }
35 | };
36 |
37 | const count = 20;
38 | module.exports = {
39 | schema,
40 | keyReducers,
41 | count
42 | };
43 |
--------------------------------------------------------------------------------
/modules/generate-firestore-data/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "generate-firestore-data",
3 | "version": "0.1.7",
4 | "main": "dist/index.js",
5 | "module": "dist/index.esm.js",
6 | "jsnext:main": "dist/index.esm.js",
7 | "types": "dist/index.d.ts",
8 | "license": "GPL-3.0-only",
9 | "bin": {
10 | "generate-firestore-data": "./dist/cli.cjs.js"
11 | },
12 | "repository": {
13 | "url": "https://github.com/rakannimer/generate-firestore-data"
14 | },
15 | "scripts": {
16 | "dev": "tsc && (concurrently --kill-others \"tsc --watch\" \"nodemon build/index.js\")",
17 | "build": "rollup -c",
18 | "prepublish": "yarn build"
19 | },
20 | "devDependencies": {
21 | "concurrently": "^3.6.1",
22 | "prettier": "^1.14.2",
23 | "rollup": "^0.64.1",
24 | "rollup-plugin-typescript2": "^0.16.1",
25 | "typescript": "^3.0.1"
26 | },
27 | "dependencies": {
28 | "firebase-admin": "^6.0.0",
29 | "generate-json": "^0.2.2"
30 | },
31 | "files": [
32 | "dist/"
33 | ],
34 | "author": {
35 | "name": "rakannimer",
36 | "email": "rakannimer@gmail.com"
37 | },
38 | "keywords": [
39 | "firebase",
40 | "firestore",
41 | "mock",
42 | "data",
43 | "generate",
44 | "json",
45 | "schema"
46 | ]
47 | }
48 |
--------------------------------------------------------------------------------
/modules/generate-firestore-data/rollup.config.js:
--------------------------------------------------------------------------------
1 | import typescript from "rollup-plugin-typescript2";
2 |
3 | export default [
4 | {
5 | input: "src/index.ts",
6 | output: [
7 | {
8 | file: "dist/index.esm.js",
9 | format: "esm"
10 | },
11 | {
12 | file: "dist/index.js",
13 | format: "cjs"
14 | }
15 | ],
16 | external: ["chunk-and-parallelize"],
17 | plugins: [
18 | typescript({
19 | typescript: require("typescript"),
20 | abortOnError: false,
21 | tsconfigOverride: {
22 | compilerOptions: {
23 | module: "esnext"
24 | }
25 | }
26 | })
27 | ]
28 | },
29 | {
30 | input: "src/cli.ts",
31 | output: [
32 | {
33 | banner: "#!/usr/bin/env node",
34 | file: "dist/cli.esm.js",
35 | format: "esm"
36 | },
37 | {
38 | banner: "#!/usr/bin/env node",
39 | file: "dist/cli.cjs.js",
40 | format: "cjs"
41 | }
42 | ],
43 | external: ["lru-cache", "document", "store2"],
44 | plugins: [
45 | typescript({
46 | typescript: require("typescript"),
47 | abortOnError: false,
48 | tsconfigOverride: {
49 | compilerOptions: {
50 | module: "esnext"
51 | }
52 | }
53 | })
54 | ]
55 | }
56 | ];
57 |
--------------------------------------------------------------------------------
/modules/generate-firestore-data/src/cli.ts:
--------------------------------------------------------------------------------
1 | const mri = require("mri");
2 | const fs = require("fs");
3 | const firebase = require("firebase-admin");
4 | const { generateFirestoreData } = require("./index");
5 | const pkg = require("../package.json");
6 |
7 | const main = async () => {
8 | console.log(`
9 | Version : ${pkg.version}
10 | `);
11 |
12 | const args = process.argv.slice(2);
13 |
14 | const { _ } = mri(args);
15 |
16 | if (_.length < 2) {
17 | throw new Error(
18 | `Expected 2 arguments, `
19 | );
20 | }
21 |
22 | const [schemaFilePath, credentialsFilePath] = _;
23 | const schemaFile = require(`${process.cwd()}/${schemaFilePath}`);
24 | const credentialsFile = require(`${process.cwd()}/${credentialsFilePath}`);
25 |
26 | const { schema, keyReducers, count } = schemaFile;
27 | const { credential, databaseURL } = credentialsFile;
28 | console.log("Generating Data");
29 | await generateFirestoreData(
30 | { schema, keyReducers, count },
31 | { credential, databaseURL, firebase }
32 | );
33 | console.log("Done");
34 | process.exit(0);
35 | };
36 | (async () => {
37 | await main();
38 | })();
39 |
--------------------------------------------------------------------------------
/modules/generate-firestore-data/src/test.ts:
--------------------------------------------------------------------------------
1 | import * as firebase from "firebase-admin";
2 | import { credentials } from "./test-credentials";
3 | import { generateFirestoreData } from "./index";
4 |
5 | const main = async () => {
6 | await generateFirestoreData(
7 | {
8 | schema: {
9 | user_bookmarks: {
10 | "{userID}": {
11 | user_id: "{userID}",
12 | name: "string",
13 | created_on: "timestamp"
14 | }
15 | }
16 | },
17 | count: 5
18 | },
19 | {
20 | databaseURL: credentials.databaseURL,
21 | credential: credentials.credential,
22 | firebase
23 | }
24 | );
25 | };
26 |
27 | if (require.main === module) {
28 | (async () => {
29 | await main();
30 | })();
31 | }
32 |
--------------------------------------------------------------------------------
/modules/generate-firestore-data/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "include": ["./src/"],
3 | "compilerOptions": {
4 | "target": "esnext",
5 | "module": "commonjs",
6 | "moduleResolution": "node",
7 | "lib": ["es2018"],
8 | "outDir": "./build/",
9 | "strict": true,
10 | "declaration": true,
11 | "removeComments": true,
12 | "esModuleInterop": true
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/modules/generate-json/.gitignore:
--------------------------------------------------------------------------------
1 | .vscode
2 | .rpt2_cache
3 | dist
4 | src/test-credentials.ts
5 | node_modules
6 | build
7 | src/parser
8 | coverage
--------------------------------------------------------------------------------
/modules/generate-json/README.md:
--------------------------------------------------------------------------------
1 | # generate-json
2 |
3 | ## [Docs](https://react-firebase-js.com/docs/generate-json-data)
4 |
--------------------------------------------------------------------------------
/modules/generate-json/__tests__/generate-data.test.ts:
--------------------------------------------------------------------------------
1 | // import { generateData } from "../dist/index.cjs";
2 | import { generateData } from "../src/";
3 |
4 | import faker from "faker";
5 |
6 | const SEED = 42;
7 |
8 | const keyReducers = [
9 | {
10 | "{env}": (fakerjs: typeof faker) => {
11 | return fakerjs.random.arrayElement(["prod", "staging"]);
12 | },
13 | "{userID}": (fakerjs: typeof faker) => {
14 | return fakerjs.random.alphaNumeric(5);
15 | },
16 | "{postID}": (fakerjs: typeof faker) => {
17 | return fakerjs.random.alphaNumeric(5);
18 | }
19 | }
20 | ];
21 |
22 | const schemas = [
23 | {
24 | "{env}": {
25 | users: {
26 | "{userID}": {
27 | comment_count: "number",
28 | username: "string",
29 | is_verified: "boolean",
30 | created_at: "timestamp"
31 | }
32 | },
33 | posts: {
34 | "{postID}": {
35 | post_title: "string",
36 | post_data: (faker, key) => {
37 | // return faker.random.words(5)
38 | return key.split("/").join("-") + ":post_data";
39 | },
40 | author_id: "{userID}",
41 | created_at: "timestamp"
42 | }
43 | },
44 | comments: {
45 | "{postID}": {
46 | "{commentID}": {
47 | value: "👍",
48 | userID: "{userID}"
49 | }
50 | }
51 | }
52 | }
53 | }
54 | ];
55 |
56 | for (let i = 0; i < schemas.length; i += 1) {
57 | const schema = schemas[0];
58 | const keyReducer = keyReducers[i];
59 | test("generateData works without second argument", async () => {
60 | faker.seed(SEED);
61 | const data = await generateData(schema);
62 | expect(data).toMatchSnapshot();
63 | });
64 |
65 | test("generateData works with second argument", async () => {
66 | faker.seed(SEED);
67 | const data = await generateData(schema, keyReducer);
68 | // console.log(data);
69 | expect(data).toMatchSnapshot();
70 | });
71 | }
72 |
--------------------------------------------------------------------------------
/modules/generate-json/__tests__/generate-json.test.ts:
--------------------------------------------------------------------------------
1 | import { generateJson } from "../src/";
2 |
3 | import faker from "faker";
4 |
5 | const SEED = 42;
6 |
7 | const keyReducers = [
8 | {
9 | "{env}": (fakerjs: typeof faker) => {
10 | return fakerjs.random.arrayElement(["prod", "staging"]);
11 | },
12 | "{userID}": (fakerjs: typeof faker) => {
13 | return fakerjs.random.alphaNumeric(5);
14 | },
15 | "{postID}": (fakerjs: typeof faker) => {
16 | return fakerjs.random.alphaNumeric(5);
17 | }
18 | }
19 | ];
20 |
21 | const schemas = [
22 | {
23 | "{env}": {
24 | users: {
25 | "{userID}": {
26 | comment_count: "number",
27 | username: "string",
28 | is_verified: "boolean",
29 | created_at: "timestamp"
30 | }
31 | },
32 | posts: {
33 | "{postID}": {
34 | post_title: "string",
35 | post_data: (faker, key) => {
36 | // return faker.random.words(5)
37 | return key.split("/").join("-") + ":post_data";
38 | },
39 | author_id: "{userID}",
40 | created_at: "timestamp"
41 | }
42 | },
43 | comments: {
44 | "{postID}": {
45 | "{commentID}": {
46 | value: "👍",
47 | userID: "{userID}"
48 | }
49 | }
50 | }
51 | }
52 | }
53 | ];
54 |
55 | for (let i = 0; i < schemas.length; i += 1) {
56 | const schema = schemas[0];
57 | const keyReducer = keyReducers[i];
58 | test("generateJson works with all arguments", async () => {
59 | faker.seed(SEED);
60 | const data = await generateJson({
61 | schema,
62 | keyReducers: keyReducer,
63 | count: 3
64 | });
65 | expect(data).toMatchSnapshot();
66 | });
67 | test("generateJson works without keyReducers", async () => {
68 | faker.seed(SEED);
69 | const data = await generateJson({ schema, count: 3 });
70 | expect(data).toMatchSnapshot();
71 | });
72 |
73 | test("generateJson works without keyReducers & without count", async () => {
74 | faker.seed(SEED);
75 | const data = await generateJson({ schema });
76 | expect(data).toMatchSnapshot();
77 | });
78 | }
79 |
--------------------------------------------------------------------------------
/modules/generate-json/example-schemas-output/keys.json:
--------------------------------------------------------------------------------
1 | [
2 | "staging.users.0qhv3.comment_count",
3 | "staging.users.0qhv3.username",
4 | "staging.users.0qhv3.is_verified",
5 | "staging.users.0qhv3.created_at",
6 | "staging.posts.jby4v.post_title",
7 | "staging.posts.jby4v.post_data",
8 | "staging.posts.jby4v.author_id",
9 | "staging.posts.jby4v.created_at",
10 | "staging.comments.jby4v.G_K_1y3ll.value",
11 | "staging.comments.jby4v.G_K_1y3ll.userID",
12 | "staging.users.4oir7.comment_count",
13 | "staging.users.4oir7.username",
14 | "staging.users.4oir7.is_verified",
15 | "staging.users.4oir7.created_at",
16 | "staging.posts.xynjh.post_title",
17 | "staging.posts.xynjh.post_data",
18 | "staging.posts.xynjh.author_id",
19 | "staging.posts.xynjh.created_at",
20 | "staging.comments.xynjh.G_K_pc8mr.value",
21 | "staging.comments.xynjh.G_K_pc8mr.userID",
22 | "staging.users.av66d.comment_count",
23 | "staging.users.av66d.username",
24 | "staging.users.av66d.is_verified",
25 | "staging.users.av66d.created_at",
26 | "staging.posts.fic95.post_title",
27 | "staging.posts.fic95.post_data",
28 | "staging.posts.fic95.author_id",
29 | "staging.posts.fic95.created_at",
30 | "staging.comments.fic95.G_K_ruuca.value",
31 | "staging.comments.fic95.G_K_ruuca.userID",
32 | "prod.users.gezfx.comment_count",
33 | "prod.users.gezfx.username",
34 | "prod.users.gezfx.is_verified",
35 | "prod.users.gezfx.created_at",
36 | "prod.posts.1tqgq.post_title",
37 | "prod.posts.1tqgq.post_data",
38 | "prod.posts.1tqgq.author_id",
39 | "prod.posts.1tqgq.created_at",
40 | "prod.comments.1tqgq.G_K_h8fad.value",
41 | "prod.comments.1tqgq.G_K_h8fad.userID",
42 | "prod.users.asgj4.comment_count",
43 | "prod.users.asgj4.username",
44 | "prod.users.asgj4.is_verified",
45 | "prod.users.asgj4.created_at",
46 | "prod.posts.7qdzk.post_title",
47 | "prod.posts.7qdzk.post_data",
48 | "prod.posts.7qdzk.author_id",
49 | "prod.posts.7qdzk.created_at",
50 | "prod.comments.7qdzk.G_K_ibz9j.value",
51 | "prod.comments.7qdzk.G_K_ibz9j.userID"
52 | ]
53 |
--------------------------------------------------------------------------------
/modules/generate-json/example-schemas-output/tree.json:
--------------------------------------------------------------------------------
1 | {
2 | "prod": {
3 | "users": {
4 | "gezfx": {
5 | "comment_count": 3029,
6 | "username": "Samoa Re-contextualized",
7 | "is_verified": true,
8 | "created_at": 11798300906
9 | }
10 | },
11 | "posts": {
12 | "1tqgq": {
13 | "post_title": "invoice Table",
14 | "post_data": "prod.posts.1tqgq.post_data:post_data",
15 | "author_id": "gezfx",
16 | "created_at": 4564016078
17 | }
18 | },
19 | "comments": {
20 | "1tqgq": { "G_K_h8fad": { "value": "👍", "userID": "gezfx" } }
21 | }
22 | },
23 | "staging": {
24 | "users": {
25 | "0qhv3": {
26 | "comment_count": 70664,
27 | "username": "lime wireless",
28 | "is_verified": true,
29 | "created_at": 20897831556
30 | }
31 | },
32 | "posts": {
33 | "jby4v": {
34 | "post_title": "Internal Solutions",
35 | "post_data": "staging.posts.jby4v.post_data:post_data",
36 | "author_id": "0qhv3",
37 | "created_at": 21197960372
38 | }
39 | },
40 | "comments": {
41 | "jby4v": { "G_K_1y3ll": { "value": "👍", "userID": "0qhv3" } }
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/modules/generate-json/example-schemas-output/values.json:
--------------------------------------------------------------------------------
1 | [
2 | 70664,
3 | "lime wireless",
4 | true,
5 | 20897831556,
6 | "Internal Solutions",
7 | "staging.posts.jby4v.post_data:post_data",
8 | "0qhv3",
9 | 21197960372,
10 | "👍",
11 | "0qhv3",
12 | 49866,
13 | "e-services Intelligent",
14 | false,
15 | 25444140329,
16 | "Buckinghamshire copy",
17 | "staging.posts.xynjh.post_data:post_data",
18 | "4oir7",
19 | 13636525450,
20 | "👍",
21 | "4oir7",
22 | 27856,
23 | "Granite Compatible",
24 | false,
25 | 5308007871,
26 | "Liaison silver",
27 | "staging.posts.fic95.post_data:post_data",
28 | "av66d",
29 | 29230917924,
30 | "👍",
31 | "av66d",
32 | 3029,
33 | "Samoa Re-contextualized",
34 | true,
35 | 11798300906,
36 | "invoice Table",
37 | "prod.posts.1tqgq.post_data:post_data",
38 | "gezfx",
39 | 4564016078,
40 | "👍",
41 | "gezfx",
42 | 16534,
43 | "generate Handcrafted Fresh Ball",
44 | false,
45 | 26764639016,
46 | "Seamless Ergonomic Wooden Shirt",
47 | "prod.posts.7qdzk.post_data:post_data",
48 | "asgj4",
49 | 14946899903,
50 | "👍",
51 | "asgj4"
52 | ]
53 |
--------------------------------------------------------------------------------
/modules/generate-json/example-schemas/schema-one.js:
--------------------------------------------------------------------------------
1 | const keyReducers = {
2 | "{env}": fakerjs => {
3 | return fakerjs.random.arrayElement(["prod", "staging"]);
4 | },
5 | "{userID}": fakerjs => {
6 | return fakerjs.random.alphaNumeric(5);
7 | },
8 | "{postID}": fakerjs => {
9 | return fakerjs.random.alphaNumeric(5);
10 | }
11 | };
12 |
13 | const schema = {
14 | "{env}": {
15 | users: {
16 | "{userID}": {
17 | comment_count: "number",
18 | username: "string",
19 | is_verified: "boolean",
20 | created_at: "timestamp"
21 | }
22 | },
23 | posts: {
24 | "{postID}": {
25 | post_title: "string",
26 | post_data: (faker, key) => {
27 | // return faker.random.words(5)
28 | return key.split("/").join("-") + ":post_data";
29 | },
30 | author_id: "{userID}",
31 | created_at: "timestamp"
32 | }
33 | },
34 | comments: {
35 | "{postID}": {
36 | "{commentID}": {
37 | value: "👍",
38 | userID: "{userID}"
39 | }
40 | }
41 | }
42 | }
43 | };
44 |
45 | const count = 5;
46 | module.exports = {
47 | schema,
48 | keyReducers,
49 | count
50 | };
51 |
--------------------------------------------------------------------------------
/modules/generate-json/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "generate-json",
3 | "version": "0.2.2",
4 | "main": "dist/index.js",
5 | "module": "dist/index.esm.js",
6 | "jsnext:main": "dist/index.esm.js",
7 | "umd": "dist/index.umd.js",
8 | "types": "dist/index.d.ts",
9 | "license": "MIT",
10 | "scripts": {
11 | "build": "rollup -c",
12 | "dev": "jest --watch",
13 | "test": "jest --coverage",
14 | "prepublish": "yarn test && yarn build"
15 | },
16 | "bin": {
17 | "generate-json": "dist/cli.cjs.js"
18 | },
19 | "dependencies": {
20 | "chunk-and-parallelize": "^0.1.1",
21 | "faker": "^4.1.0",
22 | "flat": "^4.1.0",
23 | "lodash.set": "^4.3.2",
24 | "mkdirp": "^0.5.1",
25 | "mri": "^1.1.1"
26 | },
27 | "devDependencies": {
28 | "@types/faker": "^4.1.3",
29 | "@types/flat": "^0.0.28",
30 | "@types/jest": "^23.3.1",
31 | "@types/lodash.set": "^4.3.4",
32 | "jest": "^23.5.0",
33 | "prettier": "^1.14.2",
34 | "rollup": "^0.64.1",
35 | "rollup-plugin-typescript2": "^0.16.1",
36 | "ts-jest": "^23.1.3",
37 | "typescript": "^3.0.1"
38 | },
39 | "files": [
40 | "dist/"
41 | ],
42 | "jest": {
43 | "transform": {
44 | "^.+\\.ts$": "ts-jest"
45 | },
46 | "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
47 | "moduleFileExtensions": [
48 | "ts",
49 | "tsx",
50 | "js",
51 | "jsx",
52 | "json",
53 | "node"
54 | ]
55 | },
56 | "keywords": [
57 | "fake-data",
58 | "mock",
59 | "data",
60 | "generate",
61 | "json",
62 | "schema"
63 | ]
64 | }
65 |
--------------------------------------------------------------------------------
/modules/generate-json/rollup.config.js:
--------------------------------------------------------------------------------
1 | import typescript from "rollup-plugin-typescript2";
2 |
3 | export default [
4 | {
5 | input: "src/index.ts",
6 | output: [
7 | {
8 | file: "dist/index.umd.js",
9 | format: "umd",
10 | name: "JsonDataGenerator"
11 | },
12 | {
13 | file: "dist/index.esm.js",
14 | format: "esm"
15 | },
16 | {
17 | file: "dist/index.js",
18 | format: "cjs"
19 | }
20 | ],
21 | external: ["faker", "flat", "lodash.set", "mkdirp", "mri"],
22 | plugins: [
23 | typescript({
24 | typescript: require("typescript"),
25 | abortOnError: false,
26 | tsconfigOverride: {
27 | compilerOptions: {
28 | module: "esnext"
29 | }
30 | }
31 | })
32 | ]
33 | },
34 | {
35 | input: "src/cli.ts",
36 | output: [
37 | {
38 | banner: "#!/usr/bin/env node",
39 | file: "dist/cli.esm.js",
40 | format: "esm"
41 | },
42 | {
43 | banner: "#!/usr/bin/env node",
44 | file: "dist/cli.cjs.js",
45 | format: "cjs"
46 | }
47 | ],
48 | external: ["lru-cache", "document", "store2"],
49 | plugins: [
50 | typescript({
51 | typescript: require("typescript"),
52 | abortOnError: false,
53 | tsconfigOverride: {
54 | compilerOptions: {
55 | module: "esnext"
56 | }
57 | }
58 | })
59 | ]
60 | }
61 | ];
62 |
--------------------------------------------------------------------------------
/modules/generate-json/src/cli.ts:
--------------------------------------------------------------------------------
1 | const mri = require("mri");
2 | const fs = require("fs");
3 | const mkdirp = require("mkdirp");
4 | const { generateJson } = require("./index");
5 | const pkg = require("../package.json");
6 | console.log(`
7 | Version : ${pkg.version}
8 | `);
9 |
10 | const args = process.argv.slice(2);
11 |
12 | const { _ } = mri(args);
13 |
14 | if (_.length < 2) {
15 | throw new Error(`Expected 2 arguments, `);
16 | }
17 | const [schemaFilePath, outputDirPath] = _;
18 | const schemaFile = require(`${process.cwd()}/${schemaFilePath}`);
19 | const { schema, keyReducers, count } = schemaFile;
20 |
21 | const { tree, values, keys } = generateJson({ schema, keyReducers, count });
22 | const outputDir = `${process.cwd()}/${outputDirPath}`;
23 | mkdirp(outputDir);
24 | fs.writeFileSync(`${outputDir}/tree.json`, JSON.stringify(tree), {
25 | encoding: "utf8"
26 | });
27 | fs.writeFileSync(`${outputDir}/values.json`, JSON.stringify(values), {
28 | encoding: "utf8"
29 | });
30 | fs.writeFileSync(`${outputDir}/keys.json`, JSON.stringify(keys), {
31 | encoding: "utf8"
32 | });
33 | console.log(`✅ Ok.
34 | Check ${outputDir}
35 | to see the generated data.
36 | `);
37 |
--------------------------------------------------------------------------------
/modules/generate-json/src/utils.ts:
--------------------------------------------------------------------------------
1 | import admin from "firebase-admin";
2 | import is from "is";
3 | export const isPromise = (promiseMaybe: any) => {
4 | return (
5 | !!promiseMaybe &&
6 | (typeof promiseMaybe === "object" || typeof promiseMaybe === "function") &&
7 | typeof promiseMaybe.then === "function"
8 | );
9 | };
10 |
11 | export const getValueAt = async (path: string) => {
12 | const val = await admin
13 | .app()
14 | .database()
15 | .ref(path)
16 | .once("value");
17 | return val.val();
18 | };
19 |
20 | export const getType = (val: any) => {
21 | if (is.boolean(val)) {
22 | return "boolean";
23 | } else if (is.number(val)) {
24 | return "number";
25 | } else if (is.string(val)) {
26 | return "string";
27 | } else if (is.null(val)) {
28 | return "null";
29 | } else if (is.undefined(val)) {
30 | return "undefined";
31 | } else {
32 | // console.log(val);
33 | throw val;
34 | }
35 | };
36 |
--------------------------------------------------------------------------------
/modules/generate-json/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "include": ["./src/"],
3 | "compilerOptions": {
4 | "target": "es6",
5 | "module": "commonjs",
6 | "moduleResolution": "node",
7 | "lib": ["dom", "es2017"],
8 | "outDir": "./build/",
9 | "strict": true,
10 | "declaration": true,
11 | "removeComments": true,
12 | "esModuleInterop": true
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/modules/hooks/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | dist/
3 | .cache
4 | .rpt2_cache
5 | build/
6 | coverage/
7 | .vscode
--------------------------------------------------------------------------------
/modules/hooks/README.md:
--------------------------------------------------------------------------------
1 | ## React hooks for interacting with your Firebase database
2 |
3 | React Firebase Hooks for React & React Native
4 |
5 | ## Install
6 |
7 | ```sh
8 | yarn add @react-firebase/hooks
9 | ```
10 |
11 | ## Usage
12 |
13 | ```jsx
14 | import { FirebaseProvider, useDatabase } from "@react-firebase/hooks";
15 |
16 | function UserBookmarks() {
17 | const { isLoading, value, ref } = useDatabase({
18 | path: "user_bookmarks/",
19 | limitToFirst: 2
20 | });
21 | return {JSON.stringify({ isLoading, value }, null, 2)}
;
22 | }
23 |
24 | function App() {
25 | return (
26 |
27 |
28 |
29 | );
30 | }
31 | ```
32 |
--------------------------------------------------------------------------------
/modules/hooks/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@react-firebase/hooks",
3 | "version": "0.1.2",
4 | "main": "dist/index.cjs.js",
5 | "module": "dist/index.esm.js",
6 | "types": "dist/index.d.ts",
7 | "scripts": {
8 | "start": "npm run test:i",
9 | "build": "rm -rf ./dist/ && rollup -c",
10 | "test:i": "jest --watch --coverage",
11 | "test": "tsc",
12 | "prepublish": "npm run test && npm run build",
13 | "commit": "git-cz",
14 | "setup:semantic-release": "npx semantic-release-cli setup"
15 | },
16 | "husky": {
17 | "pre-commit": "prettier src/* --write",
18 | "pre-push": "npm run test"
19 | },
20 | "repository": {
21 | "type": "git",
22 | "url": "https://github.com/rakannimer/hooks"
23 | },
24 | "license": "MIT",
25 | "devDependencies": {
26 | "@types/jest": "^23.3.3",
27 | "@types/lodash": "^4.14.117",
28 | "comment-json": "^1.1.3",
29 | "git-cz": "^1.7.1",
30 | "husky": "^1.1.1",
31 | "jest": "^23.6.0",
32 | "parcel-bundler": "^1.10.1",
33 | "prettier": "^1.14.3",
34 | "react": "16.7.0-alpha.0",
35 | "rollup": "^0.66.4",
36 | "rollup-plugin-typescript2": "^0.17.1",
37 | "semantic-release": "^15.9.17",
38 | "ts-jest": "^23.10.3",
39 | "typescript": "^3.1.1"
40 | },
41 | "peerDependencies": {
42 | "react": ">=16.7"
43 | },
44 | "jest": {
45 | "preset": "ts-jest",
46 | "collectCoverageFrom": [
47 | "src/*.{ts,tsx}"
48 | ],
49 | "testPathIgnorePatterns": [
50 | "/node_modules/",
51 | "/build/",
52 | "/dist/"
53 | ]
54 | },
55 | "files": [
56 | "dist/"
57 | ],
58 | "description": "React Custom Hooks for interacting with Firebase",
59 | "dependencies": {
60 | "get-firebase-ref": "^1.1.1",
61 | "initialize-firebase-app": "^1.0.0",
62 | "lodash": ">=4"
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/modules/hooks/rollup.config.js:
--------------------------------------------------------------------------------
1 | import typescript from "rollup-plugin-typescript2";
2 |
3 | export default {
4 | input: "src/index.tsx",
5 | output: [
6 | {
7 | file: "dist/index.cjs.js",
8 | format: "cjs"
9 | },
10 | {
11 | file: "dist/index.esm.js",
12 | format: "esm"
13 | }
14 | ],
15 | plugins: [
16 | typescript({
17 | typescript: require("typescript"),
18 | abortOnError: false,
19 | tsconfigOverride: {
20 | compilerOptions: {
21 | module: "ES2015"
22 | }
23 | }
24 | })
25 | ]
26 | };
27 |
--------------------------------------------------------------------------------
/modules/hooks/src/types.ts:
--------------------------------------------------------------------------------
1 | export interface FirebaseProviderProps {
2 | authDomain?: string;
3 | apiKey?: string;
4 | databaseURL?: string;
5 | firebase: any;
6 | projectId?: string;
7 | messagingSenderId?: string;
8 | storageBucket?: string;
9 | children?: any;
10 | }
11 |
12 | export interface FirebaseQuery {
13 | path: string;
14 | orderByChild?: null | string;
15 | orderByKey?: null | any;
16 | orderByValue?: null | any;
17 | limitToFirst?: null | number;
18 | limitToLast?: null | number;
19 | startAt?: null | number;
20 | endAt?: null | number;
21 | equalTo?: null | any;
22 | keysOnly?: boolean;
23 | once?: boolean;
24 | isList?: boolean;
25 | }
26 |
--------------------------------------------------------------------------------
/modules/hooks/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "include": ["./src/"],
3 | "compilerOptions": {
4 | "target": "ES2015",
5 | "module": "commonjs",
6 | "lib": ["es2018"],
7 | "jsx": "react",
8 | "declaration": true,
9 | "outDir": "./build/",
10 | "rootDir": "./src/",
11 | "removeComments": true,
12 | "allowSyntheticDefaultImports": true,
13 | "esModuleInterop": true,
14 | "strict": true,
15 | "skipLibCheck": true
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/modules/react-firebase-docs/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 |
3 | node_modules
4 |
5 | lib/core/metadata.js
6 | lib/core/MetadataBlog.js
7 |
8 | website/translated_docs
9 | website/build/
10 | website/yarn.lock
11 | website/node_modules
12 | website/i18n/*
13 |
--------------------------------------------------------------------------------
/modules/react-firebase-docs/docs/README.md:
--------------------------------------------------------------------------------
1 | # React Firebase
2 |
3 | Building apps with React & Firebase should be easy. The goal of this project is to offer intuitive declarative APIs to make interacting with Firebase fun and easy.
4 |
5 | ## Modules
6 |
7 | - Firebase Realtime Database : [`@react-firebase/database`](react-firebase-realtime-database/)
8 | - Firestore Database : [`@react-firebase/firestore`](react-firestore-database/)
9 | - Firebase Auth : [`@react-firebase/auth`](react-firebase-auth/)
10 | - Firebase Data Generator: [`generate-firebase-data`](generate-firebase-data/)
11 | - Firestore Data Generator: [`generate-firestore-data`](react-firestore-database/)
12 | - Linked JSON Data Generator: [`generate-data`](generate-json-data/)
13 |
14 | ## Installation
15 |
16 | ### Web
17 |
18 | Install [firebase](https://www.npmjs.com/package/firebase).
19 |
20 | ```bash
21 | yarn add firebase
22 | # Or
23 | npm i firebase
24 | ```
25 |
26 | #### Firebase Auth
27 |
28 | ```bash
29 | yarn add @react-firebase/auth
30 | ```
31 |
32 | #### Firebase Realtime Database
33 |
34 | ```bash
35 | yarn add @react-firebase/database
36 | ```
37 |
38 | #### Firebase Firestore Database
39 |
40 | ```bash
41 | yarn add @react-firebase/firestore
42 | ```
43 |
--------------------------------------------------------------------------------
/modules/react-firebase-docs/docs/assets/data-shape-in-firebase.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakannimer/react-firebase/ed3db6aba5563c78163b84c94da806a9c9d18dde/modules/react-firebase-docs/docs/assets/data-shape-in-firebase.png
--------------------------------------------------------------------------------
/modules/react-firebase-docs/docs/assets/react-firebase-tutorial-auth-2-gif.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakannimer/react-firebase/ed3db6aba5563c78163b84c94da806a9c9d18dde/modules/react-firebase-docs/docs/assets/react-firebase-tutorial-auth-2-gif.gif
--------------------------------------------------------------------------------
/modules/react-firebase-docs/docs/assets/react-firebase-tutorial-auth-3-loading-gif.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakannimer/react-firebase/ed3db6aba5563c78163b84c94da806a9c9d18dde/modules/react-firebase-docs/docs/assets/react-firebase-tutorial-auth-3-loading-gif.gif
--------------------------------------------------------------------------------
/modules/react-firebase-docs/docs/assets/react-firebase-tutorial-auth-4-error-handling-gif.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakannimer/react-firebase/ed3db6aba5563c78163b84c94da806a9c9d18dde/modules/react-firebase-docs/docs/assets/react-firebase-tutorial-auth-4-error-handling-gif.gif
--------------------------------------------------------------------------------
/modules/react-firebase-docs/docs/assets/react-firebase-tutorial-dumb-ui-gif.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakannimer/react-firebase/ed3db6aba5563c78163b84c94da806a9c9d18dde/modules/react-firebase-docs/docs/assets/react-firebase-tutorial-dumb-ui-gif.gif
--------------------------------------------------------------------------------
/modules/react-firebase-docs/docs/assets/react-firebase-tutorial-fig.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakannimer/react-firebase/ed3db6aba5563c78163b84c94da806a9c9d18dde/modules/react-firebase-docs/docs/assets/react-firebase-tutorial-fig.gif
--------------------------------------------------------------------------------
/modules/react-firebase-docs/docs/assets/react-firebase-tutorial-result-gif.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakannimer/react-firebase/ed3db6aba5563c78163b84c94da806a9c9d18dde/modules/react-firebase-docs/docs/assets/react-firebase-tutorial-result-gif.gif
--------------------------------------------------------------------------------
/modules/react-firebase-docs/docs/assets/user-input-ui.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakannimer/react-firebase/ed3db6aba5563c78163b84c94da806a9c9d18dde/modules/react-firebase-docs/docs/assets/user-input-ui.png
--------------------------------------------------------------------------------
/modules/react-firebase-docs/docs/assets/wireframe-authed-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakannimer/react-firebase/ed3db6aba5563c78163b84c94da806a9c9d18dde/modules/react-firebase-docs/docs/assets/wireframe-authed-2.png
--------------------------------------------------------------------------------
/modules/react-firebase-docs/docs/assets/wireframe-authed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakannimer/react-firebase/ed3db6aba5563c78163b84c94da806a9c9d18dde/modules/react-firebase-docs/docs/assets/wireframe-authed.png
--------------------------------------------------------------------------------
/modules/react-firebase-docs/docs/assets/wireframe-unauthed-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakannimer/react-firebase/ed3db6aba5563c78163b84c94da806a9c9d18dde/modules/react-firebase-docs/docs/assets/wireframe-unauthed-2.png
--------------------------------------------------------------------------------
/modules/react-firebase-docs/docs/assets/wireframe-unauthed-breakdown.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakannimer/react-firebase/ed3db6aba5563c78163b84c94da806a9c9d18dde/modules/react-firebase-docs/docs/assets/wireframe-unauthed-breakdown.png
--------------------------------------------------------------------------------
/modules/react-firebase-docs/docs/assets/wireframe-unauthed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakannimer/react-firebase/ed3db6aba5563c78163b84c94da806a9c9d18dde/modules/react-firebase-docs/docs/assets/wireframe-unauthed.png
--------------------------------------------------------------------------------
/modules/react-firebase-docs/docs/generate-json-data/setup.md:
--------------------------------------------------------------------------------
1 | # Setup
2 |
3 | Installation
4 |
5 | #### API
6 |
7 | ```bash
8 | yarn add generate-json
9 | ```
10 |
11 | #### CLI
12 |
13 | ```bash
14 | # In your project :
15 | yarn add -D generate-json
16 | yarn generate-json
17 |
18 | # Or temporarily
19 | npx generate-json
20 |
21 | # Or globally :
22 | npm i -g generate-json
23 | generate-json
24 | ```
25 |
--------------------------------------------------------------------------------
/modules/react-firebase-docs/docs/guides/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # Guides
4 |
5 |
--------------------------------------------------------------------------------
/modules/react-firebase-docs/docs/guides/build-a-react-app-with-firebase-auth-and-realtime-database/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # Build a React App with Firebase Auth and Realtime Database
4 |
5 | ### Overview
6 |
7 | We want to build a bookmarking app that allows a user to add links and metadata and then be able to search through them.
8 |
9 | ### App description
10 |
11 | * If a user is not authenticated, they should see a Login/Register screen
12 | * A user can choose to login/register with Google or Anonymously.
13 | * Once a user is authenticated the login/register buttons should disappear.
14 | * If a user is authenticated, they should see a :
15 | * A big text input with auto-complete.
16 | * A small button to logout.
17 | * A list of all their bookmarks sorted by last used.
18 | * Once the user starts typing, the autocomplete field should suggest clickable links that will open the link in a new tab.
19 |
20 | Looking at the app description we will need to use `firebase/auth` and `firebase/database` or `firebase/firestore`
21 |
22 | ### App wireframe
23 |
24 | 
25 |
26 | 
27 |
28 | #### Now that we have the requirements we can get started !
29 |
30 | You can read the whole code [here](https://github.com/rakannimer/react-firebase/tree/master/modules/tutorial-bookmarking-app) if you want to go straight to the code.
31 |
32 | Every step below will have a matching git commit that you can browse.
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/modules/react-firebase-docs/docs/guides/build-a-react-app-with-firebase-auth-and-realtime-database/add-firebase.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Add Firebase to your app
3 | sidebar_label: Add Firebase to your app
4 | ---
5 |
6 | Install the [firebase](https://www.npmjs.com/package/firebase) JS client.
7 |
8 | ```bash
9 | yarn add firebase
10 | # Or
11 | npm i firebase
12 | ```
13 |
14 | Change `PROJECT_NAME` to your project name and grab your firebase config here :
15 |
16 | `https://console.firebase.google.com/project/PROJECT_NAME/settings/general/`
17 |
18 | Your config file should look something like this :
19 |
20 | ```javascript
21 | // Firebase Config
22 | export const config = {
23 | apiKey: "API_KEY",
24 | projectId: "PROJECT_ID",
25 | databaseURL: "DATABASE_URL",
26 | authDomain: "AUTH_DOMAIN",
27 | // OPTIONAL
28 | storageBucket: "STORAGE_BUCKET",
29 | messagingSenderId: "MESSAGING_SENDER_ID"
30 | };
31 | ```
32 |
33 | In the example repo this file is located in `src/test-credentials.ts` but you won't be able to find it because it's added to the `.gitignore`
34 |
35 | Make sure you do the same if your repository is public.
36 |
37 |
38 |
--------------------------------------------------------------------------------
/modules/react-firebase-docs/docs/guides/build-a-react-app-with-firebase-auth-and-realtime-database/add-react-and-react-dom.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Add React and React DOM
3 | sidebar_label: Add React and React DOM
4 | ---
5 |
6 | Now that we have a running website, let's start adding the dependencies we want to use for this project.
7 |
8 | Install `react` and `react-dom` from the npm registry.
9 |
10 | ```bash
11 | yarn add react react-dom
12 | # Add the community provided types for these libraries
13 | # (For typescript users only)
14 | yarn add -D @types/react @types/react-dom
15 | ```
16 |
17 | And let's add a small React Component to the page
18 |
19 | ```jsx
20 | import * as React from "react";
21 | import { render } from "react-dom";
22 | const concept = "world";
23 |
24 | const App = () => {
25 | return Hello {concept}
;
26 | };
27 |
28 | render(, document.getElementById("root"));
29 |
30 | ```
31 |
32 | #### Our React app is ready.
33 |
34 |
35 |
36 | ### [Git Commit](https://github.com/rakannimer/react-firebase/commit/f36141dfb9038b0a820bcd3dc98e2d2197b03cdf)
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/modules/react-firebase-docs/docs/guides/build-a-react-app-with-firebase-auth-and-realtime-database/listen-to-auth.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Listen to auth
3 | sidebar_label: Listen to auth
4 | ---
5 |
6 | Install `@react-firebase/auth`
7 |
8 | ```bash
9 | yarn add @react-firebase/auth # or npm i @react-firebase/auth
10 | ```
11 |
12 | Wrap your app with a FirebaseAuthProvider and use a FirebaseAuthConsumer anywhere inside its children tree.
13 |
14 |
15 | ```jsx
16 | import * as React from "react";
17 | import { render } from "react-dom";
18 | import {
19 | FirebaseAuthProvider,
20 | FirebaseAuthConsumer
21 | } from "@react-firebase/auth";
22 | import * as firebase from "firebase/app";
23 | import { config } from "./test-credentials";
24 | const concept = "world";
25 |
26 | const IDontCareAboutFirebaseAuth = () => {
27 | return This part won't react to firebase auth changes
;
28 | };
29 |
30 | const App = () => {
31 | return (
32 |
33 |
34 |
35 |
36 | Hello
From Auth Provider Child 1
37 |
38 | {({ isSignedIn }) => {
39 | if (isSignedIn === true) {
40 | return "Signed in";
41 | } else {
42 | return "Not signed in";
43 | }
44 | }}
45 |
46 |
47 | Another div
48 |
49 |
50 | );
51 | };
52 |
53 | render(, document.getElementById("root"));
54 | ```
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/modules/react-firebase-docs/docs/guides/build-a-react-app-with-firebase-auth-and-realtime-database/read-data.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Read Data
3 | sidebar_label: Read Data
4 | ---
5 |
6 | 2 components need to read data the Search component and the History List components
7 |
8 | Our Search component looks like this :
9 |
10 | ```jsx
11 | const Search = () => {
12 | return ;
13 | };
14 | ```
15 |
16 | We want to connect it to the database at `user_bookmarks/` path.
17 |
18 | 
19 |
20 | The code we get :
21 |
22 | ```jsx
23 | const Search = () => {
24 | return (
25 |
26 | {data => {
27 | const { value } = data;
28 | if (value === null || typeof value === "undefined") return null;
29 | const keys = Object.keys(value);
30 | const values = Object.values(value);
31 | const valuesWithKeys = values.map(
32 | (value, i) =>
33 | ({
34 | link_url:value.link_url,
35 | link_description: value.link_description,
36 | id: keys[i]
37 | })
38 | );
39 | return ;
40 | }}
41 |
42 | );
43 | };
44 | ```
45 |
46 | That's it !
47 |
48 | Now for the list showing user\_bookmarks sorted by user\_bookmarks/created\_on, we want to change
49 |
50 | ```jsx
51 |
52 |
53 |
54 | ```
55 |
56 | to a dynamic list of items :
57 |
58 | ```jsx
59 |
60 | {({ value }) => {
61 | if (value === null || typeof value === "undefined") return null;
62 | const keys = Object.keys(value);
63 | const values = Object.values(value);
64 | return values.map((val, i) => (
65 |
66 | ));
67 | }}
68 | ;
69 | ```
70 |
71 | That's it ! We now have an app that writes, reads and searches in Firebase !
72 |
73 | You can check the full code[ here](https://github.com/rakannimer/react-firebase/tree/16a96e7d06285da2ea14ccb342b2ec295f019064/modules/tutorial-bookmarking-app/src).
74 |
75 | And a gif here :
76 |
77 | 
78 |
79 |
--------------------------------------------------------------------------------
/modules/react-firebase-docs/docs/guides/build-a-react-app-with-firebase-auth-and-realtime-database/write-data.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Writing Data
3 | sidebar_label: Writing Data
4 | ---
5 |
6 | Let's start by adding a way to the user to add data to the their firebase database.
7 |
8 | To do this we will be using the FirebaseDatabaseMutation component from @react-firebase/database.
9 |
10 | 
11 |
12 | When a user clicks on the + button we want to push data to user\_bookmarks/
13 |
14 | The data should have the following shape :
15 |
16 | ```typescript
17 | {
18 | link_url: string,
19 | link_description: string,
20 | created_at: timestamp,
21 | updated_at: timestamp
22 | }
23 | ```
24 |
25 | ```jsx
26 |
27 | {({ runMutation }) => (
28 |
47 | )}
48 | ;
49 | ```
50 |
51 | You can see the full code [here](https://github.com/rakannimer/react-firebase/tree/1c95420d8ecadd24ab2fefc3b89e16e4aef1ff34/modules/tutorial-bookmarking-app/src).
52 |
53 |
--------------------------------------------------------------------------------
/modules/react-firebase-docs/docs/view-source.md:
--------------------------------------------------------------------------------
1 | # View Source
2 |
3 | [Source](https://github.com/rakannimer/react-firebase)
4 |
--------------------------------------------------------------------------------
/modules/react-firebase-docs/now.json:
--------------------------------------------------------------------------------
1 | {
2 | "public": true,
3 | "alias": "react-firebase-js.com"
4 | }
--------------------------------------------------------------------------------
/modules/react-firebase-docs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-firebase-docs",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "directories": {
7 | "doc": "docs"
8 | },
9 | "scripts": {
10 | "build": "cd website && yarn build && cp ../now.json build/react-firebase/",
11 | "deploy": "yarn build && cd website/build/react-firebase && now && now alias",
12 | "test": "echo \"Error: no test specified\" && exit 1"
13 | },
14 | "keywords": [],
15 | "author": "",
16 | "license": "ISC"
17 | }
18 |
--------------------------------------------------------------------------------
/modules/react-firebase-docs/website/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "examples": "docusaurus-examples",
4 | "start": "docusaurus-start",
5 | "build": "docusaurus-build",
6 | "publish-gh-pages": "docusaurus-publish",
7 | "write-translations": "docusaurus-write-translations",
8 | "version": "docusaurus-version",
9 | "rename-version": "docusaurus-rename-version"
10 | },
11 | "devDependencies": {
12 | "docusaurus": "^1.3.3",
13 | "prettier": "^1.14.2"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/modules/react-firebase-docs/website/pages/en/help.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2017-present, Facebook, Inc.
3 | *
4 | * This source code is licensed under the MIT license found in the
5 | * LICENSE file in the root directory of this source tree.
6 | */
7 |
8 | const React = require('react');
9 |
10 | const CompLibrary = require('../../core/CompLibrary.js');
11 |
12 | const Container = CompLibrary.Container;
13 | const GridBlock = CompLibrary.GridBlock;
14 |
15 | const siteConfig = require(`${process.cwd()}/siteConfig.js`);
16 |
17 | function docUrl(doc, language) {
18 | return `${siteConfig.baseUrl}docs/${language ? `${language}/` : ''}${doc}`;
19 | }
20 |
21 | class Help extends React.Component {
22 | render() {
23 | const language = this.props.language || '';
24 | const supportLinks = [
25 | {
26 | content: `Learn more using the [documentation on this site.](${docUrl(
27 | 'doc1.html',
28 | language
29 | )})`,
30 | title: 'Browse Docs',
31 | },
32 | {
33 | content: 'Ask questions about the documentation and project',
34 | title: 'Join the community',
35 | },
36 | {
37 | content: "Find out what's new with this project",
38 | title: 'Stay up to date',
39 | },
40 | ];
41 |
42 | return (
43 |
44 |
45 |
46 |
49 |
This project is maintained by a dedicated group of people.
50 |
51 |
52 |
53 |
54 | );
55 | }
56 | }
57 |
58 | module.exports = Help;
59 |
--------------------------------------------------------------------------------
/modules/react-firebase-docs/website/pages/en/users.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2017-present, Facebook, Inc.
3 | *
4 | * This source code is licensed under the MIT license found in the
5 | * LICENSE file in the root directory of this source tree.
6 | */
7 |
8 | const React = require('react');
9 |
10 | const CompLibrary = require('../../core/CompLibrary.js');
11 |
12 | const Container = CompLibrary.Container;
13 |
14 | const siteConfig = require(`${process.cwd()}/siteConfig.js`);
15 |
16 | class Users extends React.Component {
17 | render() {
18 | if ((siteConfig.users || []).length === 0) {
19 | return null;
20 | }
21 |
22 | const editUrl = `${siteConfig.repoUrl}/edit/master/website/siteConfig.js`;
23 | const showcase = siteConfig.users.map(user => (
24 |
25 |
26 |
27 | ));
28 |
29 | return (
30 |
31 |
32 |
33 |
34 |
Who is Using This?
35 |
This project is used by many folks
36 |
37 |
{showcase}
38 |
Are you using this project?
39 |
40 | Add your company
41 |
42 |
43 |
44 |
45 | );
46 | }
47 | }
48 |
49 | module.exports = Users;
50 |
--------------------------------------------------------------------------------
/modules/react-firebase-docs/website/sidebars.json:
--------------------------------------------------------------------------------
1 | {
2 | "docs": {
3 | "Auth": ["react-firebase-auth/getting-started", "react-firebase-auth/api"],
4 | "Realtime Database": [
5 | "react-firebase-realtime-database/getting-started",
6 | "react-firebase-realtime-database/api"
7 | ],
8 | "Firestore": [
9 | "react-firestore-database/getting-started",
10 | "react-firestore-database/api"
11 | ],
12 | "Generate JSON Data": ["generate-json-data"],
13 | "Generate Firebase Data": ["generate-firebase-data"],
14 | "Generate Firestore Data": ["generate-firestore-data"],
15 | "Try it out": ["try-it-out"],
16 | "Walkthrough": [
17 | "guides/build-a-react-app-with-firebase-auth-and-realtime-database/setup-the-development-environment",
18 | "guides/build-a-react-app-with-firebase-auth-and-realtime-database/add-react-and-react-dom",
19 | "guides/build-a-react-app-with-firebase-auth-and-realtime-database/add-firebase",
20 | "guides/build-a-react-app-with-firebase-auth-and-realtime-database/listen-to-auth",
21 | "guides/build-a-react-app-with-firebase-auth-and-realtime-database/add-google-and-anonymous-auth",
22 | "guides/build-a-react-app-with-firebase-auth-and-realtime-database/implementing-the-ui",
23 | "guides/build-a-react-app-with-firebase-auth-and-realtime-database/read-data",
24 | "guides/build-a-react-app-with-firebase-auth-and-realtime-database/write-data"
25 | ]
26 | },
27 | "guides": {
28 | "a": ["doc1", "doc2"]
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/modules/react-firebase-docs/website/static/css/custom.css:
--------------------------------------------------------------------------------
1 | /* your custom css */
2 |
3 | @media only screen and (min-device-width: 360px) and (max-device-width: 736px) {
4 | }
5 |
6 | @media only screen and (min-width: 1024px) {
7 | }
8 |
9 | @media only screen and (max-width: 1023px) {
10 | }
11 |
12 | @media only screen and (min-width: 1400px) {
13 | }
14 |
15 | @media only screen and (min-width: 1500px) {
16 | }
--------------------------------------------------------------------------------
/modules/react-firebase-docs/website/static/img/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakannimer/react-firebase/ed3db6aba5563c78163b84c94da806a9c9d18dde/modules/react-firebase-docs/website/static/img/favicon.png
--------------------------------------------------------------------------------
/modules/react-firebase-docs/website/static/img/favicon/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakannimer/react-firebase/ed3db6aba5563c78163b84c94da806a9c9d18dde/modules/react-firebase-docs/website/static/img/favicon/favicon.ico
--------------------------------------------------------------------------------
/modules/react-firebase-docs/website/static/img/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakannimer/react-firebase/ed3db6aba5563c78163b84c94da806a9c9d18dde/modules/react-firebase-docs/website/static/img/logo.png
--------------------------------------------------------------------------------
/modules/react-firebase-docs/website/static/img/oss_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakannimer/react-firebase/ed3db6aba5563c78163b84c94da806a9c9d18dde/modules/react-firebase-docs/website/static/img/oss_logo.png
--------------------------------------------------------------------------------
/modules/sandboxes/firebase-auth/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
3 | .cache
4 | build
--------------------------------------------------------------------------------
/modules/sandboxes/firebase-auth/config.ts:
--------------------------------------------------------------------------------
1 | export const config = {
2 | // DO NOT USE THESE CREDENTIALS ! THEY ARE HERE TO HELP IN THE LEARNING PROCESS.
3 | // ANY AND ALL DATA ON THAT DOMAIN IS SUBJECT TO CHANGE AND REMOVAL AT ANY TIME
4 | // THIS ACCOUNT IS ALSO ON THE FREE PLAN AND IS SUBJECT TO RESTRICTIONS !
5 | apiKey: "AIzaSyBIEgdW0FGGxQZ7bbbqIhzmiVAk7nnJB14",
6 | authDomain: "react-firebase-baecd.firebaseapp.com",
7 | databaseURL: "https://react-firebase-baecd.firebaseio.com",
8 | projectId: "react-firebase-baecd",
9 | storageBucket: "react-firebase-baecd.appspot.com",
10 | messagingSenderId: "6611069556"
11 | };
12 |
--------------------------------------------------------------------------------
/modules/sandboxes/firebase-auth/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Page Title
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/modules/sandboxes/firebase-auth/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "firebase-auth-example",
3 | "version": "0.1.0",
4 | "description": "Firebase Auth Example",
5 | "main": "index.html",
6 | "repository": "https://github.com/rakannimer/react-firebase/",
7 | "author": "rakannimer",
8 | "license": "GPL-3.0",
9 | "private": false,
10 | "scripts": {
11 | "start": "parcel index.html"
12 | },
13 | "dependencies": {
14 | "@react-firebase/auth": "^0.1.9",
15 | "firebase": "^5.4.1",
16 | "react": "^16.4.2",
17 | "react-dom": "^16.4.2"
18 | },
19 | "devDependencies": {
20 | "parcel-bundler": "^1.9.7",
21 | "prettier": "^1.14.2"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/modules/sandboxes/firebase-auth/src/index.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import { render } from "react-dom";
3 | import * as firebase from "firebase/app";
4 | import "firebase/auth";
5 | import {
6 | FirebaseAuthProvider,
7 | FirebaseAuthConsumer,
8 | IfFirebaseAuthed,
9 | IfFirebaseAuthedAnd
10 | } from "@react-firebase/auth";
11 | import { config } from "../config";
12 |
13 | export const App = () => {
14 | return (
15 |
16 |
17 |
25 |
33 |
40 |
41 | {({ isSignedIn, user, providerId }) => {
42 | return (
43 |
44 | {JSON.stringify({ isSignedIn, user, providerId }, null, 2)}
45 |
46 | );
47 | }}
48 |
49 |
50 |
51 | {() => {
52 | return You are authenticated
;
53 | }}
54 |
55 |
providerId !== "anonymous"}
57 | >
58 | {({ providerId }) => {
59 | return You are authenticated with {providerId}
;
60 | }}
61 |
62 |
63 |
64 |
65 | );
66 | };
67 | render(, document.getElementById("root"));
68 |
--------------------------------------------------------------------------------
/modules/sandboxes/firebase-auth/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "jsx": "react",
4 | "target": "es5",
5 | "module": "ESNext",
6 | "moduleResolution": "node",
7 | "lib": ["es2018", "dom"],
8 | "outDir": "./build/",
9 | "strict": true,
10 | "declaration": true,
11 | "removeComments": true,
12 | "allowSyntheticDefaultImports": true
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/modules/sandboxes/firebase-database-flatlist-infinite-list/config.js:
--------------------------------------------------------------------------------
1 | export const config = {
2 | // DO NOT USE THESE CREDENTIALS ! THEY ARE HERE TO HELP IN THE LEARNING PROCESS.
3 | // ANY AND ALL DATA ON THAT DOMAIN IS SUBJECT TO CHANGE AND REMOVAL AT ANY TIME
4 | // THIS ACCOUNT IS ALSO ON THE FREE PLAN AND IS SUBJECT TO RESTRICTIONS !
5 | apiKey: "AIzaSyBIEgdW0FGGxQZ7bbbqIhzmiVAk7nnJB14",
6 | authDomain: "react-firebase-baecd.firebaseapp.com",
7 | databaseURL: "https://react-firebase-baecd.firebaseio.com",
8 | projectId: "react-firebase-baecd",
9 | storageBucket: "react-firebase-baecd.appspot.com",
10 | messagingSenderId: "6611069556"
11 | };
12 |
--------------------------------------------------------------------------------
/modules/sandboxes/firebase-database-flatlist-infinite-list/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Parcel Sandbox
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/modules/sandboxes/firebase-database-flatlist-infinite-list/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "parcel-sandbox",
3 | "version": "1.0.0",
4 | "description": "Simple Parcel Sandbox",
5 | "main": "index.html",
6 | "scripts": {
7 | "start": "parcel index.html --open",
8 | "build": "parcel build index.html"
9 | },
10 | "dependencies": {
11 | "@reach/component-component": "0.1.0",
12 | "@react-firebase/database": "0.2.15",
13 | "firebase": "5.4.1",
14 | "react": "latest",
15 | "react-art": "16.4.2",
16 | "react-dom": "16.4.2",
17 | "react-native-web": "0.8.9"
18 | },
19 | "devDependencies": {
20 | "parcel-bundler": "^1.6.1"
21 | }
22 | }
--------------------------------------------------------------------------------
/modules/sandboxes/firebase-database-flatlist-infinite-list/src/index.js:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import { render } from "react-dom";
3 | import { View, Text, FlatList } from "react-native-web";
4 | import * as firebase from "firebase/app";
5 | import "firebase/database";
6 | import {
7 | FirebaseDatabaseProvider,
8 | FirebaseDatabaseNode
9 | } from "@react-firebase/database";
10 | import Component from "@reach/component-component";
11 | import { config } from "../config";
12 |
13 | const s = v => JSON.stringify(v, null, 2);
14 |
15 | const App = () => {
16 | return (
17 |
18 |
19 |
20 | {component => (
21 |
25 | {({ value }) => {
26 | if (value === null || typeof value === "undefined") return null;
27 | const keys = Object.keys(value);
28 | const values = Object.values(value);
29 | return (
30 | keys[i]}
34 | renderItem={v => (
35 |
36 | {s(v)}
37 |
38 | )}
39 | onEndReached={() => {
40 | component.setState({ limit: component.state.limit + 1 });
41 | }}
42 | />
43 | );
44 | }}
45 |
46 | )}
47 |
48 |
49 | Oh hai
50 |
51 |
52 |
53 | );
54 | };
55 | render(, document.getElementById("app"));
56 |
--------------------------------------------------------------------------------
/modules/sandboxes/firebase-database-infinite-list/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
3 | .cache
4 | build
--------------------------------------------------------------------------------
/modules/sandboxes/firebase-database-infinite-list/config.ts:
--------------------------------------------------------------------------------
1 | export const config = {
2 | // DO NOT USE THESE CREDENTIALS ! THEY ARE HERE TO HELP IN THE LEARNING PROCESS.
3 | // ANY AND ALL DATA ON THAT DOMAIN IS SUBJECT TO CHANGE AND REMOVAL AT ANY TIME
4 | // THIS ACCOUNT IS ALSO ON THE FREE PLAN AND IS SUBJECT TO RESTRICTIONS !
5 | apiKey: "AIzaSyBIEgdW0FGGxQZ7bbbqIhzmiVAk7nnJB14",
6 | authDomain: "react-firebase-baecd.firebaseapp.com",
7 | databaseURL: "https://react-firebase-baecd.firebaseio.com",
8 | projectId: "react-firebase-baecd",
9 | storageBucket: "react-firebase-baecd.appspot.com",
10 | messagingSenderId: "6611069556"
11 | };
12 |
--------------------------------------------------------------------------------
/modules/sandboxes/firebase-database-infinite-list/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Page Title
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/modules/sandboxes/firebase-database-infinite-list/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "firebase-database-infinite-list-example",
3 | "version": "0.1.0",
4 | "description": "Firebase Database Infinite List Example",
5 | "main": "index.html",
6 | "repository": "https://github.com/rakannimer/react-firebase/",
7 | "author": "rakannimer",
8 | "license": "GPL-3.0",
9 | "private": false,
10 | "scripts": {
11 | "start": "parcel index.html"
12 | },
13 | "dependencies": {
14 | "@react-firebase/database": "^0.2.13",
15 | "firebase": "^5.4.1",
16 | "react": "^16.4.2",
17 | "react-dom": "^16.4.2"
18 | },
19 | "devDependencies": {
20 | "parcel-bundler": "^1.9.7",
21 | "prettier": "^1.14.2"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/modules/sandboxes/firebase-database-infinite-list/src/index.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import { render } from "react-dom";
3 | import firebase from "firebase/app";
4 | import "firebase/database";
5 | import {
6 | FirebaseDatabaseProvider,
7 | FirebaseDatabaseNode
8 | } from "@react-firebase/database";
9 | import { config } from "../config";
10 |
11 | const styles = {
12 | fontFamily: "sans-serif"
13 | };
14 |
15 | const s = (a: any) => JSON.stringify(a, null, 2);
16 |
17 | export type AppState = {
18 | limit: number;
19 | };
20 |
21 | class App extends React.Component {
22 | state = {
23 | limit: 2
24 | };
25 | render() {
26 | return (
27 |
28 |
29 |
35 | {d => {
36 | return (
37 |
38 | Path {d.path}
39 |
40 | Value {s(d.value)}
41 |
42 |
49 |
50 | );
51 | }}
52 |
53 |
54 |
55 | );
56 | }
57 | }
58 |
59 | render(, document.getElementById("root"));
60 |
--------------------------------------------------------------------------------
/modules/sandboxes/firebase-database-infinite-list/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "jsx": "react",
4 | "target": "es5",
5 | "module": "ESNext",
6 | "moduleResolution": "node",
7 | "lib": ["es2018", "dom"],
8 | "outDir": "./build/",
9 | "strict": true,
10 | "declaration": true,
11 | "removeComments": true,
12 | "allowSyntheticDefaultImports": true
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/modules/sandboxes/firebase-database-mutation/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
3 | .cache
4 | build
--------------------------------------------------------------------------------
/modules/sandboxes/firebase-database-mutation/config.ts:
--------------------------------------------------------------------------------
1 | export const config = {
2 | // DO NOT USE THESE CREDENTIALS ! THEY ARE HERE TO HELP IN THE LEARNING PROCESS.
3 | // ANY AND ALL DATA ON THAT DOMAIN IS SUBJECT TO CHANGE AND REMOVAL AT ANY TIME
4 | // THIS ACCOUNT IS ALSO ON THE FREE PLAN AND IS SUBJECT TO RESTRICTIONS !
5 | apiKey: "AIzaSyBIEgdW0FGGxQZ7bbbqIhzmiVAk7nnJB14",
6 | authDomain: "react-firebase-baecd.firebaseapp.com",
7 | databaseURL: "https://react-firebase-baecd.firebaseio.com",
8 | projectId: "react-firebase-baecd",
9 | storageBucket: "react-firebase-baecd.appspot.com",
10 | messagingSenderId: "6611069556"
11 | };
12 |
--------------------------------------------------------------------------------
/modules/sandboxes/firebase-database-mutation/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Page Title
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/modules/sandboxes/firebase-database-mutation/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "firebase-database-mutation-example",
3 | "version": "0.1.0",
4 | "description": "Firestore Database Mutation Example",
5 | "main": "index.html",
6 | "repository": "https://github.com/rakannimer/react-firebase/",
7 | "author": "rakannimer",
8 | "license": "GPL-3.0",
9 | "private": false,
10 | "scripts": {
11 | "start": "parcel index.html"
12 | },
13 | "dependencies": {
14 | "@react-firebase/database": "^0.2.13",
15 | "firebase": "^5.4.1",
16 | "react": "^16.4.2",
17 | "react-dom": "^16.4.2"
18 | },
19 | "devDependencies": {
20 | "parcel-bundler": "^1.9.7",
21 | "prettier": "^1.14.2"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/modules/sandboxes/firebase-database-mutation/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "jsx": "react",
4 | "target": "es5",
5 | "module": "ESNext",
6 | "moduleResolution": "node",
7 | "lib": ["es2018", "dom"],
8 | "outDir": "./build/",
9 | "strict": true,
10 | "declaration": true,
11 | "removeComments": true,
12 | "allowSyntheticDefaultImports": true
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/modules/sandboxes/firebase-database-transaction/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
3 | .cache
4 | build
--------------------------------------------------------------------------------
/modules/sandboxes/firebase-database-transaction/config.ts:
--------------------------------------------------------------------------------
1 | export const config = {
2 | // DO NOT USE THESE CREDENTIALS ! THEY ARE HERE TO HELP IN THE LEARNING PROCESS.
3 | // ANY AND ALL DATA ON THAT DOMAIN IS SUBJECT TO CHANGE AND REMOVAL AT ANY TIME
4 | // THIS ACCOUNT IS ALSO ON THE FREE PLAN AND IS SUBJECT TO RESTRICTIONS !
5 | apiKey: "AIzaSyBIEgdW0FGGxQZ7bbbqIhzmiVAk7nnJB14",
6 | authDomain: "react-firebase-baecd.firebaseapp.com",
7 | databaseURL: "https://react-firebase-baecd.firebaseio.com",
8 | projectId: "react-firebase-baecd",
9 | storageBucket: "react-firebase-baecd.appspot.com",
10 | messagingSenderId: "6611069556"
11 | };
12 |
--------------------------------------------------------------------------------
/modules/sandboxes/firebase-database-transaction/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Page Title
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/modules/sandboxes/firebase-database-transaction/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "firebase-database-transaction-example",
3 | "version": "0.1.0",
4 | "description": "Firestore Database Transaction Example",
5 | "main": "index.html",
6 | "repository": "https://github.com/rakannimer/react-firebase/",
7 | "author": "rakannimer",
8 | "license": "GPL-3.0",
9 | "private": false,
10 | "scripts": {
11 | "start": "parcel index.html"
12 | },
13 | "dependencies": {
14 | "@react-firebase/database": "^0.2.13",
15 | "firebase": "^5.4.1",
16 | "react": "^16.4.2",
17 | "react-dom": "^16.4.2"
18 | },
19 | "devDependencies": {
20 | "parcel-bundler": "^1.9.7",
21 | "prettier": "^1.14.2"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/modules/sandboxes/firebase-database-transaction/src/index.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import { render } from "react-dom";
3 | import firebase from "firebase/app";
4 | import "firebase/database";
5 | import {
6 | FirebaseDatabaseProvider,
7 | FirebaseDatabaseNode,
8 | FirebaseDatabaseTransaction
9 | } from "@react-firebase/database";
10 | import { config } from "../config";
11 |
12 | const styles = {
13 | fontFamily: "sans-serif"
14 | };
15 |
16 | const s = (a: any) => JSON.stringify(a, null, 2);
17 |
18 | const path = "user_bookmarks/a/usage_count";
19 |
20 | const App = () => (
21 |
22 |
23 |
24 | {({ runTransaction }) => {
25 | return (
26 |
27 |
44 |
45 | );
46 | }}
47 |
48 |
49 |
50 | {d => {
51 | return (
52 |
53 | {d.value && (
54 |
Value : {s(d.value)}
55 | )}
56 | {d.path &&
Path : {d.path}
}
57 |
58 | isLoading : {s(d.isLoading)}
59 |
60 |
61 | );
62 | }}
63 |
64 |
65 |
66 | );
67 |
68 | render(, document.getElementById("root"));
69 |
--------------------------------------------------------------------------------
/modules/sandboxes/firebase-database-transaction/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "jsx": "react",
4 | "target": "es5",
5 | "module": "ESNext",
6 | "moduleResolution": "node",
7 | "lib": ["es2018", "dom"],
8 | "outDir": "./build/",
9 | "strict": true,
10 | "declaration": true,
11 | "removeComments": true,
12 | "allowSyntheticDefaultImports": true
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/modules/sandboxes/firestore-add-to-collection/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
3 | .cache
4 | build
--------------------------------------------------------------------------------
/modules/sandboxes/firestore-add-to-collection/config.ts:
--------------------------------------------------------------------------------
1 | export const config = {
2 | // DO NOT USE THESE CREDENTIALS ! THEY ARE HERE TO HELP IN THE LEARNING PROCESS.
3 | // ANY AND ALL DATA ON THAT DOMAIN IS SUBJECT TO CHANGE AND REMOVAL AT ANY TIME
4 | // THIS ACCOUNT IS ALSO ON THE FREE PLAN AND IS SUBJECT TO RESTRICTIONS !
5 | apiKey: "AIzaSyBIEgdW0FGGxQZ7bbbqIhzmiVAk7nnJB14",
6 | authDomain: "react-firebase-baecd.firebaseapp.com",
7 | databaseURL: "https://react-firebase-baecd.firebaseio.com",
8 | projectId: "react-firebase-baecd",
9 | storageBucket: "react-firebase-baecd.appspot.com",
10 | messagingSenderId: "6611069556"
11 | };
12 |
--------------------------------------------------------------------------------
/modules/sandboxes/firestore-add-to-collection/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Page Title
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/modules/sandboxes/firestore-add-to-collection/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "firestore-mutation-example",
3 | "version": "0.1.0",
4 | "description": "Firestore Collection Add Document Example",
5 | "main": "index.html",
6 | "repository": "https://github.com/rakannimer/react-firebase/",
7 | "author": "rakannimer",
8 | "license": "GPL-3.0",
9 | "private": false,
10 | "scripts": {
11 | "start": "parcel index.html"
12 | },
13 | "dependencies": {
14 | "@react-firebase/firestore": "^0.2.9",
15 | "firebase": "^5.4.1",
16 | "react": "^16.4.2",
17 | "react-dom": "^16.4.2"
18 | },
19 | "devDependencies": {
20 | "parcel-bundler": "^1.9.7",
21 | "prettier": "^1.14.2"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/modules/sandboxes/firestore-add-to-collection/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "jsx": "react",
4 | "target": "es5",
5 | "module": "ESNext",
6 | "moduleResolution": "node",
7 | "lib": ["es2018", "dom"],
8 | "outDir": "./build/",
9 | "strict": true,
10 | "declaration": true,
11 | "removeComments": true,
12 | "allowSyntheticDefaultImports": true
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/modules/sandboxes/firestore-batched-write/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
3 | .cache
4 | build
--------------------------------------------------------------------------------
/modules/sandboxes/firestore-batched-write/config.ts:
--------------------------------------------------------------------------------
1 | export const config = {
2 | // DO NOT USE THESE CREDENTIALS ! THEY ARE HERE TO HELP IN THE LEARNING PROCESS.
3 | // ANY AND ALL DATA ON THAT DOMAIN IS SUBJECT TO CHANGE AND REMOVAL AT ANY TIME
4 | // THIS ACCOUNT IS ALSO ON THE FREE PLAN AND IS SUBJECT TO RESTRICTIONS !
5 | apiKey: "AIzaSyBIEgdW0FGGxQZ7bbbqIhzmiVAk7nnJB14",
6 | authDomain: "react-firebase-baecd.firebaseapp.com",
7 | databaseURL: "https://react-firebase-baecd.firebaseio.com",
8 | projectId: "react-firebase-baecd",
9 | storageBucket: "react-firebase-baecd.appspot.com",
10 | messagingSenderId: "6611069556"
11 | };
12 |
--------------------------------------------------------------------------------
/modules/sandboxes/firestore-batched-write/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Page Title
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/modules/sandboxes/firestore-batched-write/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "firestore-batched-write-example",
3 | "version": "0.1.0",
4 | "description": "Firestore Batch Write Example",
5 | "main": "index.html",
6 | "repository": "https://github.com/rakannimer/react-firebase/",
7 | "author": "rakannimer",
8 | "license": "GPL-3.0",
9 | "private": false,
10 | "scripts": {
11 | "start": "parcel index.html"
12 | },
13 | "dependencies": {
14 | "@react-firebase/firestore": "^0.3.0",
15 | "firebase": "^5.4.1",
16 | "react": "^16.4.2",
17 | "react-dom": "^16.4.2"
18 | },
19 | "devDependencies": {
20 | "parcel-bundler": "^1.9.7",
21 | "prettier": "^1.14.2"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/modules/sandboxes/firestore-batched-write/src/index.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import { render } from "react-dom";
3 | import firebase from "firebase/app";
4 | import "firebase/firestore";
5 | import {
6 | FirestoreProvider,
7 | FirestoreDocument,
8 | FirestoreBatchedWrite
9 | } from "@react-firebase/firestore";
10 | import { config } from "../config";
11 |
12 | const styles = {
13 | fontFamily: "sans-serif"
14 | };
15 |
16 | const s = (a: any) => JSON.stringify(a, null, 2);
17 |
18 | const path = "user_bookmarks/test";
19 |
20 | const App = () => (
21 |
22 |
23 |
24 | {({ addMutationToBatch, commit }) => {
25 | return (
26 |
27 |
Batched write
28 |
40 |
50 |
51 | );
52 | }}
53 |
54 |
55 | {value => {
56 | return (
57 |
58 | {
{s(value)}
}
59 | {value.path &&
{value.path}
}
60 |
{value.isLoading}
61 |
62 | );
63 | }}
64 |
65 |
66 |
67 | );
68 |
69 | render(, document.getElementById("root"));
70 |
--------------------------------------------------------------------------------
/modules/sandboxes/firestore-batched-write/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "include": ["./src/"],
3 | "compilerOptions": {
4 | "jsx": "react",
5 | "target": "es5",
6 | "module": "ESNext",
7 | "moduleResolution": "node",
8 | "lib": ["es2018", "dom"],
9 | "outDir": "./build/",
10 | "strict": true,
11 | "declaration": true,
12 | "removeComments": true,
13 | "allowSyntheticDefaultImports": true
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/modules/sandboxes/firestore-collection-example/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
3 | .cache
4 | build
--------------------------------------------------------------------------------
/modules/sandboxes/firestore-collection-example/config.ts:
--------------------------------------------------------------------------------
1 | export const config = {
2 | // DO NOT USE THESE CREDENTIALS ! THEY ARE HERE TO HELP IN THE LEARNING PROCESS.
3 | // ANY AND ALL DATA ON THAT DOMAIN IS SUBJECT TO CHANGE AND REMOVAL AT ANY TIME
4 | // THIS ACCOUNT IS ALSO ON THE FREE PLAN AND IS SUBJECT TO RESTRICTIONS !
5 | apiKey: "AIzaSyBIEgdW0FGGxQZ7bbbqIhzmiVAk7nnJB14",
6 | authDomain: "react-firebase-baecd.firebaseapp.com",
7 | databaseURL: "https://react-firebase-baecd.firebaseio.com",
8 | projectId: "react-firebase-baecd",
9 | storageBucket: "react-firebase-baecd.appspot.com",
10 | messagingSenderId: "6611069556"
11 | };
12 |
--------------------------------------------------------------------------------
/modules/sandboxes/firestore-collection-example/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Page Title
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/modules/sandboxes/firestore-collection-example/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "firestore-example",
3 | "version": "0.1.0",
4 | "description": "Firestore Document or Collection Mutation Example",
5 | "main": "index.html",
6 | "repository": "https://github.com/rakannimer/react-firebase/",
7 | "author": "rakannimer",
8 | "license": "GPL-3.0",
9 | "private": false,
10 | "scripts": {
11 | "start": "parcel index.html --open"
12 | },
13 | "dependencies": {
14 | "@react-firebase/firestore": "^0.2.9",
15 | "firebase": "^5.4.1",
16 | "react": "^16.4.2",
17 | "react-dom": "^16.4.2"
18 | },
19 | "devDependencies": {
20 | "parcel-bundler": "^1.9.7",
21 | "prettier": "^1.14.2"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/modules/sandboxes/firestore-collection-example/src/index.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import { render } from "react-dom";
3 |
4 | import firebase from "firebase/app";
5 | import "firebase/firestore";
6 | import {
7 | FirestoreProvider,
8 | FirestoreCollection
9 | } from "@react-firebase/firestore";
10 | import { config } from "../config";
11 |
12 | const styles = {
13 | fontFamily: "sans-serif"
14 | };
15 |
16 | const s = (a: any) => JSON.stringify(a, null, 2);
17 |
18 | const App = () => {
19 | return (
20 |
21 |
22 |
23 |
24 | {d => {
25 | return {s(d)}
;
26 | }}
27 |
28 |
29 |
30 |
31 | );
32 | };
33 |
34 | render(, document.getElementById("root"));
35 |
--------------------------------------------------------------------------------
/modules/sandboxes/firestore-collection-example/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "jsx": "react",
4 | "target": "es5",
5 | "module": "ESNext",
6 | "moduleResolution": "node",
7 | "lib": ["es2018", "dom"],
8 | "outDir": "./build/",
9 | "strict": true,
10 | "declaration": true,
11 | "removeComments": true,
12 | "allowSyntheticDefaultImports": true
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/modules/sandboxes/firestore-infinite-list/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
3 | .cache
4 | build
--------------------------------------------------------------------------------
/modules/sandboxes/firestore-infinite-list/config.ts:
--------------------------------------------------------------------------------
1 | export const config = {
2 | // DO NOT USE THESE CREDENTIALS ! THEY ARE HERE TO HELP IN THE LEARNING PROCESS.
3 | // ANY AND ALL DATA ON THAT DOMAIN IS SUBJECT TO CHANGE AND REMOVAL AT ANY TIME
4 | // THIS ACCOUNT IS ALSO ON THE FREE PLAN AND IS SUBJECT TO RESTRICTIONS !
5 | apiKey: "AIzaSyBIEgdW0FGGxQZ7bbbqIhzmiVAk7nnJB14",
6 | authDomain: "react-firebase-baecd.firebaseapp.com",
7 | databaseURL: "https://react-firebase-baecd.firebaseio.com",
8 | projectId: "react-firebase-baecd",
9 | storageBucket: "react-firebase-baecd.appspot.com",
10 | messagingSenderId: "6611069556"
11 | };
12 |
--------------------------------------------------------------------------------
/modules/sandboxes/firestore-infinite-list/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Page Title
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/modules/sandboxes/firestore-infinite-list/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "firestore-infinite-list",
3 | "version": "0.1.0",
4 | "description": "Firestore Infinite List Example",
5 | "main": "index.html",
6 | "repository": "https://github.com/rakannimer/react-firebase/",
7 | "author": "rakannimer",
8 | "license": "GPL-3.0",
9 | "private": false,
10 | "scripts": {
11 | "start": "parcel index.html"
12 | },
13 | "dependencies": {
14 | "@react-firebase/firestore": "^0.2.9",
15 | "firebase": "^5.4.1",
16 | "react": "^16.4.2",
17 | "react-dom": "^16.4.2"
18 | },
19 | "devDependencies": {
20 | "parcel-bundler": "^1.9.7",
21 | "prettier": "^1.14.2"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/modules/sandboxes/firestore-infinite-list/src/index.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import { render } from "react-dom";
3 | import firebase from "firebase/app";
4 | import "firebase/firestore";
5 | import {
6 | FirestoreCollection,
7 | FirestoreProvider
8 | } from "@react-firebase/firestore";
9 | import { config } from "../config";
10 | const s = (a: any) => JSON.stringify(a, null, 2);
11 |
12 | export type InfiniteListState = {
13 | page: number;
14 | pageLength: number;
15 | };
16 |
17 | export class InfiniteList extends React.Component {
18 | state = {
19 | page: 0,
20 | pageLength: 1
21 | };
22 | render() {
23 | return (
24 |
25 |
26 |
31 | {({ value }) => {
32 | return (
33 |
36 | );
37 | }}
38 |
39 |
40 |
50 |
51 | );
52 | }
53 | }
54 |
55 | const App = InfiniteList;
56 |
57 | render(, document.getElementById("root"));
58 |
--------------------------------------------------------------------------------
/modules/sandboxes/firestore-infinite-list/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "jsx": "react",
4 | "target": "es5",
5 | "module": "ESNext",
6 | "moduleResolution": "node",
7 | "lib": ["es2018", "dom"],
8 | "outDir": "./build/",
9 | "strict": true,
10 | "declaration": true,
11 | "removeComments": true,
12 | "allowSyntheticDefaultImports": true
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/modules/sandboxes/firestore-mutation-example/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
3 | .cache
4 | build
--------------------------------------------------------------------------------
/modules/sandboxes/firestore-mutation-example/config.ts:
--------------------------------------------------------------------------------
1 | export const config = {
2 | // DO NOT USE THESE CREDENTIALS ! THEY ARE HERE TO HELP IN THE LEARNING PROCESS.
3 | // ANY AND ALL DATA ON THAT DOMAIN IS SUBJECT TO CHANGE AND REMOVAL AT ANY TIME
4 | // THIS ACCOUNT IS ALSO ON THE FREE PLAN AND IS SUBJECT TO RESTRICTIONS !
5 | apiKey: "AIzaSyBIEgdW0FGGxQZ7bbbqIhzmiVAk7nnJB14",
6 | authDomain: "react-firebase-baecd.firebaseapp.com",
7 | databaseURL: "https://react-firebase-baecd.firebaseio.com",
8 | projectId: "react-firebase-baecd",
9 | storageBucket: "react-firebase-baecd.appspot.com",
10 | messagingSenderId: "6611069556"
11 | };
12 |
--------------------------------------------------------------------------------
/modules/sandboxes/firestore-mutation-example/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Page Title
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/modules/sandboxes/firestore-mutation-example/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "firestore-mutation-example",
3 | "version": "0.1.0",
4 | "description": "Firestore Document or Collection Mutation Example",
5 | "main": "index.html",
6 | "repository": "https://github.com/rakannimer/react-firebase/",
7 | "author": "rakannimer",
8 | "license": "GPL-3.0",
9 | "private": false,
10 | "scripts": {
11 | "start": "parcel index.html"
12 | },
13 | "dependencies": {
14 | "@react-firebase/firestore": "^0.2.9",
15 | "firebase": "^5.4.1",
16 | "react": "^16.4.2",
17 | "react-dom": "^16.4.2"
18 | },
19 | "devDependencies": {
20 | "parcel-bundler": "^1.9.7",
21 | "prettier": "^1.14.2"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/modules/sandboxes/firestore-mutation-example/src/index.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import { render } from "react-dom";
3 | import firebase from "firebase/app";
4 | import "firebase/firestore";
5 | import {
6 | FirestoreProvider,
7 | FirestoreDocument,
8 | FirestoreMutation
9 | } from "@react-firebase/firestore";
10 | import { config } from "../config";
11 |
12 | const styles = {
13 | fontFamily: "sans-serif"
14 | };
15 |
16 | const s = (a: any) => JSON.stringify(a, null, 2);
17 |
18 | const path = "user_bookmarks/test";
19 |
20 | const App = () => (
21 |
22 |
23 |
24 | {({ runMutation }) => {
25 | return (
26 |
27 |
Mutate state
28 |
40 |
41 | );
42 | }}
43 |
44 |
45 | {value => {
46 | return (
47 |
48 | {value.value &&
{s(value.value)}
}
49 | {value.path &&
{value.path}
}
50 |
{value.isLoading}
51 |
52 | );
53 | }}
54 |
55 |
56 |
57 | );
58 |
59 | render(, document.getElementById("root"));
60 |
--------------------------------------------------------------------------------
/modules/sandboxes/firestore-mutation-example/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "include": ["./src/"],
3 | "compilerOptions": {
4 | "jsx": "react",
5 | "target": "es5",
6 | "module": "ESNext",
7 | "moduleResolution": "node",
8 | "lib": ["es2018", "dom"],
9 | "outDir": "./build/",
10 | "strict": true,
11 | "declaration": true,
12 | "removeComments": true,
13 | "allowSyntheticDefaultImports": true
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/modules/sandboxes/firestore-transaction/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
3 | .cache
4 | build
--------------------------------------------------------------------------------
/modules/sandboxes/firestore-transaction/config.ts:
--------------------------------------------------------------------------------
1 | export const config = {
2 | // DO NOT USE THESE CREDENTIALS ! THEY ARE HERE TO HELP IN THE LEARNING PROCESS.
3 | // ANY AND ALL DATA ON THAT DOMAIN IS SUBJECT TO CHANGE AND REMOVAL AT ANY TIME
4 | // THIS ACCOUNT IS ALSO ON THE FREE PLAN AND IS SUBJECT TO RESTRICTIONS !
5 | apiKey: "AIzaSyBIEgdW0FGGxQZ7bbbqIhzmiVAk7nnJB14",
6 | authDomain: "react-firebase-baecd.firebaseapp.com",
7 | databaseURL: "https://react-firebase-baecd.firebaseio.com",
8 | projectId: "react-firebase-baecd",
9 | storageBucket: "react-firebase-baecd.appspot.com",
10 | messagingSenderId: "6611069556"
11 | };
12 |
--------------------------------------------------------------------------------
/modules/sandboxes/firestore-transaction/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Page Title
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/modules/sandboxes/firestore-transaction/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "firestore-tranasction-example",
3 | "version": "0.1.0",
4 | "description": "Firestore Batch Write Example",
5 | "main": "index.html",
6 | "repository": "https://github.com/rakannimer/react-firebase/",
7 | "author": "rakannimer",
8 | "license": "GPL-3.0",
9 | "private": false,
10 | "scripts": {
11 | "start": "parcel index.html"
12 | },
13 | "dependencies": {
14 | "@react-firebase/firestore": "^0.2.9",
15 | "firebase": "^5.4.1",
16 | "react": "^16.4.2",
17 | "react-dom": "^16.4.2"
18 | },
19 | "devDependencies": {
20 | "parcel-bundler": "^1.9.7",
21 | "prettier": "^1.14.2"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/modules/sandboxes/firestore-transaction/src/index.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import { render } from "react-dom";
3 | import firebase from "firebase/app";
4 | import "firebase/firestore";
5 | import {
6 | FirestoreProvider,
7 | FirestoreDocument,
8 | FirestoreTransaction
9 | } from "@react-firebase/firestore";
10 | import { config } from "../config";
11 |
12 | const styles = {
13 | fontFamily: "sans-serif"
14 | };
15 |
16 | const s = (a: any) => JSON.stringify(a, null, 2);
17 |
18 | const path = "user_bookmarks/test";
19 |
20 | const App = () => (
21 |
22 |
23 |
24 | {({ runTransaction }) => {
25 | return (
26 |
27 |
45 |
46 | );
47 | }}
48 |
49 |
50 | {d => {
51 | return (
52 |
53 | {d.value &&
54 | d.value.a && (
55 |
56 | {JSON.stringify(d.value.a)}
57 |
58 | )}
59 | {d.path &&
{d.path}
}
60 |
{d.isLoading}
61 |
62 | );
63 | }}
64 |
65 |
66 |
67 | );
68 |
69 | render(, document.getElementById("root"));
70 |
--------------------------------------------------------------------------------
/modules/sandboxes/firestore-transaction/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "jsx": "react",
4 | "target": "es5",
5 | "module": "ESNext",
6 | "moduleResolution": "node",
7 | "lib": ["es2018", "dom"],
8 | "outDir": "./build/",
9 | "strict": true,
10 | "declaration": true,
11 | "removeComments": true,
12 | "allowSyntheticDefaultImports": true
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/modules/tutorial-bookmarking-app/.gitignore:
--------------------------------------------------------------------------------
1 | # parcel cache
2 | .cache
3 | .vscode
4 |
5 | dist
6 | node_modules
--------------------------------------------------------------------------------
/modules/tutorial-bookmarking-app/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "tutorial-bookmarking-app",
3 | "version": "1.0.0",
4 | "main": "src/index.html",
5 | "license": "MIT",
6 | "devDependencies": {
7 | "@types/lodash.get": "^4.4.4",
8 | "@types/lodash.set": "^4.3.4",
9 | "@types/match-sorter": "^2.2.0",
10 | "@types/react": "^16.4.11",
11 | "@types/react-dom": "^16.0.7",
12 | "parcel-bundler": "^1.9.7",
13 | "prettier": "^1.14.2",
14 | "typescript": "^3.0.1"
15 | },
16 | "scripts": {
17 | "dev": "parcel src/index.html"
18 | },
19 | "dependencies": {
20 | "@material-ui/core": "^1.5.1",
21 | "@material-ui/icons": "^2.0.3",
22 | "@react-firebase/auth": "^0.1.8",
23 | "@react-firebase/database": "0.2.7",
24 | "downshift": "^2.1.5",
25 | "firebase": "^5.4.0",
26 | "lodash.get": "^4.4.2",
27 | "lodash.set": "^4.3.2",
28 | "match-sorter": "^2.2.3",
29 | "react": "^16.4.2",
30 | "react-dom": "^16.4.2",
31 | "react-powerplug": "^1.0.0-rc.1"
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/modules/tutorial-bookmarking-app/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/modules/tutorial-bookmarking-app/src/test-credentials.ts:
--------------------------------------------------------------------------------
1 | export const config = {
2 | apiKey: "AIzaSyBIEgdW0FGGxQZ7bbbqIhzmiVAk7nnJB14",
3 | authDomain: "react-firebase-baecd.firebaseapp.com",
4 | databaseURL: "https://react-firebase-baecd.firebaseio.com",
5 | projectId: "react-firebase-baecd",
6 | storageBucket: "react-firebase-baecd.appspot.com",
7 | messagingSenderId: "6611069556"
8 | };
9 |
--------------------------------------------------------------------------------
/modules/tutorial-bookmarking-app/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "jsx": "react",
4 | "target": "es5",
5 | "module": "commonjs",
6 | "lib": ["dom", "es2017"],
7 |
8 | "strict": true,
9 | "esModuleInterop": true
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "private": true,
3 | "name": "react-firebase",
4 | "workspaces": [
5 | "modules/*"
6 | ],
7 | "scripts": {
8 | "test:auth": "cd modules/auth && yarn test",
9 | "test:database": "cd modules/database && yarn test",
10 | "test:firestore": "cd modules/firestore && yarn test",
11 | "test": "yarn test:auth && yarn test:database && yarn test:firestore"
12 | },
13 | "repository": {
14 | "url": "https://github.com/rakannimer/react-firebase"
15 | },
16 | "devDependencies": {}
17 | }
18 |
--------------------------------------------------------------------------------
/react-firebase.code-workspace:
--------------------------------------------------------------------------------
1 | {
2 | "folders": [
3 | {
4 | "path": "modules/sandboxes"
5 | },
6 | {
7 | "path": "modules/database"
8 | },
9 | {
10 | "path": "modules/react-firebase-docs"
11 | },
12 | {
13 | "path": "modules/firestore"
14 | },
15 | {
16 | "path": "modules/auth"
17 | },
18 | {
19 | "path": "modules/hooks"
20 | },
21 | {
22 | "path": "modules/generate-json"
23 | },
24 | {
25 | "path": "modules/generate-firestore-data"
26 | },
27 | {
28 | "path": "modules/generate-firebase-data"
29 | },
30 | {
31 | "path": "modules/tutorial-bookmarking-app"
32 | },
33 | {
34 | "path": "react-native-examples/react-native-firebase-starter/"
35 | },
36 | {
37 | "path": "react-native-examples/react-native-expo-firebase-example/"
38 | },
39 | {
40 | "path": "./"
41 | }
42 | ],
43 | "settings": {}
44 | }
45 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-expo-firebase-example/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["babel-preset-expo"],
3 | "env": {
4 | "development": {
5 | "plugins": ["transform-react-jsx-source"]
6 | }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-expo-firebase-example/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # expo
4 | .expo/
5 |
6 | # dependencies
7 | /node_modules
8 |
9 | # misc
10 | .env.local
11 | .env.development.local
12 | .env.test.local
13 | .env.production.local
14 |
15 | npm-debug.log*
16 | yarn-debug.log*
17 | yarn-error.log*
18 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-expo-firebase-example/.watchmanconfig:
--------------------------------------------------------------------------------
1 | {}
2 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-expo-firebase-example/App.test.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import App from './App';
3 |
4 | import renderer from 'react-test-renderer';
5 |
6 | it('renders without crashing', () => {
7 | const rendered = renderer.create().toJSON();
8 | expect(rendered).toBeTruthy();
9 | });
10 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-expo-firebase-example/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "expo": {
3 | "sdkVersion": "27.0.0"
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-expo-firebase-example/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-native-expo-firebase-example",
3 | "version": "0.1.0",
4 | "private": true,
5 | "devDependencies": {
6 | "jest-expo": "~27.0.0",
7 | "prettier": "^1.14.2",
8 | "react-native-scripts": "1.14.0",
9 | "react-test-renderer": "16.3.1"
10 | },
11 | "main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
12 | "scripts": {
13 | "start": "react-native-scripts start",
14 | "eject": "react-native-scripts eject",
15 | "android": "react-native-scripts android",
16 | "ios": "react-native-scripts ios",
17 | "test": "jest"
18 | },
19 | "jest": {
20 | "preset": "jest-expo"
21 | },
22 | "dependencies": {
23 | "@react-firebase/auth": "^0.2.2",
24 | "@react-firebase/database": "^0.2.13",
25 | "expo": "^27.0.1",
26 | "firebase": "^5.4.1",
27 | "react": "16.3.1",
28 | "react-native": "~0.55.2"
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-expo-firebase-example/test-credentials.js:
--------------------------------------------------------------------------------
1 | export const config = {
2 | apiKey: "AIzaSyBIEgdW0FGGxQZ7bbbqIhzmiVAk7nnJB14",
3 | authDomain: "react-firebase-baecd.firebaseapp.com",
4 | databaseURL: "https://react-firebase-baecd.firebaseio.com",
5 | projectId: "react-firebase-baecd",
6 | storageBucket: "react-firebase-baecd.appspot.com",
7 | messagingSenderId: "6611069556"
8 | };
9 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | "babel-preset-react-native-stage-0/decorator-support"
4 | ],
5 | "env": {
6 | "development": {
7 | "plugins": [
8 | "transform-react-jsx-source"
9 | ]
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/.buckconfig:
--------------------------------------------------------------------------------
1 |
2 | [android]
3 | target = Google Inc.:Google APIs:23
4 |
5 | [maven_repositories]
6 | central = https://repo1.maven.org/maven2
7 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/.editorconfig:
--------------------------------------------------------------------------------
1 | # editorconfig.org
2 | root = true
3 |
4 | [*]
5 | indent_style = space
6 | indent_size = 2
7 | end_of_line = lf
8 | charset = utf-8
9 | trim_trailing_whitespace = true
10 | insert_final_newline = true
11 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/.flowconfig:
--------------------------------------------------------------------------------
1 | [ignore]
2 | ; We fork some components by platform
3 | .*/*[.]android.js
4 |
5 | ; Ignore "BUCK" generated dirs
6 | /\.buckd/
7 |
8 | ; Ignore unexpected extra "@providesModule"
9 | .*/node_modules/.*/node_modules/fbjs/.*
10 |
11 | ; Ignore duplicate module providers
12 | ; For RN Apps installed via npm, "Libraries" folder is inside
13 | ; "node_modules/react-native" but in the source repo it is in the root
14 | .*/Libraries/react-native/React.js
15 |
16 | ; Ignore polyfills
17 | .*/Libraries/polyfills/.*
18 |
19 | ; Ignore metro
20 | .*/node_modules/metro/.*
21 |
22 | [include]
23 |
24 | [libs]
25 | node_modules/react-native/Libraries/react-native/react-native-interface.js
26 | node_modules/react-native/flow/
27 | node_modules/react-native/flow-github/
28 |
29 | [options]
30 | emoji=true
31 |
32 | module.system=haste
33 |
34 | munge_underscores=true
35 |
36 | module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
37 |
38 | module.file_ext=.js
39 | module.file_ext=.jsx
40 | module.file_ext=.json
41 | module.file_ext=.native.js
42 |
43 | suppress_type=$FlowIssue
44 | suppress_type=$FlowFixMe
45 | suppress_type=$FlowFixMeProps
46 | suppress_type=$FlowFixMeState
47 |
48 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
49 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
50 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
51 | suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
52 |
53 | [version]
54 | ^0.67.0
55 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/.gitattributes:
--------------------------------------------------------------------------------
1 | *.pbxproj -text
2 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/.gitignore:
--------------------------------------------------------------------------------
1 | # OSX
2 | #
3 | .DS_Store
4 |
5 | # Xcode
6 | #
7 | build/
8 | *.pbxuser
9 | !default.pbxuser
10 | *.mode1v3
11 | !default.mode1v3
12 | *.mode2v3
13 | !default.mode2v3
14 | *.perspectivev3
15 | !default.perspectivev3
16 | xcuserdata
17 | *.xccheckout
18 | *.moved-aside
19 | DerivedData
20 | *.hmap
21 | *.ipa
22 | *.xcuserstate
23 | project.xcworkspace
24 |
25 | # Android/IntelliJ
26 | #
27 | build/
28 | .idea
29 | .gradle
30 | local.properties
31 | *.iml
32 |
33 | # node.js
34 | #
35 | node_modules/
36 | npm-debug.log
37 | yarn-error.log
38 |
39 | # BUCK
40 | buck-out/
41 | \.buckd/
42 | *.keystore
43 |
44 | # fastlane
45 | #
46 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
47 | # screenshots whenever they are needed.
48 | # For more information about the recommended setup visit:
49 | # https://docs.fastlane.tools/best-practices/source-control/
50 |
51 | */fastlane/report.xml
52 | */fastlane/Preview.html
53 | */fastlane/screenshots
54 |
55 | # Bundle artifact
56 | *.jsbundle
57 |
58 | # RNFirebase specific
59 | #
60 | .expo/
61 | /ios/Pods/
62 | # google-services.json
63 | # GoogleService-Info.plist
64 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/.opensource/project.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "React Native Firebase Starter",
3 | "type": "sample",
4 | "platforms": ["Android", "iOS"],
5 | "content": "README.md",
6 | "related": ["invertase/react-native-firebase"]
7 | }
8 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/.watchmanconfig:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/App.test.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import App from './App';
3 |
4 | import renderer from 'react-test-renderer';
5 |
6 | it('renders without crashing', () => {
7 | const rendered = renderer.create().toJSON();
8 | expect(rendered).toBeTruthy();
9 | });
10 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2017 Invertase Limited
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this library except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/android/.editorconfig:
--------------------------------------------------------------------------------
1 | # editorconfig.org
2 | root = true
3 |
4 | [*]
5 | indent_style = space
6 | indent_size = 2
7 | end_of_line = lf
8 | charset = utf-8
9 | trim_trailing_whitespace = true
10 | insert_final_newline = true
11 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/android/app/BUCK:
--------------------------------------------------------------------------------
1 | # To learn about Buck see [Docs](https://buckbuild.com/).
2 | # To run your application with Buck:
3 | # - install Buck
4 | # - `npm start` - to start the packager
5 | # - `cd android`
6 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
7 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
8 | # - `buck install -r android/app` - compile, install and run application
9 | #
10 |
11 | lib_deps = []
12 |
13 | for jarfile in glob(['libs/*.jar']):
14 | name = 'jars__' + jarfile[jarfile.rindex('/') + 1: jarfile.rindex('.jar')]
15 | lib_deps.append(':' + name)
16 | prebuilt_jar(
17 | name = name,
18 | binary_jar = jarfile,
19 | )
20 |
21 | for aarfile in glob(['libs/*.aar']):
22 | name = 'aars__' + aarfile[aarfile.rindex('/') + 1: aarfile.rindex('.aar')]
23 | lib_deps.append(':' + name)
24 | android_prebuilt_aar(
25 | name = name,
26 | aar = aarfile,
27 | )
28 |
29 | android_library(
30 | name = "all-libs",
31 | exported_deps = lib_deps,
32 | )
33 |
34 | android_library(
35 | name = "app-code",
36 | srcs = glob([
37 | "src/main/java/**/*.java",
38 | ]),
39 | deps = [
40 | ":all-libs",
41 | ":build_config",
42 | ":res",
43 | ],
44 | )
45 |
46 | android_build_config(
47 | name = "build_config",
48 | package = "com.reactfirebase.reactfirebaseexample",
49 | )
50 |
51 | android_resource(
52 | name = "res",
53 | package = "com.reactfirebase.reactfirebaseexample",
54 | res = "src/main/res",
55 | )
56 |
57 | android_binary(
58 | name = "app",
59 | keystore = "//android/keystores:debug",
60 | manifest = "src/main/AndroidManifest.xml",
61 | package_type = "debug",
62 | deps = [
63 | ":app-code",
64 | ],
65 | )
66 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
15 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/android/app/src/main/java/com/reactfirebase/reactfirebaseexample/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.reactfirebase.reactfirebaseexample;
2 |
3 | import com.facebook.react.ReactActivity;
4 |
5 | public class MainActivity extends ReactActivity {
6 |
7 | /**
8 | * Returns the name of the main component registered from JavaScript.
9 | * This is used to schedule rendering of the component.
10 | */
11 | @Override
12 | protected String getMainComponentName() {
13 | return "reactfirebaseexample";
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakannimer/react-firebase/ed3db6aba5563c78163b84c94da806a9c9d18dde/react-native-examples/react-native-firebase-starter/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakannimer/react-firebase/ed3db6aba5563c78163b84c94da806a9c9d18dde/react-native-examples/react-native-firebase-starter/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakannimer/react-firebase/ed3db6aba5563c78163b84c94da806a9c9d18dde/react-native-examples/react-native-firebase-starter/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakannimer/react-firebase/ed3db6aba5563c78163b84c94da806a9c9d18dde/react-native-examples/react-native-firebase-starter/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/android/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | reactfirebaseexample
3 |
4 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/android/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 |
6 | jcenter()
7 | google()
8 | maven {
9 | url 'https://maven.fabric.io/public'
10 | }
11 | }
12 | dependencies {
13 | classpath 'com.android.tools.build:gradle:3.1.3'
14 | classpath 'com.google.gms:google-services:4.0.1'
15 | classpath 'com.google.firebase:firebase-plugins:1.1.1'
16 | classpath 'io.fabric.tools:gradle:1.25.4'
17 | // NOTE: Do not place your application dependencies here; they belong
18 | // in the individual module build.gradle files
19 | }
20 | }
21 |
22 | allprojects {
23 | repositories {
24 | mavenLocal()
25 | jcenter()
26 | google()
27 | maven {
28 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
29 | url "$rootDir/../node_modules/react-native/android"
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/android/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 |
20 | org.gradle.daemon=true
21 | org.gradle.parallel=true
22 | android.useDeprecatedNdk=true
23 | org.gradle.configureondemand=true
24 | org.gradle.jvmargs=-Xmx3g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
25 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakannimer/react-firebase/ed3db6aba5563c78163b84c94da806a9c9d18dde/react-native-examples/react-native-firebase-starter/android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | zipStoreBase=GRADLE_USER_HOME
4 | zipStorePath=wrapper/dists
5 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
6 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/android/keystores/BUCK:
--------------------------------------------------------------------------------
1 | keystore(
2 | name = "debug",
3 | properties = "debug.keystore.properties",
4 | store = "debug.keystore",
5 | visibility = [
6 | "PUBLIC",
7 | ],
8 | )
9 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/android/keystores/debug.keystore.properties:
--------------------------------------------------------------------------------
1 | key.store=debug.keystore
2 | key.alias=androiddebugkey
3 | key.store.password=android
4 | key.alias.password=android
5 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/android/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'reactfirebaseexample'
2 | include ':react-native-firebase'
3 | project(':react-native-firebase').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-firebase/android')
4 |
5 | include ':app'
6 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "reactfirebaseexample",
3 | "displayName": "reactfirebaseexample"
4 | }
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/assets/RNFirebase.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakannimer/react-firebase/ed3db6aba5563c78163b84c94da806a9c9d18dde/react-native-examples/react-native-firebase-starter/assets/RNFirebase.png
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/index.js:
--------------------------------------------------------------------------------
1 | import { AppRegistry } from 'react-native';
2 | import App from './App';
3 | AppRegistry.registerComponent('reactfirebaseexample', () => App);
4 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/ios/GoogleService-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | AD_UNIT_ID_FOR_BANNER_TEST
6 | ca-app-pub-3940256099942544/2934735716
7 | AD_UNIT_ID_FOR_INTERSTITIAL_TEST
8 | ca-app-pub-3940256099942544/4411468910
9 | CLIENT_ID
10 | 6611069556-qsehbjoki9l6l31sk7e4kglkfjvjofub.apps.googleusercontent.com
11 | REVERSED_CLIENT_ID
12 | com.googleusercontent.apps.6611069556-qsehbjoki9l6l31sk7e4kglkfjvjofub
13 | API_KEY
14 | AIzaSyDM2ghD0mW8u6uWn6m3Zp6yq7-F7z5_6oE
15 | GCM_SENDER_ID
16 | 6611069556
17 | PLIST_VERSION
18 | 1
19 | BUNDLE_ID
20 | com.reactfirebase.reactfirebaseexample
21 | PROJECT_ID
22 | react-firebase-baecd
23 | STORAGE_BUCKET
24 | react-firebase-baecd.appspot.com
25 | IS_ADS_ENABLED
26 |
27 | IS_ANALYTICS_ENABLED
28 |
29 | IS_APPINVITE_ENABLED
30 |
31 | IS_GCM_ENABLED
32 |
33 | IS_SIGNIN_ENABLED
34 |
35 | GOOGLE_APP_ID
36 | 1:6611069556:ios:855aece9994893c6
37 | DATABASE_URL
38 | https://react-firebase-baecd.firebaseio.com
39 |
40 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/ios/Podfile:
--------------------------------------------------------------------------------
1 | # Uncomment the next line to define a global platform for your project
2 | platform :ios, '9.0'
3 |
4 | target 'reactfirebaseexample' do
5 | # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
6 | # use_frameworks!
7 |
8 | # Pods for reactfirebaseexample
9 |
10 | # Required by RNFirebase
11 | pod 'Firebase/Core', '~> 5.3.0'
12 |
13 | # [OPTIONAL PODS] - comment out pods for firebase products you won't be using.
14 | pod 'Firebase/AdMob', '~> 5.3.0'
15 | pod 'Firebase/Auth', '~> 5.3.0'
16 | pod 'Firebase/Crash', '~> 5.3.0'
17 | pod 'Firebase/Database', '~> 5.3.0'
18 | pod 'Firebase/Functions', '~> 5.3.0'
19 | pod 'Firebase/DynamicLinks', '~> 5.3.0'
20 | pod 'Firebase/Firestore', '~> 5.3.0'
21 | # pod 'Firebase/Invites', '~> 5.3.0'
22 | pod 'Firebase/Messaging', '~> 5.3.0'
23 | pod 'Firebase/RemoteConfig', '~> 5.3.0'
24 | pod 'Firebase/Storage', '~> 5.3.0'
25 | pod 'Firebase/Performance', '~> 5.3.0'
26 | pod 'Fabric', '~> 1.7.5'
27 | pod 'Crashlytics', '~> 3.10.4'
28 |
29 | end
30 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/ios/reactfirebaseexample-tvOS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | UIViewControllerBasedStatusBarAppearance
38 |
39 | NSLocationWhenInUseUsageDescription
40 |
41 | NSAppTransportSecurity
42 |
43 |
44 | NSExceptionDomains
45 |
46 | localhost
47 |
48 | NSExceptionAllowsInsecureHTTPLoads
49 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/ios/reactfirebaseexample-tvOSTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/ios/reactfirebaseexample.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/ios/reactfirebaseexample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/ios/reactfirebaseexample/AppDelegate.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-present, Facebook, Inc.
3 | *
4 | * This source code is licensed under the MIT license found in the
5 | * LICENSE file in the root directory of this source tree.
6 | */
7 |
8 | #import
9 |
10 | @interface AppDelegate : UIResponder
11 |
12 | @property (nonatomic, strong) UIWindow *window;
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/ios/reactfirebaseexample/AppDelegate.m:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-present, Facebook, Inc.
3 | *
4 | * This source code is licensed under the MIT license found in the
5 | * LICENSE file in the root directory of this source tree.
6 | */
7 |
8 | #import "AppDelegate.h"
9 |
10 | #import
11 | #import
12 | #import
13 |
14 | @implementation AppDelegate
15 |
16 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
17 | {
18 | [FIRApp configure];
19 | NSURL *jsCodeLocation;
20 | jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
21 |
22 | RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
23 | moduleName:@"reactfirebaseexample"
24 | initialProperties:nil
25 | launchOptions:launchOptions];
26 | rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
27 |
28 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
29 | UIViewController *rootViewController = [UIViewController new];
30 | rootViewController.view = rootView;
31 | self.window.rootViewController = rootViewController;
32 | [self.window makeKeyAndVisible];
33 | return YES;
34 | }
35 |
36 | @end
37 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/ios/reactfirebaseexample/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/ios/reactfirebaseexample/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | $(DISPLAY_NAME)
9 | CFBundleExecutable
10 | $(EXECUTABLE_NAME)
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(DISPLAY_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1
25 | LSRequiresIPhoneOS
26 |
27 | UILaunchStoryboardName
28 | LaunchScreen
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 | UIViewControllerBasedStatusBarAppearance
40 |
41 | NSLocationWhenInUseUsageDescription
42 |
43 | NSAppTransportSecurity
44 |
45 |
46 | NSExceptionDomains
47 |
48 | localhost
49 |
50 | NSExceptionAllowsInsecureHTTPLoads
51 |
52 |
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/ios/reactfirebaseexample/main.m:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-present, Facebook, Inc.
3 | *
4 | * This source code is licensed under the MIT license found in the
5 | * LICENSE file in the root directory of this source tree.
6 | */
7 |
8 | #import
9 |
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/ios/reactfirebaseexampleTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/ios/reactfirebaseexampleTests/reactfirebaseexampleTests.m:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015-present, Facebook, Inc.
3 | *
4 | * This source code is licensed under the MIT license found in the
5 | * LICENSE file in the root directory of this source tree.
6 | */
7 |
8 | #import
9 | #import
10 |
11 | #import
12 | #import
13 |
14 | #define TIMEOUT_SECONDS 600
15 | #define TEXT_TO_LOOK_FOR @"Welcome to React Native!"
16 |
17 | @interface reactfirebaseexampleTests : XCTestCase
18 |
19 | @end
20 |
21 | @implementation reactfirebaseexampleTests
22 |
23 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test
24 | {
25 | if (test(view)) {
26 | return YES;
27 | }
28 | for (UIView *subview in [view subviews]) {
29 | if ([self findSubviewInView:subview matching:test]) {
30 | return YES;
31 | }
32 | }
33 | return NO;
34 | }
35 |
36 | - (void)testRendersWelcomeScreen
37 | {
38 | UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController];
39 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS];
40 | BOOL foundElement = NO;
41 |
42 | __block NSString *redboxError = nil;
43 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) {
44 | if (level >= RCTLogLevelError) {
45 | redboxError = message;
46 | }
47 | });
48 |
49 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) {
50 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
51 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
52 |
53 | foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) {
54 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) {
55 | return YES;
56 | }
57 | return NO;
58 | }];
59 | }
60 |
61 | RCTSetLogFunction(RCTDefaultLogFunction);
62 |
63 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError);
64 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS);
65 | }
66 |
67 |
68 | @end
69 |
--------------------------------------------------------------------------------
/react-native-examples/react-native-firebase-starter/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "reactfirebaseexample",
3 | "version": "0.1.0",
4 | "private": true,
5 | "devDependencies": {
6 | "babel-jest": "^23.4.0",
7 | "babel-preset-react-native-stage-0": "^1.0.1",
8 | "fs-extra": "^6.0.1",
9 | "jest": "^23.4.0",
10 | "prettier": "^1.14.2",
11 | "react-test-renderer": "^16.4.1",
12 | "replace-in-file": "^3.4.0"
13 | },
14 | "scripts": {
15 | "android": "react-native run-android",
16 | "ios": "react-native run-ios",
17 | "rename": "node ./bin/rename.js",
18 | "start": "react-native start",
19 | "test": "jest"
20 | },
21 | "jest": {
22 | "preset": "react-native"
23 | },
24 | "dependencies": {
25 | "@react-firebase/auth": "^0.2.4",
26 | "@react-firebase/database": "^0.2.14",
27 | "@react-firebase/firestore": "^0.3.0",
28 | "fbjs": "^0.8.17",
29 | "react": "^16.3.2",
30 | "react-native": "^0.55.3",
31 | "react-native-firebase": "^4.3.6"
32 | }
33 | }
34 |
--------------------------------------------------------------------------------