Skip to content

Commit 4f94a58

Browse files
jessewashburndogi
andauthored
Jules api integration (fixes #45) (#46)
Co-authored-by: dogi <[email protected]>
1 parent 92e1774 commit 4f94a58

File tree

6 files changed

+820
-0
lines changed

6 files changed

+820
-0
lines changed

.gitignore

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Node.js
2+
node_modules/
3+
npm-debug.log
4+
yarn-error.log
5+
6+
# Firebase
7+
.firebaserc
8+
.runtimeconfig.json
9+
10+
# Environment files
11+
.env
12+
.env.local
13+
.env.*.local
14+
15+
# IDE
16+
.vscode/
17+
.idea/
18+
*.swp
19+
*.swo
20+
*~
21+
22+
# OS
23+
.DS_Store
24+
Thumbs.db
25+
26+
# Build/Dist
27+
dist/
28+
build/
29+
30+
# Logs
31+
*.log
32+
logs/
33+
34+
# Documentation (local setup notes - not needed in repo)
35+
*SETUP*.md
36+
*IMPLEMENTATION*.md
37+
*VERIFICATION*.md
38+
*FIREBASE*.md
39+
*CLOUD_FUNCTIONS*.md
40+
*INTEGRATION*.md
41+
*REFERENCE*.md

firebase-init.js

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// Firebase initialization wrapper for browser environment
2+
// This file initializes Firebase using the modular SDK
3+
4+
// Check if we're in a browser and Firebase can be loaded
5+
window.firebaseReady = false;
6+
window.firebaseError = null;
7+
8+
// Firebase configuration
9+
const firebaseConfig = {
10+
apiKey: "AIzaSyBBM7OVM3-jwHky-1P_6JL4RAmzhebuDPg",
11+
authDomain: "prompt-sharing-f8eeb.firebaseapp.com",
12+
projectId: "prompt-sharing-f8eeb",
13+
storageBucket: "prompt-sharing-f8eeb.firebasestorage.app",
14+
messagingSenderId: "840037476057",
15+
appId: "1:840037476057:web:a8ca03b1defe94071e80c8",
16+
measurementId: "G-8QR07NVLML"
17+
};
18+
19+
// Initialize Firebase when modular SDK is available
20+
function initFirebaseWhenReady() {
21+
try {
22+
// Using the global firebase namespace that should be available after SDK loads
23+
if (typeof firebase !== 'undefined' && firebase.initializeApp) {
24+
// Initialize app
25+
const app = firebase.initializeApp(firebaseConfig);
26+
console.log('Firebase initialized successfully');
27+
28+
// Get services - compat API doesn't require app parameter
29+
window.auth = firebase.auth();
30+
window.db = firebase.firestore();
31+
window.functions = firebase.functions();
32+
33+
// For local development, allow localhost
34+
if (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1') {
35+
if (window.auth.settings) {
36+
window.auth.settings.appVerificationDisabledForTesting = true;
37+
}
38+
}
39+
40+
window.firebaseReady = true;
41+
console.log('Firebase services ready:', { auth: !!window.auth, db: !!window.db, functions: !!window.functions });
42+
43+
return true;
44+
} else {
45+
return false;
46+
}
47+
} catch (error) {
48+
console.error('Firebase initialization error:', error);
49+
window.firebaseError = error;
50+
return false;
51+
}
52+
}
53+
54+
// Try to initialize immediately
55+
if (!initFirebaseWhenReady()) {
56+
// If not ready, retry every 100ms for up to 30 seconds
57+
let attempts = 0;
58+
const maxAttempts = 300;
59+
const retryInterval = setInterval(() => {
60+
attempts++;
61+
if (initFirebaseWhenReady() || attempts >= maxAttempts) {
62+
clearInterval(retryInterval);
63+
if (attempts >= maxAttempts) {
64+
console.error('Failed to initialize Firebase after 30 seconds');
65+
window.firebaseError = 'Timeout waiting for Firebase SDK';
66+
}
67+
}
68+
}, 100);
69+
}
70+
71+
// Also expose a manual check function
72+
window.checkFirebaseReady = function() {
73+
return window.firebaseReady;
74+
};

firebase.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"projects": {
3+
"default": "prompt-sharing-f8eeb"
4+
},
5+
"functions": [
6+
{
7+
"source": "functions",
8+
"codebase": "default",
9+
"ignore": [
10+
"node_modules",
11+
".git",
12+
"firebase-debug.log",
13+
"firebase-functions-debug.log"
14+
]
15+
}
16+
],
17+
"hosting": {
18+
"site": "prompt-sharing-f8eeb",
19+
"public": ".",
20+
"ignore": [
21+
"firebase.json",
22+
"**/.*",
23+
"**/node_modules/**",
24+
"functions/**"
25+
]
26+
}
27+
}

0 commit comments

Comments
 (0)