Skip to content

Remove nodePatches.ts hackery. #2144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/database/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Unreleased
- [changed] Internal cleanup to Node.JS support.

# 6.4.0
- [fixed] Fixed an issue that caused `.info/serverTimeOffset` events not to fire (#2043).
- [changed] Treat `ns` url query parameter as the default Realtime Database
namespace name.
Expand Down
5 changes: 4 additions & 1 deletion packages/database/index.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ import { enableLogging } from './src/core/util/util';
import { RepoManager } from './src/core/RepoManager';
import * as INTERNAL from './src/api/internal';
import * as TEST_ACCESS from './src/api/test_access';
import './src/nodePatches';
import * as types from '@firebase/database-types';
import { setSDKVersion } from './src/core/version';
import { CONSTANTS, isNodeSdk } from '@firebase/util';
import { setWebSocketImpl } from './src/realtime/WebSocketConnection';
import { Client } from 'faye-websocket';

setWebSocketImpl(Client);

const ServerValue = Database.ServerValue;

Expand Down
2 changes: 1 addition & 1 deletion packages/database/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"test": "yarn test:emulator",
"test:all": "run-p test:browser test:node",
"test:browser": "karma start --single-run",
"test:node": "TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --file src/nodePatches.ts --opts ../../config/mocha.node.opts",
"test:node": "TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --file index.node.ts --opts ../../config/mocha.node.opts",
"test:emulator": "ts-node --compiler-options='{\"module\":\"commonjs\"}' ../../scripts/emulator-testing/database-test-runner.ts",
"prepare": "yarn build"
},
Expand Down
210 changes: 0 additions & 210 deletions packages/database/src/nodePatches.ts

This file was deleted.

30 changes: 12 additions & 18 deletions packages/database/src/realtime/BrowserPollConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ export class BrowserPollConnection implements Transport {
urlParams[LAST_SESSION_PARAM] = this.lastSessionId;
}
if (
!isNodeSdk() &&
typeof location !== 'undefined' &&
location.href &&
location.href.indexOf(FORGE_DOMAIN) !== -1
Expand Down Expand Up @@ -252,17 +251,21 @@ export class BrowserPollConnection implements Transport {

// Static method, use string literal so it can be accessed in a generic way
static isAvailable() {
// 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.forceAllow_ ||
(!BrowserPollConnection.forceDisallow_ &&
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() &&
!isNodeSdk())
);
!isWindowsStoreApp()
);
}
}

/**
Expand Down Expand Up @@ -542,15 +545,6 @@ export class FirebaseIFrameScriptHolder {
}, Math.floor(0));
}

if (isNodeSdk() && this.myID) {
const urlParams: { [k: string]: string } = {};
urlParams[FIREBASE_LONGPOLL_DISCONN_FRAME_PARAM] = 't';
urlParams[FIREBASE_LONGPOLL_ID_PARAM] = this.myID;
urlParams[FIREBASE_LONGPOLL_PW_PARAM] = this.myPW;
const theURL = this.urlFn(urlParams);
(FirebaseIFrameScriptHolder as any).nodeRestRequest(theURL);
}

// Protect from being called recursively.
const onDisconnect = this.onDisconnect;
if (onDisconnect) {
Expand Down