Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
static isAvailable() {
if (isNodeSdk()) {
return false;
} else if (BrowserPollConnection.forceAllow_) {
return true;
} else {
// NOTE: In React-Native there's normally no 'document', but if you debug a React-Native app in
// the Chrome debugger, 'document' is defined, but document.createElement is null (2015/06/08).
return (
!BrowserPollConnection.forceDisallow_ &&
typeof document !== 'undefined' &&
document.createElement != null &&
!isChromeExtensionContentScript() &&
!isWindowsStoreApp()
);
}
}
addTag(url: string, loadCB: () => void) {
if (isNodeSdk()) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(this as any).doNodeLongPoll(url, loadCB);
} else {
setTimeout(() => {
try {
// if we're already closed, don't add this poll
if (!this.sendNewPolls) {
return;
}
const newScript = this.myIFrame.doc.createElement('script');
newScript.type = 'text/javascript';
newScript.async = true;
newScript.src = url;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
newScript.onload = (newScript as any).onreadystatechange = function() {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const executeWhenDOMReady = function(fn: () => void) {
if (isNodeSdk() || document.readyState === 'complete') {
fn();
} else {
// Modeled after jQuery. Try DOMContentLoaded and onreadystatechange (which
// fire before onload), but fall back to onload.
let called = false;
const wrappedFn = function() {
if (!document.body) {
setTimeout(wrappedFn, Math.floor(10));
return;
}
if (!called) {
called = true;
fn();
}
addDisconnectPingFrame(id: string, pw: string) {
if (isNodeSdk()) {
return;
}
this.myDisconnFrame = document.createElement('iframe');
const urlParams: { [k: string]: string } = {};
urlParams[FIREBASE_LONGPOLL_DISCONN_FRAME_REQUEST_PARAM] = 't';
urlParams[FIREBASE_LONGPOLL_ID_PARAM] = id;
urlParams[FIREBASE_LONGPOLL_PW_PARAM] = pw;
this.myDisconnFrame.src = this.urlFn(urlParams);
this.myDisconnFrame.style.display = 'none';
document.body.appendChild(this.myDisconnFrame);
}
private static connectionURL_(
repoInfo: RepoInfo,
transportSessionId?: string,
lastSessionId?: string
): string {
const urlParams: { [k: string]: string } = {};
urlParams[VERSION_PARAM] = PROTOCOL_VERSION;
if (
!isNodeSdk() &&
typeof location !== 'undefined' &&
location.href &&
location.href.indexOf(FORGE_DOMAIN) !== -1
) {
urlParams[REFERER_PARAM] = FORGE_REF;
}
if (transportSessionId) {
urlParams[TRANSPORT_SESSION_PARAM] = transportSessionId;
}
if (lastSessionId) {
urlParams[LAST_SESSION_PARAM] = lastSessionId;
}
return repoInfo.connectionURL(WEBSOCKET, urlParams);
}
Reference,
Query,
Database,
DataSnapshot,
enableLogging,
INTERNAL,
ServerValue,
TEST_ACCESS
}
)
.setMultipleInstances(true)
);
instance.registerVersion(name, version, 'node');
if (isNodeSdk()) {
module.exports = Object.assign({}, namespace, { initStandalone });
}
}