@firebase/database 0.8.3-canary.fb90580e5 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +0 -16
- package/dist/index.esm.js +34 -163
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm2017.js +34 -161
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.node.cjs.js +34 -163
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/src/api/Query.d.ts +0 -2
- package/dist/src/core/AuthTokenProvider.d.ts +2 -2
- package/dist/src/core/Repo.d.ts +21 -10
- package/dist/src/core/RepoManager.d.ts +2 -8
- package/dist/src/core/util/NextPushId.d.ts +0 -2
- package/dist/src/core/util/util.d.ts +0 -8
- package/dist/src/core/view/QueryParams.d.ts +0 -6
- package/package.json +13 -16
- package/dist/exp/exp/index.d.ts +0 -29
- package/dist/exp/index.d.ts +0 -49
- package/dist/exp/index.esm.js +0 -15735
- package/dist/exp/index.esm.js.map +0 -1
- package/dist/exp/index.esm2017.js +0 -15139
- package/dist/exp/index.esm2017.js.map +0 -1
- package/dist/exp/index.node.cjs.js +0 -15746
- package/dist/exp/index.node.cjs.js.map +0 -1
- package/dist/exp/index.node.d.ts +0 -83
- package/dist/exp/src/api/DataSnapshot.d.ts +0 -99
- package/dist/exp/src/api/Database.d.ts +0 -87
- package/dist/exp/src/api/Query.d.ts +0 -193
- package/dist/exp/src/api/Reference.d.ts +0 -106
- package/dist/exp/src/api/TransactionResult.d.ts +0 -30
- package/dist/exp/src/api/internal.d.ts +0 -55
- package/dist/exp/src/api/onDisconnect.d.ts +0 -60
- package/dist/exp/src/api/test_access.d.ts +0 -42
- package/dist/exp/src/core/AuthTokenProvider.d.ts +0 -50
- package/dist/exp/src/core/CompoundWrite.d.ts +0 -77
- package/dist/exp/src/core/PersistentConnection.d.ts +0 -148
- package/dist/exp/src/core/ReadonlyRestClient.d.ts +0 -73
- package/dist/exp/src/core/Repo.d.ts +0 -121
- package/dist/exp/src/core/RepoInfo.d.ts +0 -59
- package/dist/exp/src/core/RepoManager.d.ts +0 -78
- package/dist/exp/src/core/Repo_transaction.d.ts +0 -33
- package/dist/exp/src/core/ServerActions.d.ts +0 -85
- package/dist/exp/src/core/SnapshotHolder.d.ts +0 -28
- package/dist/exp/src/core/SparseSnapshotTree.d.ts +0 -61
- package/dist/exp/src/core/SyncPoint.d.ts +0 -84
- package/dist/exp/src/core/SyncTree.d.ts +0 -236
- package/dist/exp/src/core/WriteTree.d.ts +0 -295
- package/dist/exp/src/core/operation/AckUserWrite.d.ts +0 -42
- package/dist/exp/src/core/operation/ListenComplete.d.ts +0 -32
- package/dist/exp/src/core/operation/Merge.d.ts +0 -46
- package/dist/exp/src/core/operation/Operation.d.ts +0 -78
- package/dist/exp/src/core/operation/Overwrite.d.ts +0 -35
- package/dist/exp/src/core/snap/ChildrenNode.d.ts +0 -180
- package/dist/exp/src/core/snap/IndexMap.d.ts +0 -43
- package/dist/exp/src/core/snap/LeafNode.d.ts +0 -107
- package/dist/exp/src/core/snap/Node.d.ts +0 -148
- package/dist/exp/src/core/snap/childSet.d.ts +0 -34
- package/dist/exp/src/core/snap/comparators.d.ts +0 -19
- package/dist/exp/src/core/snap/indexes/Index.d.ts +0 -69
- package/dist/exp/src/core/snap/indexes/KeyIndex.d.ts +0 -54
- package/dist/exp/src/core/snap/indexes/PathIndex.d.ts +0 -54
- package/dist/exp/src/core/snap/indexes/PriorityIndex.d.ts +0 -58
- package/dist/exp/src/core/snap/indexes/ValueIndex.d.ts +0 -56
- package/dist/exp/src/core/snap/nodeFromJSON.d.ts +0 -25
- package/dist/exp/src/core/snap/snap.d.ts +0 -29
- package/dist/exp/src/core/stats/StatsCollection.d.ts +0 -28
- package/dist/exp/src/core/stats/StatsListener.d.ts +0 -31
- package/dist/exp/src/core/stats/StatsManager.d.ts +0 -24
- package/dist/exp/src/core/stats/StatsReporter.d.ts +0 -33
- package/dist/exp/src/core/storage/DOMStorageWrapper.d.ts +0 -55
- package/dist/exp/src/core/storage/MemoryStorage.d.ts +0 -29
- package/dist/exp/src/core/storage/storage.d.ts +0 -22
- package/dist/exp/src/core/util/EventEmitter.d.ts +0 -45
- package/dist/exp/src/core/util/ImmutableTree.d.ts +0 -157
- package/dist/exp/src/core/util/NextPushId.d.ts +0 -33
- package/dist/exp/src/core/util/OnlineMonitor.d.ts +0 -40
- package/dist/exp/src/core/util/Path.d.ts +0 -132
- package/dist/exp/src/core/util/ServerValues.d.ts +0 -66
- package/dist/exp/src/core/util/SortedMap.d.ts +0 -362
- package/dist/exp/src/core/util/Tree.d.ts +0 -134
- package/dist/exp/src/core/util/VisibilityMonitor.d.ts +0 -30
- package/dist/exp/src/core/util/libs/parser.d.ts +0 -37
- package/dist/exp/src/core/util/misc.d.ts +0 -19
- package/dist/exp/src/core/util/util.d.ts +0 -232
- package/dist/exp/src/core/util/validation.d.ts +0 -108
- package/dist/exp/src/core/version.d.ts +0 -19
- package/dist/exp/src/core/view/CacheNode.d.ts +0 -59
- package/dist/exp/src/core/view/Change.d.ts +0 -74
- package/dist/exp/src/core/view/ChildChangeAccumulator.d.ts +0 -22
- package/dist/exp/src/core/view/CompleteChildSource.d.ts +0 -91
- package/dist/exp/src/core/view/Event.d.ts +0 -102
- package/dist/exp/src/core/view/EventGenerator.d.ts +0 -77
- package/dist/exp/src/core/view/EventQueue.d.ts +0 -99
- package/dist/exp/src/core/view/EventRegistration.d.ts +0 -154
- package/dist/exp/src/core/view/QueryParams.d.ts +0 -176
- package/dist/exp/src/core/view/View.d.ts +0 -97
- package/dist/exp/src/core/view/ViewCache.d.ts +0 -70
- package/dist/exp/src/core/view/ViewProcessor.d.ts +0 -166
- package/dist/exp/src/core/view/filter/IndexedFilter.d.ts +0 -54
- package/dist/exp/src/core/view/filter/LimitedFilter.d.ts +0 -94
- package/dist/exp/src/core/view/filter/NodeFilter.d.ts +0 -75
- package/dist/exp/src/core/view/filter/RangedFilter.d.ts +0 -109
- package/dist/exp/src/exp/Database.d.ts +0 -95
- package/dist/exp/src/realtime/BrowserPollConnection.d.ts +0 -208
- package/dist/exp/src/realtime/Connection.d.ts +0 -119
- package/dist/exp/src/realtime/Constants.d.ts +0 -26
- package/dist/exp/src/realtime/Transport.d.ts +0 -62
- package/dist/exp/src/realtime/TransportManager.d.ts +0 -55
- package/dist/exp/src/realtime/WebSocketConnection.d.ts +0 -133
- package/dist/exp/src/realtime/polling/PacketReceiver.d.ts +0 -41
- package/dist/exp/test/browser/crawler_support.test.d.ts +0 -17
- package/dist/exp/test/compound_write.test.d.ts +0 -17
- package/dist/exp/test/connection.test.d.ts +0 -17
- package/dist/exp/test/database.test.d.ts +0 -17
- package/dist/exp/test/datasnapshot.test.d.ts +0 -17
- package/dist/exp/test/exp/integration.test.d.ts +0 -17
- package/dist/exp/test/helpers/EventAccumulator.d.ts +0 -34
- package/dist/exp/test/helpers/events.d.ts +0 -37
- package/dist/exp/test/helpers/util.d.ts +0 -50
- package/dist/exp/test/info.test.d.ts +0 -17
- package/dist/exp/test/node.test.d.ts +0 -17
- package/dist/exp/test/order.test.d.ts +0 -17
- package/dist/exp/test/order_by.test.d.ts +0 -17
- package/dist/exp/test/path.test.d.ts +0 -17
- package/dist/exp/test/promise.test.d.ts +0 -17
- package/dist/exp/test/pushid.test.d.ts +0 -17
- package/dist/exp/test/query.test.d.ts +0 -17
- package/dist/exp/test/repoinfo.test.d.ts +0 -17
- package/dist/exp/test/servervalues.test.d.ts +0 -17
- package/dist/exp/test/sortedmap.test.d.ts +0 -17
- package/dist/exp/test/sparsesnapshottree.test.d.ts +0 -17
- package/dist/exp/test/transaction.test.d.ts +0 -17
- package/dist/src/exp/Database.d.ts +0 -95
- package/dist/test/exp/integration.test.d.ts +0 -17
- package/dist/test/pushid.test.d.ts +0 -17
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2017 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
import { Node } from '../../snap/Node';
|
|
18
|
-
import { Path } from '../../util/Path';
|
|
19
|
-
import { CompleteChildSource } from '../CompleteChildSource';
|
|
20
|
-
import { ChildChangeAccumulator } from '../ChildChangeAccumulator';
|
|
21
|
-
import { Index } from '../../snap/indexes/Index';
|
|
22
|
-
/**
|
|
23
|
-
* NodeFilter is used to update nodes and complete children of nodes while applying queries on the fly and keeping
|
|
24
|
-
* track of any child changes. This class does not track value changes as value changes depend on more
|
|
25
|
-
* than just the node itself. Different kind of queries require different kind of implementations of this interface.
|
|
26
|
-
* @interface
|
|
27
|
-
*/
|
|
28
|
-
export interface NodeFilter {
|
|
29
|
-
/**
|
|
30
|
-
* Update a single complete child in the snap. If the child equals the old child in the snap, this is a no-op.
|
|
31
|
-
* The method expects an indexed snap.
|
|
32
|
-
*
|
|
33
|
-
* @param {!Node} snap
|
|
34
|
-
* @param {string} key
|
|
35
|
-
* @param {!Node} newChild
|
|
36
|
-
* @param {!Path} affectedPath
|
|
37
|
-
* @param {!CompleteChildSource} source
|
|
38
|
-
* @param {?ChildChangeAccumulator} optChangeAccumulator
|
|
39
|
-
* @return {!Node}
|
|
40
|
-
*/
|
|
41
|
-
updateChild(snap: Node, key: string, newChild: Node, affectedPath: Path, source: CompleteChildSource, optChangeAccumulator: ChildChangeAccumulator | null): Node;
|
|
42
|
-
/**
|
|
43
|
-
* Update a node in full and output any resulting change from this complete update.
|
|
44
|
-
*
|
|
45
|
-
* @param {!Node} oldSnap
|
|
46
|
-
* @param {!Node} newSnap
|
|
47
|
-
* @param {?ChildChangeAccumulator} optChangeAccumulator
|
|
48
|
-
* @return {!Node}
|
|
49
|
-
*/
|
|
50
|
-
updateFullNode(oldSnap: Node, newSnap: Node, optChangeAccumulator: ChildChangeAccumulator | null): Node;
|
|
51
|
-
/**
|
|
52
|
-
* Update the priority of the root node
|
|
53
|
-
*
|
|
54
|
-
* @param {!Node} oldSnap
|
|
55
|
-
* @param {!Node} newPriority
|
|
56
|
-
* @return {!Node}
|
|
57
|
-
*/
|
|
58
|
-
updatePriority(oldSnap: Node, newPriority: Node): Node;
|
|
59
|
-
/**
|
|
60
|
-
* Returns true if children might be filtered due to query criteria
|
|
61
|
-
*
|
|
62
|
-
* @return {boolean}
|
|
63
|
-
*/
|
|
64
|
-
filtersNodes(): boolean;
|
|
65
|
-
/**
|
|
66
|
-
* Returns the index filter that this filter uses to get a NodeFilter that doesn't filter any children.
|
|
67
|
-
* @return {!NodeFilter}
|
|
68
|
-
*/
|
|
69
|
-
getIndexedFilter(): NodeFilter;
|
|
70
|
-
/**
|
|
71
|
-
* Returns the index that this filter uses
|
|
72
|
-
* @return {!Index}
|
|
73
|
-
*/
|
|
74
|
-
getIndex(): Index;
|
|
75
|
-
}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2017 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
import { IndexedFilter } from './IndexedFilter';
|
|
18
|
-
import { NamedNode, Node } from '../../../core/snap/Node';
|
|
19
|
-
import { NodeFilter } from './NodeFilter';
|
|
20
|
-
import { QueryParams } from '../QueryParams';
|
|
21
|
-
import { Index } from '../../snap/indexes/Index';
|
|
22
|
-
import { Path } from '../../util/Path';
|
|
23
|
-
import { CompleteChildSource } from '../CompleteChildSource';
|
|
24
|
-
import { ChildChangeAccumulator } from '../ChildChangeAccumulator';
|
|
25
|
-
/**
|
|
26
|
-
* Filters nodes by range and uses an IndexFilter to track any changes after filtering the node
|
|
27
|
-
*
|
|
28
|
-
* @constructor
|
|
29
|
-
* @implements {NodeFilter}
|
|
30
|
-
*/
|
|
31
|
-
export declare class RangedFilter implements NodeFilter {
|
|
32
|
-
/**
|
|
33
|
-
* @type {!IndexedFilter}
|
|
34
|
-
* @const
|
|
35
|
-
* @private
|
|
36
|
-
*/
|
|
37
|
-
private indexedFilter_;
|
|
38
|
-
/**
|
|
39
|
-
* @const
|
|
40
|
-
* @type {!Index}
|
|
41
|
-
* @private
|
|
42
|
-
*/
|
|
43
|
-
private index_;
|
|
44
|
-
/**
|
|
45
|
-
* @const
|
|
46
|
-
* @type {!NamedNode}
|
|
47
|
-
* @private
|
|
48
|
-
*/
|
|
49
|
-
private startPost_;
|
|
50
|
-
/**
|
|
51
|
-
* @const
|
|
52
|
-
* @type {!NamedNode}
|
|
53
|
-
* @private
|
|
54
|
-
*/
|
|
55
|
-
private endPost_;
|
|
56
|
-
/**
|
|
57
|
-
* @param {!QueryParams} params
|
|
58
|
-
*/
|
|
59
|
-
constructor(params: QueryParams);
|
|
60
|
-
/**
|
|
61
|
-
* @return {!NamedNode}
|
|
62
|
-
*/
|
|
63
|
-
getStartPost(): NamedNode;
|
|
64
|
-
/**
|
|
65
|
-
* @return {!NamedNode}
|
|
66
|
-
*/
|
|
67
|
-
getEndPost(): NamedNode;
|
|
68
|
-
/**
|
|
69
|
-
* @param {!NamedNode} node
|
|
70
|
-
* @return {boolean}
|
|
71
|
-
*/
|
|
72
|
-
matches(node: NamedNode): boolean;
|
|
73
|
-
/**
|
|
74
|
-
* @inheritDoc
|
|
75
|
-
*/
|
|
76
|
-
updateChild(snap: Node, key: string, newChild: Node, affectedPath: Path, source: CompleteChildSource, optChangeAccumulator: ChildChangeAccumulator | null): Node;
|
|
77
|
-
/**
|
|
78
|
-
* @inheritDoc
|
|
79
|
-
*/
|
|
80
|
-
updateFullNode(oldSnap: Node, newSnap: Node, optChangeAccumulator: ChildChangeAccumulator | null): Node;
|
|
81
|
-
/**
|
|
82
|
-
* @inheritDoc
|
|
83
|
-
*/
|
|
84
|
-
updatePriority(oldSnap: Node, newPriority: Node): Node;
|
|
85
|
-
/**
|
|
86
|
-
* @inheritDoc
|
|
87
|
-
*/
|
|
88
|
-
filtersNodes(): boolean;
|
|
89
|
-
/**
|
|
90
|
-
* @inheritDoc
|
|
91
|
-
*/
|
|
92
|
-
getIndexedFilter(): IndexedFilter;
|
|
93
|
-
/**
|
|
94
|
-
* @inheritDoc
|
|
95
|
-
*/
|
|
96
|
-
getIndex(): Index;
|
|
97
|
-
/**
|
|
98
|
-
* @param {!QueryParams} params
|
|
99
|
-
* @return {!NamedNode}
|
|
100
|
-
* @private
|
|
101
|
-
*/
|
|
102
|
-
private static getStartPost_;
|
|
103
|
-
/**
|
|
104
|
-
* @param {!QueryParams} params
|
|
105
|
-
* @return {!NamedNode}
|
|
106
|
-
* @private
|
|
107
|
-
*/
|
|
108
|
-
private static getEndPost_;
|
|
109
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2020 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
import { FirebaseApp, _FirebaseService } from "@firebase/app-types";
|
|
18
|
-
import { Reference } from '../api/Reference';
|
|
19
|
-
import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
|
|
20
|
-
import { Provider } from '@firebase/component';
|
|
21
|
-
/**
|
|
22
|
-
* Class representing a Firebase Realtime Database.
|
|
23
|
-
*/
|
|
24
|
-
export declare class FirebaseDatabase implements _FirebaseService {
|
|
25
|
-
readonly app: FirebaseApp;
|
|
26
|
-
static readonly ServerValue: {
|
|
27
|
-
TIMESTAMP: {
|
|
28
|
-
'.sv': string;
|
|
29
|
-
};
|
|
30
|
-
increment: (delta: number) => {
|
|
31
|
-
'.sv': {
|
|
32
|
-
increment: number;
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
private _delegate;
|
|
37
|
-
constructor(app: FirebaseApp, authProvider: Provider<FirebaseAuthInternalName>, databaseUrl?: string);
|
|
38
|
-
/**
|
|
39
|
-
* Modify this instance to communicate with the Realtime Database emulator.
|
|
40
|
-
*
|
|
41
|
-
* <p>Note: This method must be called before performing any other operation.
|
|
42
|
-
*
|
|
43
|
-
* @param host - the emulator host (ex: localhost)
|
|
44
|
-
* @param port - the emulator port (ex: 8080)
|
|
45
|
-
*/
|
|
46
|
-
useEmulator(host: string, port: number): void;
|
|
47
|
-
/**
|
|
48
|
-
* Returns a reference to the root or to the path specified in the provided
|
|
49
|
-
* argument.
|
|
50
|
-
*
|
|
51
|
-
* @param path - The relative string path or an existing Reference to a
|
|
52
|
-
* database location.
|
|
53
|
-
* @throws If a Reference is provided, throws if it does not belong to the
|
|
54
|
-
* same project.
|
|
55
|
-
* @returns Firebase reference.
|
|
56
|
-
*/
|
|
57
|
-
ref(path?: string): Reference;
|
|
58
|
-
ref(path?: Reference): Reference;
|
|
59
|
-
/**
|
|
60
|
-
* Returns a reference to the root or the path specified in url.
|
|
61
|
-
* We throw a exception if the url is not in the same domain as the
|
|
62
|
-
* current repo.
|
|
63
|
-
* @param url - A URL that refers to a database location.
|
|
64
|
-
* @returns A Firebase reference.
|
|
65
|
-
*/
|
|
66
|
-
refFromURL(url: string): Reference;
|
|
67
|
-
goOffline(): void;
|
|
68
|
-
goOnline(): void;
|
|
69
|
-
_delete(): Promise<void>;
|
|
70
|
-
_setDatabaseUrl(url: string): void;
|
|
71
|
-
}
|
|
72
|
-
declare const ServerValue: {
|
|
73
|
-
TIMESTAMP: {
|
|
74
|
-
'.sv': string;
|
|
75
|
-
};
|
|
76
|
-
increment: (delta: number) => {
|
|
77
|
-
'.sv': {
|
|
78
|
-
increment: number;
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
export { ServerValue };
|
|
83
|
-
/**
|
|
84
|
-
* Returns the instance of the Realtime Database SDK that is associated
|
|
85
|
-
* with the provided {@link FirebaseApp}. Initializes a new instance with
|
|
86
|
-
* with default settings if no instance exists or if the existing instance uses
|
|
87
|
-
* a custom database URL.
|
|
88
|
-
*
|
|
89
|
-
* @param app - The {@link FirebaseApp} instance that the returned Realtime
|
|
90
|
-
* Database instance is associated with.
|
|
91
|
-
* @param url - The URL of the Realtime Database instance to connect to. If not
|
|
92
|
-
* provided, the SDK connects to the default instance of the Firebase App.
|
|
93
|
-
* @returns The `FirebaseDatabase` instance of the provided app.
|
|
94
|
-
*/
|
|
95
|
-
export declare function getDatabase(app: FirebaseApp, url?: string): FirebaseDatabase;
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2017 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
import { PacketReceiver } from './polling/PacketReceiver';
|
|
18
|
-
import { Transport } from './Transport';
|
|
19
|
-
import { RepoInfo } from '../core/RepoInfo';
|
|
20
|
-
export declare const FIREBASE_LONGPOLL_START_PARAM = "start";
|
|
21
|
-
export declare const FIREBASE_LONGPOLL_CLOSE_COMMAND = "close";
|
|
22
|
-
export declare const FIREBASE_LONGPOLL_COMMAND_CB_NAME = "pLPCommand";
|
|
23
|
-
export declare const FIREBASE_LONGPOLL_DATA_CB_NAME = "pRTLPCB";
|
|
24
|
-
export declare const FIREBASE_LONGPOLL_ID_PARAM = "id";
|
|
25
|
-
export declare const FIREBASE_LONGPOLL_PW_PARAM = "pw";
|
|
26
|
-
export declare const FIREBASE_LONGPOLL_SERIAL_PARAM = "ser";
|
|
27
|
-
export declare const FIREBASE_LONGPOLL_CALLBACK_ID_PARAM = "cb";
|
|
28
|
-
export declare const FIREBASE_LONGPOLL_SEGMENT_NUM_PARAM = "seg";
|
|
29
|
-
export declare const FIREBASE_LONGPOLL_SEGMENTS_IN_PACKET = "ts";
|
|
30
|
-
export declare const FIREBASE_LONGPOLL_DATA_PARAM = "d";
|
|
31
|
-
export declare const FIREBASE_LONGPOLL_DISCONN_FRAME_PARAM = "disconn";
|
|
32
|
-
export declare const FIREBASE_LONGPOLL_DISCONN_FRAME_REQUEST_PARAM = "dframe";
|
|
33
|
-
/**
|
|
34
|
-
* This class manages a single long-polling connection.
|
|
35
|
-
*
|
|
36
|
-
* @constructor
|
|
37
|
-
* @implements {Transport}
|
|
38
|
-
*/
|
|
39
|
-
export declare class BrowserPollConnection implements Transport {
|
|
40
|
-
connId: string;
|
|
41
|
-
repoInfo: RepoInfo;
|
|
42
|
-
private applicationId?;
|
|
43
|
-
transportSessionId?: string;
|
|
44
|
-
lastSessionId?: string;
|
|
45
|
-
bytesSent: number;
|
|
46
|
-
bytesReceived: number;
|
|
47
|
-
urlFn: (params: object) => string;
|
|
48
|
-
scriptTagHolder: FirebaseIFrameScriptHolder;
|
|
49
|
-
myDisconnFrame: HTMLIFrameElement;
|
|
50
|
-
curSegmentNum: number;
|
|
51
|
-
myPacketOrderer: PacketReceiver;
|
|
52
|
-
id: string;
|
|
53
|
-
password: string;
|
|
54
|
-
private log_;
|
|
55
|
-
private stats_;
|
|
56
|
-
private everConnected_;
|
|
57
|
-
private isClosed_;
|
|
58
|
-
private connectTimeoutTimer_;
|
|
59
|
-
private onDisconnect_;
|
|
60
|
-
/**
|
|
61
|
-
* @param connId An identifier for this connection, used for logging
|
|
62
|
-
* @param repoInfo The info for the endpoint to send data to.
|
|
63
|
-
* @param applicationId The Firebase App ID for this project.
|
|
64
|
-
* @param transportSessionId Optional transportSessionid if we are reconnecting for an existing
|
|
65
|
-
* transport session
|
|
66
|
-
* @param lastSessionId Optional lastSessionId if the PersistentConnection has already created a
|
|
67
|
-
* connection previously
|
|
68
|
-
*/
|
|
69
|
-
constructor(connId: string, repoInfo: RepoInfo, applicationId?: string, transportSessionId?: string, lastSessionId?: string);
|
|
70
|
-
/**
|
|
71
|
-
*
|
|
72
|
-
* @param {function(Object)} onMessage Callback when messages arrive
|
|
73
|
-
* @param {function()} onDisconnect Callback with connection lost.
|
|
74
|
-
*/
|
|
75
|
-
open(onMessage: (msg: {}) => void, onDisconnect: (a?: boolean) => void): void;
|
|
76
|
-
/**
|
|
77
|
-
* Call this when a handshake has completed successfully and we want to consider the connection established
|
|
78
|
-
*/
|
|
79
|
-
start(): void;
|
|
80
|
-
private static forceAllow_;
|
|
81
|
-
/**
|
|
82
|
-
* Forces long polling to be considered as a potential transport
|
|
83
|
-
*/
|
|
84
|
-
static forceAllow(): void;
|
|
85
|
-
private static forceDisallow_;
|
|
86
|
-
/**
|
|
87
|
-
* Forces longpolling to not be considered as a potential transport
|
|
88
|
-
*/
|
|
89
|
-
static forceDisallow(): void;
|
|
90
|
-
static isAvailable(): boolean;
|
|
91
|
-
/**
|
|
92
|
-
* No-op for polling
|
|
93
|
-
*/
|
|
94
|
-
markConnectionHealthy(): void;
|
|
95
|
-
/**
|
|
96
|
-
* Stops polling and cleans up the iframe
|
|
97
|
-
* @private
|
|
98
|
-
*/
|
|
99
|
-
private shutdown_;
|
|
100
|
-
/**
|
|
101
|
-
* Triggered when this transport is closed
|
|
102
|
-
* @private
|
|
103
|
-
*/
|
|
104
|
-
private onClosed_;
|
|
105
|
-
/**
|
|
106
|
-
* External-facing close handler. RealTime has requested we shut down. Kill our connection and tell the server
|
|
107
|
-
* that we've left.
|
|
108
|
-
*/
|
|
109
|
-
close(): void;
|
|
110
|
-
/**
|
|
111
|
-
* Send the JSON object down to the server. It will need to be stringified, base64 encoded, and then
|
|
112
|
-
* broken into chunks (since URLs have a small maximum length).
|
|
113
|
-
* @param {!Object} data The JSON data to transmit.
|
|
114
|
-
*/
|
|
115
|
-
send(data: {}): void;
|
|
116
|
-
/**
|
|
117
|
-
* This is how we notify the server that we're leaving.
|
|
118
|
-
* We aren't able to send requests with DHTML on a window close event, but we can
|
|
119
|
-
* trigger XHR requests in some browsers (everything but Opera basically).
|
|
120
|
-
* @param {!string} id
|
|
121
|
-
* @param {!string} pw
|
|
122
|
-
*/
|
|
123
|
-
addDisconnectPingFrame(id: string, pw: string): void;
|
|
124
|
-
/**
|
|
125
|
-
* Used to track the bytes received by this client
|
|
126
|
-
* @param {*} args
|
|
127
|
-
* @private
|
|
128
|
-
*/
|
|
129
|
-
private incrementIncomingBytes_;
|
|
130
|
-
}
|
|
131
|
-
export interface IFrameElement extends HTMLIFrameElement {
|
|
132
|
-
doc: Document;
|
|
133
|
-
}
|
|
134
|
-
/*********************************************************************************************
|
|
135
|
-
* A wrapper around an iframe that is used as a long-polling script holder.
|
|
136
|
-
* @constructor
|
|
137
|
-
*********************************************************************************************/
|
|
138
|
-
export declare class FirebaseIFrameScriptHolder {
|
|
139
|
-
onDisconnect: () => void;
|
|
140
|
-
urlFn: (a: object) => string;
|
|
141
|
-
outstandingRequests: Set<number>;
|
|
142
|
-
pendingSegs: Array<{
|
|
143
|
-
seg: number;
|
|
144
|
-
ts: number;
|
|
145
|
-
d: unknown;
|
|
146
|
-
}>;
|
|
147
|
-
currentSerial: number;
|
|
148
|
-
sendNewPolls: boolean;
|
|
149
|
-
uniqueCallbackIdentifier: number;
|
|
150
|
-
myIFrame: IFrameElement;
|
|
151
|
-
alive: boolean;
|
|
152
|
-
myID: string;
|
|
153
|
-
myPW: string;
|
|
154
|
-
commandCB: (command: string, ...args: unknown[]) => void;
|
|
155
|
-
onMessageCB: (...args: unknown[]) => void;
|
|
156
|
-
/**
|
|
157
|
-
* @param commandCB - The callback to be called when control commands are recevied from the server.
|
|
158
|
-
* @param onMessageCB - The callback to be triggered when responses arrive from the server.
|
|
159
|
-
* @param onDisconnect - The callback to be triggered when this tag holder is closed
|
|
160
|
-
* @param urlFn - A function that provides the URL of the endpoint to send data to.
|
|
161
|
-
*/
|
|
162
|
-
constructor(commandCB: (command: string, ...args: unknown[]) => void, onMessageCB: (...args: unknown[]) => void, onDisconnect: () => void, urlFn: (a: object) => string);
|
|
163
|
-
/**
|
|
164
|
-
* Each browser has its own funny way to handle iframes. Here we mush them all together into one object that I can
|
|
165
|
-
* actually use.
|
|
166
|
-
* @private
|
|
167
|
-
* @return {Element}
|
|
168
|
-
*/
|
|
169
|
-
private static createIFrame_;
|
|
170
|
-
/**
|
|
171
|
-
* Cancel all outstanding queries and remove the frame.
|
|
172
|
-
*/
|
|
173
|
-
close(): void;
|
|
174
|
-
/**
|
|
175
|
-
* Actually start the long-polling session by adding the first script tag(s) to the iframe.
|
|
176
|
-
* @param {!string} id - The ID of this connection
|
|
177
|
-
* @param {!string} pw - The password for this connection
|
|
178
|
-
*/
|
|
179
|
-
startLongPoll(id: string, pw: string): void;
|
|
180
|
-
/**
|
|
181
|
-
* This is called any time someone might want a script tag to be added. It adds a script tag when there aren't
|
|
182
|
-
* too many outstanding requests and we are still alive.
|
|
183
|
-
*
|
|
184
|
-
* If there are outstanding packet segments to send, it sends one. If there aren't, it sends a long-poll anyways if
|
|
185
|
-
* needed.
|
|
186
|
-
*/
|
|
187
|
-
private newRequest_;
|
|
188
|
-
/**
|
|
189
|
-
* Queue a packet for transmission to the server.
|
|
190
|
-
* @param segnum - A sequential id for this packet segment used for reassembly
|
|
191
|
-
* @param totalsegs - The total number of segments in this packet
|
|
192
|
-
* @param data - The data for this segment.
|
|
193
|
-
*/
|
|
194
|
-
enqueueSegment(segnum: number, totalsegs: number, data: unknown): void;
|
|
195
|
-
/**
|
|
196
|
-
* Add a script tag for a regular long-poll request.
|
|
197
|
-
* @param {!string} url - The URL of the script tag.
|
|
198
|
-
* @param {!number} serial - The serial number of the request.
|
|
199
|
-
* @private
|
|
200
|
-
*/
|
|
201
|
-
private addLongPollTag_;
|
|
202
|
-
/**
|
|
203
|
-
* Add an arbitrary script tag to the iframe.
|
|
204
|
-
* @param {!string} url - The URL for the script tag source.
|
|
205
|
-
* @param {!function()} loadCB - A callback to be triggered once the script has loaded.
|
|
206
|
-
*/
|
|
207
|
-
addTag(url: string, loadCB: () => void): void;
|
|
208
|
-
}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2017 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
import { RepoInfo } from '../core/RepoInfo';
|
|
18
|
-
/**
|
|
19
|
-
* Creates a new real-time connection to the server using whichever method works
|
|
20
|
-
* best in the current browser.
|
|
21
|
-
*
|
|
22
|
-
* @constructor
|
|
23
|
-
*/
|
|
24
|
-
export declare class Connection {
|
|
25
|
-
id: string;
|
|
26
|
-
private repoInfo_;
|
|
27
|
-
private applicationId_;
|
|
28
|
-
private onMessage_;
|
|
29
|
-
private onReady_;
|
|
30
|
-
private onDisconnect_;
|
|
31
|
-
private onKill_;
|
|
32
|
-
lastSessionId?: string;
|
|
33
|
-
connectionCount: number;
|
|
34
|
-
pendingDataMessages: unknown[];
|
|
35
|
-
sessionId: string;
|
|
36
|
-
private conn_;
|
|
37
|
-
private healthyTimeout_;
|
|
38
|
-
private isHealthy_;
|
|
39
|
-
private log_;
|
|
40
|
-
private primaryResponsesRequired_;
|
|
41
|
-
private rx_;
|
|
42
|
-
private secondaryConn_;
|
|
43
|
-
private secondaryResponsesRequired_;
|
|
44
|
-
private state_;
|
|
45
|
-
private transportManager_;
|
|
46
|
-
private tx_;
|
|
47
|
-
/**
|
|
48
|
-
* @param id - an id for this connection
|
|
49
|
-
* @param repoInfo_ - the info for the endpoint to connect to
|
|
50
|
-
* @param applicationId_ - the Firebase App ID for this project
|
|
51
|
-
* @param onMessage_ - the callback to be triggered when a server-push message arrives
|
|
52
|
-
* @param onReady_ - the callback to be triggered when this connection is ready to send messages.
|
|
53
|
-
* @param onDisconnect_ - the callback to be triggered when a connection was lost
|
|
54
|
-
* @param onKill_ - the callback to be triggered when this connection has permanently shut down.
|
|
55
|
-
* @param lastSessionId - last session id in persistent connection. is used to clean up old session in real-time server
|
|
56
|
-
*/
|
|
57
|
-
constructor(id: string, repoInfo_: RepoInfo, applicationId_: string | undefined, onMessage_: (a: {}) => void, onReady_: (a: number, b: string) => void, onDisconnect_: () => void, onKill_: (a: string) => void, lastSessionId?: string);
|
|
58
|
-
/**
|
|
59
|
-
* Starts a connection attempt
|
|
60
|
-
* @private
|
|
61
|
-
*/
|
|
62
|
-
private start_;
|
|
63
|
-
/**
|
|
64
|
-
* @return {!string}
|
|
65
|
-
* @private
|
|
66
|
-
*/
|
|
67
|
-
private nextTransportId_;
|
|
68
|
-
private disconnReceiver_;
|
|
69
|
-
private connReceiver_;
|
|
70
|
-
/**
|
|
71
|
-
*
|
|
72
|
-
* @param {Object} dataMsg An arbitrary data message to be sent to the server
|
|
73
|
-
*/
|
|
74
|
-
sendRequest(dataMsg: object): void;
|
|
75
|
-
tryCleanupConnection(): void;
|
|
76
|
-
private onSecondaryControl_;
|
|
77
|
-
private onSecondaryMessageReceived_;
|
|
78
|
-
private upgradeIfSecondaryHealthy_;
|
|
79
|
-
private proceedWithUpgrade_;
|
|
80
|
-
private onPrimaryMessageReceived_;
|
|
81
|
-
private onDataMessage_;
|
|
82
|
-
private onPrimaryResponse_;
|
|
83
|
-
private onControl_;
|
|
84
|
-
/**
|
|
85
|
-
*
|
|
86
|
-
* @param {Object} handshake The handshake data returned from the server
|
|
87
|
-
* @private
|
|
88
|
-
*/
|
|
89
|
-
private onHandshake_;
|
|
90
|
-
private tryStartUpgrade_;
|
|
91
|
-
private startUpgrade_;
|
|
92
|
-
private onReset_;
|
|
93
|
-
private onConnectionEstablished_;
|
|
94
|
-
private sendPingOnPrimaryIfNecessary_;
|
|
95
|
-
private onSecondaryConnectionLost_;
|
|
96
|
-
/**
|
|
97
|
-
*
|
|
98
|
-
* @param {boolean} everConnected Whether or not the connection ever reached a server. Used to determine if
|
|
99
|
-
* we should flush the host cache
|
|
100
|
-
* @private
|
|
101
|
-
*/
|
|
102
|
-
private onConnectionLost_;
|
|
103
|
-
/**
|
|
104
|
-
*
|
|
105
|
-
* @param {string} reason
|
|
106
|
-
* @private
|
|
107
|
-
*/
|
|
108
|
-
private onConnectionShutdown_;
|
|
109
|
-
private sendData_;
|
|
110
|
-
/**
|
|
111
|
-
* Cleans up this connection, calling the appropriate callbacks
|
|
112
|
-
*/
|
|
113
|
-
close(): void;
|
|
114
|
-
/**
|
|
115
|
-
*
|
|
116
|
-
* @private
|
|
117
|
-
*/
|
|
118
|
-
private closeConnections_;
|
|
119
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2017 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
export declare const PROTOCOL_VERSION = "5";
|
|
18
|
-
export declare const VERSION_PARAM = "v";
|
|
19
|
-
export declare const TRANSPORT_SESSION_PARAM = "s";
|
|
20
|
-
export declare const REFERER_PARAM = "r";
|
|
21
|
-
export declare const FORGE_REF = "f";
|
|
22
|
-
export declare const FORGE_DOMAIN_RE: RegExp;
|
|
23
|
-
export declare const LAST_SESSION_PARAM = "ls";
|
|
24
|
-
export declare const APPLICATION_ID_PARAM = "p";
|
|
25
|
-
export declare const WEBSOCKET = "websocket";
|
|
26
|
-
export declare const LONG_POLLING = "long_polling";
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2017 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
import { RepoInfo } from '../core/RepoInfo';
|
|
18
|
-
export interface TransportConstructor {
|
|
19
|
-
new (connId: string, repoInfo: RepoInfo, applicationId?: string, transportSessionId?: string, lastSessionId?: string): Transport;
|
|
20
|
-
isAvailable: () => boolean;
|
|
21
|
-
responsesRequiredToBeHealthy?: number;
|
|
22
|
-
healthyTimeout?: number;
|
|
23
|
-
}
|
|
24
|
-
export declare abstract class Transport {
|
|
25
|
-
/**
|
|
26
|
-
* Bytes received since connection started.
|
|
27
|
-
* @type {number}
|
|
28
|
-
*/
|
|
29
|
-
abstract bytesReceived: number;
|
|
30
|
-
/**
|
|
31
|
-
* Bytes sent since connection started.
|
|
32
|
-
* @type {number}
|
|
33
|
-
*/
|
|
34
|
-
abstract bytesSent: number;
|
|
35
|
-
/**
|
|
36
|
-
* An identifier for this connection, used for logging
|
|
37
|
-
* @type {string}
|
|
38
|
-
*/
|
|
39
|
-
abstract connId: string;
|
|
40
|
-
/**
|
|
41
|
-
*
|
|
42
|
-
* @param {string} connId An identifier for this connection, used for logging
|
|
43
|
-
* @param {RepoInfo} repoInfo The info for the endpoint to send data to.
|
|
44
|
-
* @param {string=} transportSessionId Optional transportSessionId if this is connecting to an existing transport session
|
|
45
|
-
* @param {string=} lastSessionId Optional lastSessionId if there was a previous connection
|
|
46
|
-
* @interface
|
|
47
|
-
*/
|
|
48
|
-
constructor(connId: string, repoInfo: RepoInfo, transportSessionId?: string, lastSessionId?: string);
|
|
49
|
-
/**
|
|
50
|
-
* @param {function(Object)} onMessage Callback when messages arrive
|
|
51
|
-
* @param {function()} onDisconnect Callback with connection lost.
|
|
52
|
-
*/
|
|
53
|
-
abstract open(onMessage: (a: {}) => void, onDisconnect: (a?: boolean) => void): void;
|
|
54
|
-
abstract start(): void;
|
|
55
|
-
abstract close(): void;
|
|
56
|
-
/**
|
|
57
|
-
* @param {!Object} data The JSON data to transmit
|
|
58
|
-
*/
|
|
59
|
-
abstract send(data: {}): void;
|
|
60
|
-
abstract markConnectionHealthy(): void;
|
|
61
|
-
abstract markConnectionHealthy(): void;
|
|
62
|
-
}
|