@firebase/database 1.0.9 → 1.0.10
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.cjs.js +13834 -13834
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm2017.js +13834 -13834
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.node.cjs.js +13849 -13849
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.standalone.js +13797 -13797
- package/dist/index.standalone.js.map +1 -1
- package/dist/node-esm/index.node.esm.js +13849 -13849
- package/dist/node-esm/index.node.esm.js.map +1 -1
- package/dist/node-esm/src/api/Database.d.ts +137 -137
- package/dist/node-esm/src/api/OnDisconnect.d.ts +110 -110
- package/dist/node-esm/src/api/Reference.d.ts +122 -122
- package/dist/node-esm/src/api/Reference_impl.d.ts +1098 -1098
- package/dist/node-esm/src/api/ServerValue.d.ts +30 -30
- package/dist/node-esm/src/api/Transaction.d.ts +83 -83
- package/dist/node-esm/src/api/test_access.d.ts +31 -31
- package/dist/node-esm/src/api.d.ts +18 -18
- package/dist/node-esm/src/api.standalone.d.ts +30 -30
- package/dist/node-esm/src/core/AppCheckTokenProvider.d.ts +30 -30
- package/dist/node-esm/src/core/AuthTokenProvider.d.ts +49 -49
- package/dist/node-esm/src/core/CompoundWrite.d.ts +81 -81
- package/dist/node-esm/src/core/PersistentConnection.d.ts +135 -135
- package/dist/node-esm/src/core/ReadonlyRestClient.d.ts +60 -60
- package/dist/node-esm/src/core/Repo.d.ts +144 -144
- package/dist/node-esm/src/core/RepoInfo.d.ts +56 -56
- package/dist/node-esm/src/core/ServerActions.d.ts +52 -52
- package/dist/node-esm/src/core/SnapshotHolder.d.ts +26 -26
- package/dist/node-esm/src/core/SparseSnapshotTree.d.ts +64 -64
- package/dist/node-esm/src/core/SyncPoint.d.ts +91 -91
- package/dist/node-esm/src/core/SyncTree.d.ts +166 -166
- package/dist/node-esm/src/core/WriteTree.d.ts +205 -205
- package/dist/node-esm/src/core/operation/AckUserWrite.d.ts +36 -36
- package/dist/node-esm/src/core/operation/ListenComplete.d.ts +26 -26
- package/dist/node-esm/src/core/operation/Merge.d.ts +33 -33
- package/dist/node-esm/src/core/operation/Operation.d.ts +45 -45
- package/dist/node-esm/src/core/operation/Overwrite.d.ts +28 -28
- package/dist/node-esm/src/core/snap/ChildrenNode.d.ts +112 -112
- package/dist/node-esm/src/core/snap/IndexMap.d.ts +43 -43
- package/dist/node-esm/src/core/snap/LeafNode.d.ts +83 -83
- package/dist/node-esm/src/core/snap/Node.d.ts +126 -126
- package/dist/node-esm/src/core/snap/childSet.d.ts +32 -32
- package/dist/node-esm/src/core/snap/comparators.d.ts +19 -19
- package/dist/node-esm/src/core/snap/indexes/Index.d.ts +50 -50
- package/dist/node-esm/src/core/snap/indexes/KeyIndex.d.ts +34 -34
- package/dist/node-esm/src/core/snap/indexes/PathIndex.d.ts +29 -29
- package/dist/node-esm/src/core/snap/indexes/PriorityIndex.d.ts +33 -33
- package/dist/node-esm/src/core/snap/indexes/ValueIndex.d.ts +31 -31
- package/dist/node-esm/src/core/snap/nodeFromJSON.d.ts +24 -24
- package/dist/node-esm/src/core/snap/snap.d.ts +23 -23
- package/dist/node-esm/src/core/stats/StatsCollection.d.ts +26 -26
- package/dist/node-esm/src/core/stats/StatsListener.d.ts +30 -30
- package/dist/node-esm/src/core/stats/StatsManager.d.ts +20 -20
- package/dist/node-esm/src/core/stats/StatsReporter.d.ts +28 -28
- package/dist/node-esm/src/core/storage/DOMStorageWrapper.d.ts +46 -46
- package/dist/node-esm/src/core/storage/MemoryStorage.d.ts +27 -27
- package/dist/node-esm/src/core/storage/storage.d.ts +22 -22
- package/dist/node-esm/src/core/util/EventEmitter.d.ts +39 -39
- package/dist/node-esm/src/core/util/ImmutableTree.d.ts +117 -117
- package/dist/node-esm/src/core/util/NextPushId.d.ts +33 -33
- package/dist/node-esm/src/core/util/OnlineMonitor.d.ts +31 -31
- package/dist/node-esm/src/core/util/Path.d.ts +94 -94
- package/dist/node-esm/src/core/util/ServerValues.d.ts +56 -56
- package/dist/node-esm/src/core/util/SortedMap.d.ts +324 -324
- package/dist/node-esm/src/core/util/Tree.d.ts +105 -105
- package/dist/node-esm/src/core/util/VisibilityMonitor.d.ts +23 -23
- package/dist/node-esm/src/core/util/libs/parser.d.ts +32 -32
- package/dist/node-esm/src/core/util/misc.d.ts +19 -19
- package/dist/node-esm/src/core/util/util.d.ts +176 -176
- package/dist/node-esm/src/core/util/validation.d.ts +70 -70
- package/dist/node-esm/src/core/version.d.ts +23 -23
- package/dist/node-esm/src/core/view/CacheNode.d.ts +41 -41
- package/dist/node-esm/src/core/view/Change.d.ts +46 -46
- package/dist/node-esm/src/core/view/ChildChangeAccumulator.d.ts +22 -22
- package/dist/node-esm/src/core/view/CompleteChildSource.d.ts +55 -55
- package/dist/node-esm/src/core/view/Event.d.ts +64 -64
- package/dist/node-esm/src/core/view/EventGenerator.d.ts +42 -42
- package/dist/node-esm/src/core/view/EventQueue.d.ts +67 -67
- package/dist/node-esm/src/core/view/EventRegistration.d.ts +87 -87
- package/dist/node-esm/src/core/view/QueryParams.d.ts +95 -95
- package/dist/node-esm/src/core/view/View.d.ts +59 -59
- package/dist/node-esm/src/core/view/ViewCache.d.ts +32 -32
- package/dist/node-esm/src/core/view/ViewProcessor.d.ts +32 -32
- package/dist/node-esm/src/core/view/filter/IndexedFilter.d.ts +35 -35
- package/dist/node-esm/src/core/view/filter/LimitedFilter.d.ts +47 -47
- package/dist/node-esm/src/core/view/filter/NodeFilter.d.ts +54 -54
- package/dist/node-esm/src/core/view/filter/RangedFilter.d.ts +47 -47
- package/dist/node-esm/src/index.d.ts +28 -28
- package/dist/node-esm/src/index.node.d.ts +17 -17
- package/dist/node-esm/src/index.standalone.d.ts +17 -17
- package/dist/node-esm/src/internal/index.d.ts +38 -38
- package/dist/node-esm/src/realtime/BrowserPollConnection.d.ts +198 -198
- package/dist/node-esm/src/realtime/Connection.d.ts +102 -102
- package/dist/node-esm/src/realtime/Constants.d.ts +27 -27
- package/dist/node-esm/src/realtime/Transport.d.ts +58 -58
- package/dist/node-esm/src/realtime/TransportManager.d.ts +50 -50
- package/dist/node-esm/src/realtime/WebSocketConnection.d.ts +127 -127
- package/dist/node-esm/src/realtime/polling/PacketReceiver.d.ts +38 -38
- package/dist/node-esm/src/register.d.ts +1 -1
- package/dist/node-esm/test/compound_write.test.d.ts +17 -17
- package/dist/node-esm/test/connection.test.d.ts +17 -17
- package/dist/node-esm/test/deno.test.d.ts +17 -17
- package/dist/node-esm/test/exp/integration.test.d.ts +17 -17
- package/dist/node-esm/test/helpers/EventAccumulator.d.ts +35 -35
- package/dist/node-esm/test/helpers/syncpoint-util.d.ts +29 -29
- package/dist/node-esm/test/helpers/util.d.ts +34 -34
- package/dist/node-esm/test/node.test.d.ts +17 -17
- package/dist/node-esm/test/parser.test.d.ts +17 -17
- package/dist/node-esm/test/path.test.d.ts +17 -17
- package/dist/node-esm/test/pushid.test.d.ts +17 -17
- package/dist/node-esm/test/queryconstraint.test.d.ts +17 -17
- package/dist/node-esm/test/repoinfo.test.d.ts +17 -17
- package/dist/node-esm/test/sortedmap.test.d.ts +17 -17
- package/dist/node-esm/test/sparsesnapshottree.test.d.ts +17 -17
- package/dist/node-esm/test/syncpoint.test.d.ts +17 -17
- package/dist/node-esm/test/transport.test.d.ts +17 -17
- package/dist/node-esm/test/websocketconnection.test.d.ts +17 -17
- package/dist/src/api/Database.d.ts +137 -137
- package/dist/src/api/OnDisconnect.d.ts +110 -110
- package/dist/src/api/Reference.d.ts +122 -122
- package/dist/src/api/Reference_impl.d.ts +1098 -1098
- package/dist/src/api/ServerValue.d.ts +30 -30
- package/dist/src/api/Transaction.d.ts +83 -83
- package/dist/src/api/test_access.d.ts +31 -31
- package/dist/src/api.d.ts +18 -18
- package/dist/src/api.standalone.d.ts +30 -30
- package/dist/src/core/AppCheckTokenProvider.d.ts +30 -30
- package/dist/src/core/AuthTokenProvider.d.ts +49 -49
- package/dist/src/core/CompoundWrite.d.ts +81 -81
- package/dist/src/core/PersistentConnection.d.ts +135 -135
- package/dist/src/core/ReadonlyRestClient.d.ts +60 -60
- package/dist/src/core/Repo.d.ts +144 -144
- package/dist/src/core/RepoInfo.d.ts +56 -56
- package/dist/src/core/ServerActions.d.ts +52 -52
- package/dist/src/core/SnapshotHolder.d.ts +26 -26
- package/dist/src/core/SparseSnapshotTree.d.ts +64 -64
- package/dist/src/core/SyncPoint.d.ts +91 -91
- package/dist/src/core/SyncTree.d.ts +166 -166
- package/dist/src/core/WriteTree.d.ts +205 -205
- package/dist/src/core/operation/AckUserWrite.d.ts +36 -36
- package/dist/src/core/operation/ListenComplete.d.ts +26 -26
- package/dist/src/core/operation/Merge.d.ts +33 -33
- package/dist/src/core/operation/Operation.d.ts +45 -45
- package/dist/src/core/operation/Overwrite.d.ts +28 -28
- package/dist/src/core/snap/ChildrenNode.d.ts +112 -112
- package/dist/src/core/snap/IndexMap.d.ts +43 -43
- package/dist/src/core/snap/LeafNode.d.ts +83 -83
- package/dist/src/core/snap/Node.d.ts +126 -126
- package/dist/src/core/snap/childSet.d.ts +32 -32
- package/dist/src/core/snap/comparators.d.ts +19 -19
- package/dist/src/core/snap/indexes/Index.d.ts +50 -50
- package/dist/src/core/snap/indexes/KeyIndex.d.ts +34 -34
- package/dist/src/core/snap/indexes/PathIndex.d.ts +29 -29
- package/dist/src/core/snap/indexes/PriorityIndex.d.ts +33 -33
- package/dist/src/core/snap/indexes/ValueIndex.d.ts +31 -31
- package/dist/src/core/snap/nodeFromJSON.d.ts +24 -24
- package/dist/src/core/snap/snap.d.ts +23 -23
- package/dist/src/core/stats/StatsCollection.d.ts +26 -26
- package/dist/src/core/stats/StatsListener.d.ts +30 -30
- package/dist/src/core/stats/StatsManager.d.ts +20 -20
- package/dist/src/core/stats/StatsReporter.d.ts +28 -28
- package/dist/src/core/storage/DOMStorageWrapper.d.ts +46 -46
- package/dist/src/core/storage/MemoryStorage.d.ts +27 -27
- package/dist/src/core/storage/storage.d.ts +22 -22
- package/dist/src/core/util/EventEmitter.d.ts +39 -39
- package/dist/src/core/util/ImmutableTree.d.ts +117 -117
- package/dist/src/core/util/NextPushId.d.ts +33 -33
- package/dist/src/core/util/OnlineMonitor.d.ts +31 -31
- package/dist/src/core/util/Path.d.ts +94 -94
- package/dist/src/core/util/ServerValues.d.ts +56 -56
- package/dist/src/core/util/SortedMap.d.ts +324 -324
- package/dist/src/core/util/Tree.d.ts +105 -105
- package/dist/src/core/util/VisibilityMonitor.d.ts +23 -23
- package/dist/src/core/util/libs/parser.d.ts +32 -32
- package/dist/src/core/util/misc.d.ts +19 -19
- package/dist/src/core/util/util.d.ts +176 -176
- package/dist/src/core/util/validation.d.ts +70 -70
- package/dist/src/core/version.d.ts +23 -23
- package/dist/src/core/view/CacheNode.d.ts +41 -41
- package/dist/src/core/view/Change.d.ts +46 -46
- package/dist/src/core/view/ChildChangeAccumulator.d.ts +22 -22
- package/dist/src/core/view/CompleteChildSource.d.ts +55 -55
- package/dist/src/core/view/Event.d.ts +64 -64
- package/dist/src/core/view/EventGenerator.d.ts +42 -42
- package/dist/src/core/view/EventQueue.d.ts +67 -67
- package/dist/src/core/view/EventRegistration.d.ts +87 -87
- package/dist/src/core/view/QueryParams.d.ts +95 -95
- package/dist/src/core/view/View.d.ts +59 -59
- package/dist/src/core/view/ViewCache.d.ts +32 -32
- package/dist/src/core/view/ViewProcessor.d.ts +32 -32
- package/dist/src/core/view/filter/IndexedFilter.d.ts +35 -35
- package/dist/src/core/view/filter/LimitedFilter.d.ts +47 -47
- package/dist/src/core/view/filter/NodeFilter.d.ts +54 -54
- package/dist/src/core/view/filter/RangedFilter.d.ts +47 -47
- package/dist/src/index.d.ts +28 -28
- package/dist/src/index.node.d.ts +17 -17
- package/dist/src/index.standalone.d.ts +17 -17
- package/dist/src/internal/index.d.ts +38 -38
- package/dist/src/realtime/BrowserPollConnection.d.ts +198 -198
- package/dist/src/realtime/Connection.d.ts +102 -102
- package/dist/src/realtime/Constants.d.ts +27 -27
- package/dist/src/realtime/Transport.d.ts +58 -58
- package/dist/src/realtime/TransportManager.d.ts +50 -50
- package/dist/src/realtime/WebSocketConnection.d.ts +127 -127
- package/dist/src/realtime/polling/PacketReceiver.d.ts +38 -38
- package/dist/src/register.d.ts +1 -1
- package/dist/test/compound_write.test.d.ts +17 -17
- package/dist/test/connection.test.d.ts +17 -17
- package/dist/test/deno.test.d.ts +17 -17
- package/dist/test/exp/integration.test.d.ts +17 -17
- package/dist/test/helpers/EventAccumulator.d.ts +35 -35
- package/dist/test/helpers/syncpoint-util.d.ts +29 -29
- package/dist/test/helpers/util.d.ts +34 -34
- package/dist/test/node.test.d.ts +17 -17
- package/dist/test/parser.test.d.ts +17 -17
- package/dist/test/path.test.d.ts +17 -17
- package/dist/test/pushid.test.d.ts +17 -17
- package/dist/test/queryconstraint.test.d.ts +17 -17
- package/dist/test/repoinfo.test.d.ts +17 -17
- package/dist/test/sortedmap.test.d.ts +17 -17
- package/dist/test/sparsesnapshottree.test.d.ts +17 -17
- package/dist/test/syncpoint.test.d.ts +17 -17
- package/dist/test/transport.test.d.ts +17 -17
- package/dist/test/websocketconnection.test.d.ts +17 -17
- package/package.json +8 -8
|
@@ -1,64 +1,64 @@
|
|
|
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
|
-
/**
|
|
20
|
-
* Helper class to store a sparse set of snapshots.
|
|
21
|
-
*/
|
|
22
|
-
export interface SparseSnapshotTree {
|
|
23
|
-
value: Node | null;
|
|
24
|
-
readonly children: Map<string, SparseSnapshotTree>;
|
|
25
|
-
}
|
|
26
|
-
export declare function newSparseSnapshotTree(): SparseSnapshotTree;
|
|
27
|
-
/**
|
|
28
|
-
* Gets the node stored at the given path if one exists.
|
|
29
|
-
* Only seems to be used in tests.
|
|
30
|
-
*
|
|
31
|
-
* @param path - Path to look up snapshot for.
|
|
32
|
-
* @returns The retrieved node, or null.
|
|
33
|
-
*/
|
|
34
|
-
export declare function sparseSnapshotTreeFind(sparseSnapshotTree: SparseSnapshotTree, path: Path): Node | null;
|
|
35
|
-
/**
|
|
36
|
-
* Stores the given node at the specified path. If there is already a node
|
|
37
|
-
* at a shallower path, it merges the new data into that snapshot node.
|
|
38
|
-
*
|
|
39
|
-
* @param path - Path to look up snapshot for.
|
|
40
|
-
* @param data - The new data, or null.
|
|
41
|
-
*/
|
|
42
|
-
export declare function sparseSnapshotTreeRemember(sparseSnapshotTree: SparseSnapshotTree, path: Path, data: Node): void;
|
|
43
|
-
/**
|
|
44
|
-
* Purge the data at path from the cache.
|
|
45
|
-
*
|
|
46
|
-
* @param path - Path to look up snapshot for.
|
|
47
|
-
* @returns True if this node should now be removed.
|
|
48
|
-
*/
|
|
49
|
-
export declare function sparseSnapshotTreeForget(sparseSnapshotTree: SparseSnapshotTree, path: Path): boolean;
|
|
50
|
-
/**
|
|
51
|
-
* Recursively iterates through all of the stored tree and calls the
|
|
52
|
-
* callback on each one.
|
|
53
|
-
*
|
|
54
|
-
* @param prefixPath - Path to look up node for.
|
|
55
|
-
* @param func - The function to invoke for each tree.
|
|
56
|
-
*/
|
|
57
|
-
export declare function sparseSnapshotTreeForEachTree(sparseSnapshotTree: SparseSnapshotTree, prefixPath: Path, func: (a: Path, b: Node) => unknown): void;
|
|
58
|
-
/**
|
|
59
|
-
* Iterates through each immediate child and triggers the callback.
|
|
60
|
-
* Only seems to be used in tests.
|
|
61
|
-
*
|
|
62
|
-
* @param func - The function to invoke for each child.
|
|
63
|
-
*/
|
|
64
|
-
export declare function sparseSnapshotTreeForEachChild(sparseSnapshotTree: SparseSnapshotTree, func: (a: string, b: SparseSnapshotTree) => void): void;
|
|
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
|
+
/**
|
|
20
|
+
* Helper class to store a sparse set of snapshots.
|
|
21
|
+
*/
|
|
22
|
+
export interface SparseSnapshotTree {
|
|
23
|
+
value: Node | null;
|
|
24
|
+
readonly children: Map<string, SparseSnapshotTree>;
|
|
25
|
+
}
|
|
26
|
+
export declare function newSparseSnapshotTree(): SparseSnapshotTree;
|
|
27
|
+
/**
|
|
28
|
+
* Gets the node stored at the given path if one exists.
|
|
29
|
+
* Only seems to be used in tests.
|
|
30
|
+
*
|
|
31
|
+
* @param path - Path to look up snapshot for.
|
|
32
|
+
* @returns The retrieved node, or null.
|
|
33
|
+
*/
|
|
34
|
+
export declare function sparseSnapshotTreeFind(sparseSnapshotTree: SparseSnapshotTree, path: Path): Node | null;
|
|
35
|
+
/**
|
|
36
|
+
* Stores the given node at the specified path. If there is already a node
|
|
37
|
+
* at a shallower path, it merges the new data into that snapshot node.
|
|
38
|
+
*
|
|
39
|
+
* @param path - Path to look up snapshot for.
|
|
40
|
+
* @param data - The new data, or null.
|
|
41
|
+
*/
|
|
42
|
+
export declare function sparseSnapshotTreeRemember(sparseSnapshotTree: SparseSnapshotTree, path: Path, data: Node): void;
|
|
43
|
+
/**
|
|
44
|
+
* Purge the data at path from the cache.
|
|
45
|
+
*
|
|
46
|
+
* @param path - Path to look up snapshot for.
|
|
47
|
+
* @returns True if this node should now be removed.
|
|
48
|
+
*/
|
|
49
|
+
export declare function sparseSnapshotTreeForget(sparseSnapshotTree: SparseSnapshotTree, path: Path): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Recursively iterates through all of the stored tree and calls the
|
|
52
|
+
* callback on each one.
|
|
53
|
+
*
|
|
54
|
+
* @param prefixPath - Path to look up node for.
|
|
55
|
+
* @param func - The function to invoke for each tree.
|
|
56
|
+
*/
|
|
57
|
+
export declare function sparseSnapshotTreeForEachTree(sparseSnapshotTree: SparseSnapshotTree, prefixPath: Path, func: (a: Path, b: Node) => unknown): void;
|
|
58
|
+
/**
|
|
59
|
+
* Iterates through each immediate child and triggers the callback.
|
|
60
|
+
* Only seems to be used in tests.
|
|
61
|
+
*
|
|
62
|
+
* @param func - The function to invoke for each child.
|
|
63
|
+
*/
|
|
64
|
+
export declare function sparseSnapshotTreeForEachChild(sparseSnapshotTree: SparseSnapshotTree, func: (a: string, b: SparseSnapshotTree) => void): void;
|
|
@@ -1,91 +1,91 @@
|
|
|
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 { ReferenceConstructor } from '../api/Reference';
|
|
18
|
-
import { Operation } from './operation/Operation';
|
|
19
|
-
import { Node } from './snap/Node';
|
|
20
|
-
import { Path } from './util/Path';
|
|
21
|
-
import { Event } from './view/Event';
|
|
22
|
-
import { EventRegistration, QueryContext } from './view/EventRegistration';
|
|
23
|
-
import { View } from './view/View';
|
|
24
|
-
import { WriteTreeRef } from './WriteTree';
|
|
25
|
-
/**
|
|
26
|
-
* SyncPoint represents a single location in a SyncTree with 1 or more event registrations, meaning we need to
|
|
27
|
-
* maintain 1 or more Views at this location to cache server data and raise appropriate events for server changes
|
|
28
|
-
* and user writes (set, transaction, update).
|
|
29
|
-
*
|
|
30
|
-
* It's responsible for:
|
|
31
|
-
* - Maintaining the set of 1 or more views necessary at this location (a SyncPoint with 0 views should be removed).
|
|
32
|
-
* - Proxying user / server operations to the views as appropriate (i.e. applyServerOverwrite,
|
|
33
|
-
* applyUserOverwrite, etc.)
|
|
34
|
-
*/
|
|
35
|
-
export declare class SyncPoint {
|
|
36
|
-
/**
|
|
37
|
-
* The Views being tracked at this location in the tree, stored as a map where the key is a
|
|
38
|
-
* queryId and the value is the View for that query.
|
|
39
|
-
*
|
|
40
|
-
* NOTE: This list will be quite small (usually 1, but perhaps 2 or 3; any more is an odd use case).
|
|
41
|
-
*/
|
|
42
|
-
readonly views: Map<string, View>;
|
|
43
|
-
}
|
|
44
|
-
export declare function syncPointSetReferenceConstructor(val: ReferenceConstructor): void;
|
|
45
|
-
export declare function syncPointIsEmpty(syncPoint: SyncPoint): boolean;
|
|
46
|
-
export declare function syncPointApplyOperation(syncPoint: SyncPoint, operation: Operation, writesCache: WriteTreeRef, optCompleteServerCache: Node | null): Event[];
|
|
47
|
-
/**
|
|
48
|
-
* Get a view for the specified query.
|
|
49
|
-
*
|
|
50
|
-
* @param query - The query to return a view for
|
|
51
|
-
* @param writesCache
|
|
52
|
-
* @param serverCache
|
|
53
|
-
* @param serverCacheComplete
|
|
54
|
-
* @returns Events to raise.
|
|
55
|
-
*/
|
|
56
|
-
export declare function syncPointGetView(syncPoint: SyncPoint, query: QueryContext, writesCache: WriteTreeRef, serverCache: Node | null, serverCacheComplete: boolean): View;
|
|
57
|
-
/**
|
|
58
|
-
* Add an event callback for the specified query.
|
|
59
|
-
*
|
|
60
|
-
* @param query
|
|
61
|
-
* @param eventRegistration
|
|
62
|
-
* @param writesCache
|
|
63
|
-
* @param serverCache - Complete server cache, if we have it.
|
|
64
|
-
* @param serverCacheComplete
|
|
65
|
-
* @returns Events to raise.
|
|
66
|
-
*/
|
|
67
|
-
export declare function syncPointAddEventRegistration(syncPoint: SyncPoint, query: QueryContext, eventRegistration: EventRegistration, writesCache: WriteTreeRef, serverCache: Node | null, serverCacheComplete: boolean): Event[];
|
|
68
|
-
/**
|
|
69
|
-
* Remove event callback(s). Return cancelEvents if a cancelError is specified.
|
|
70
|
-
*
|
|
71
|
-
* If query is the default query, we'll check all views for the specified eventRegistration.
|
|
72
|
-
* If eventRegistration is null, we'll remove all callbacks for the specified view(s).
|
|
73
|
-
*
|
|
74
|
-
* @param eventRegistration - If null, remove all callbacks.
|
|
75
|
-
* @param cancelError - If a cancelError is provided, appropriate cancel events will be returned.
|
|
76
|
-
* @returns removed queries and any cancel events
|
|
77
|
-
*/
|
|
78
|
-
export declare function syncPointRemoveEventRegistration(syncPoint: SyncPoint, query: QueryContext, eventRegistration: EventRegistration | null, cancelError?: Error): {
|
|
79
|
-
removed: QueryContext[];
|
|
80
|
-
events: Event[];
|
|
81
|
-
};
|
|
82
|
-
export declare function syncPointGetQueryViews(syncPoint: SyncPoint): View[];
|
|
83
|
-
/**
|
|
84
|
-
* @param path - The path to the desired complete snapshot
|
|
85
|
-
* @returns A complete cache, if it exists
|
|
86
|
-
*/
|
|
87
|
-
export declare function syncPointGetCompleteServerCache(syncPoint: SyncPoint, path: Path): Node | null;
|
|
88
|
-
export declare function syncPointViewForQuery(syncPoint: SyncPoint, query: QueryContext): View | null;
|
|
89
|
-
export declare function syncPointViewExistsForQuery(syncPoint: SyncPoint, query: QueryContext): boolean;
|
|
90
|
-
export declare function syncPointHasCompleteView(syncPoint: SyncPoint): boolean;
|
|
91
|
-
export declare function syncPointGetCompleteView(syncPoint: SyncPoint): View | null;
|
|
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 { ReferenceConstructor } from '../api/Reference';
|
|
18
|
+
import { Operation } from './operation/Operation';
|
|
19
|
+
import { Node } from './snap/Node';
|
|
20
|
+
import { Path } from './util/Path';
|
|
21
|
+
import { Event } from './view/Event';
|
|
22
|
+
import { EventRegistration, QueryContext } from './view/EventRegistration';
|
|
23
|
+
import { View } from './view/View';
|
|
24
|
+
import { WriteTreeRef } from './WriteTree';
|
|
25
|
+
/**
|
|
26
|
+
* SyncPoint represents a single location in a SyncTree with 1 or more event registrations, meaning we need to
|
|
27
|
+
* maintain 1 or more Views at this location to cache server data and raise appropriate events for server changes
|
|
28
|
+
* and user writes (set, transaction, update).
|
|
29
|
+
*
|
|
30
|
+
* It's responsible for:
|
|
31
|
+
* - Maintaining the set of 1 or more views necessary at this location (a SyncPoint with 0 views should be removed).
|
|
32
|
+
* - Proxying user / server operations to the views as appropriate (i.e. applyServerOverwrite,
|
|
33
|
+
* applyUserOverwrite, etc.)
|
|
34
|
+
*/
|
|
35
|
+
export declare class SyncPoint {
|
|
36
|
+
/**
|
|
37
|
+
* The Views being tracked at this location in the tree, stored as a map where the key is a
|
|
38
|
+
* queryId and the value is the View for that query.
|
|
39
|
+
*
|
|
40
|
+
* NOTE: This list will be quite small (usually 1, but perhaps 2 or 3; any more is an odd use case).
|
|
41
|
+
*/
|
|
42
|
+
readonly views: Map<string, View>;
|
|
43
|
+
}
|
|
44
|
+
export declare function syncPointSetReferenceConstructor(val: ReferenceConstructor): void;
|
|
45
|
+
export declare function syncPointIsEmpty(syncPoint: SyncPoint): boolean;
|
|
46
|
+
export declare function syncPointApplyOperation(syncPoint: SyncPoint, operation: Operation, writesCache: WriteTreeRef, optCompleteServerCache: Node | null): Event[];
|
|
47
|
+
/**
|
|
48
|
+
* Get a view for the specified query.
|
|
49
|
+
*
|
|
50
|
+
* @param query - The query to return a view for
|
|
51
|
+
* @param writesCache
|
|
52
|
+
* @param serverCache
|
|
53
|
+
* @param serverCacheComplete
|
|
54
|
+
* @returns Events to raise.
|
|
55
|
+
*/
|
|
56
|
+
export declare function syncPointGetView(syncPoint: SyncPoint, query: QueryContext, writesCache: WriteTreeRef, serverCache: Node | null, serverCacheComplete: boolean): View;
|
|
57
|
+
/**
|
|
58
|
+
* Add an event callback for the specified query.
|
|
59
|
+
*
|
|
60
|
+
* @param query
|
|
61
|
+
* @param eventRegistration
|
|
62
|
+
* @param writesCache
|
|
63
|
+
* @param serverCache - Complete server cache, if we have it.
|
|
64
|
+
* @param serverCacheComplete
|
|
65
|
+
* @returns Events to raise.
|
|
66
|
+
*/
|
|
67
|
+
export declare function syncPointAddEventRegistration(syncPoint: SyncPoint, query: QueryContext, eventRegistration: EventRegistration, writesCache: WriteTreeRef, serverCache: Node | null, serverCacheComplete: boolean): Event[];
|
|
68
|
+
/**
|
|
69
|
+
* Remove event callback(s). Return cancelEvents if a cancelError is specified.
|
|
70
|
+
*
|
|
71
|
+
* If query is the default query, we'll check all views for the specified eventRegistration.
|
|
72
|
+
* If eventRegistration is null, we'll remove all callbacks for the specified view(s).
|
|
73
|
+
*
|
|
74
|
+
* @param eventRegistration - If null, remove all callbacks.
|
|
75
|
+
* @param cancelError - If a cancelError is provided, appropriate cancel events will be returned.
|
|
76
|
+
* @returns removed queries and any cancel events
|
|
77
|
+
*/
|
|
78
|
+
export declare function syncPointRemoveEventRegistration(syncPoint: SyncPoint, query: QueryContext, eventRegistration: EventRegistration | null, cancelError?: Error): {
|
|
79
|
+
removed: QueryContext[];
|
|
80
|
+
events: Event[];
|
|
81
|
+
};
|
|
82
|
+
export declare function syncPointGetQueryViews(syncPoint: SyncPoint): View[];
|
|
83
|
+
/**
|
|
84
|
+
* @param path - The path to the desired complete snapshot
|
|
85
|
+
* @returns A complete cache, if it exists
|
|
86
|
+
*/
|
|
87
|
+
export declare function syncPointGetCompleteServerCache(syncPoint: SyncPoint, path: Path): Node | null;
|
|
88
|
+
export declare function syncPointViewForQuery(syncPoint: SyncPoint, query: QueryContext): View | null;
|
|
89
|
+
export declare function syncPointViewExistsForQuery(syncPoint: SyncPoint, query: QueryContext): boolean;
|
|
90
|
+
export declare function syncPointHasCompleteView(syncPoint: SyncPoint): boolean;
|
|
91
|
+
export declare function syncPointGetCompleteView(syncPoint: SyncPoint): View | null;
|
|
@@ -1,166 +1,166 @@
|
|
|
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 { ReferenceConstructor } from '../api/Reference';
|
|
18
|
-
import { Node } from './snap/Node';
|
|
19
|
-
import { SyncPoint } from './SyncPoint';
|
|
20
|
-
import { ImmutableTree } from './util/ImmutableTree';
|
|
21
|
-
import { Path } from './util/Path';
|
|
22
|
-
import { Event } from './view/Event';
|
|
23
|
-
import { EventRegistration, QueryContext } from './view/EventRegistration';
|
|
24
|
-
import { WriteTree } from './WriteTree';
|
|
25
|
-
export declare function syncTreeSetReferenceConstructor(val: ReferenceConstructor): void;
|
|
26
|
-
export interface ListenProvider {
|
|
27
|
-
startListening(query: QueryContext, tag: number | null, hashFn: () => string, onComplete: (a: string, b?: unknown) => Event[]): Event[];
|
|
28
|
-
stopListening(a: QueryContext, b: number | null): void;
|
|
29
|
-
}
|
|
30
|
-
export declare function resetSyncTreeTag(): void;
|
|
31
|
-
/**
|
|
32
|
-
* SyncTree is the central class for managing event callback registration, data caching, views
|
|
33
|
-
* (query processing), and event generation. There are typically two SyncTree instances for
|
|
34
|
-
* each Repo, one for the normal Firebase data, and one for the .info data.
|
|
35
|
-
*
|
|
36
|
-
* It has a number of responsibilities, including:
|
|
37
|
-
* - Tracking all user event callbacks (registered via addEventRegistration() and removeEventRegistration()).
|
|
38
|
-
* - Applying and caching data changes for user set(), transaction(), and update() calls
|
|
39
|
-
* (applyUserOverwrite(), applyUserMerge()).
|
|
40
|
-
* - Applying and caching data changes for server data changes (applyServerOverwrite(),
|
|
41
|
-
* applyServerMerge()).
|
|
42
|
-
* - Generating user-facing events for server and user changes (all of the apply* methods
|
|
43
|
-
* return the set of events that need to be raised as a result).
|
|
44
|
-
* - Maintaining the appropriate set of server listens to ensure we are always subscribed
|
|
45
|
-
* to the correct set of paths and queries to satisfy the current set of user event
|
|
46
|
-
* callbacks (listens are started/stopped using the provided listenProvider).
|
|
47
|
-
*
|
|
48
|
-
* NOTE: Although SyncTree tracks event callbacks and calculates events to raise, the actual
|
|
49
|
-
* events are returned to the caller rather than raised synchronously.
|
|
50
|
-
*
|
|
51
|
-
*/
|
|
52
|
-
export declare class SyncTree {
|
|
53
|
-
listenProvider_: ListenProvider;
|
|
54
|
-
/**
|
|
55
|
-
* Tree of SyncPoints. There's a SyncPoint at any location that has 1 or more views.
|
|
56
|
-
*/
|
|
57
|
-
syncPointTree_: ImmutableTree<SyncPoint>;
|
|
58
|
-
/**
|
|
59
|
-
* A tree of all pending user writes (user-initiated set()'s, transaction()'s, update()'s, etc.).
|
|
60
|
-
*/
|
|
61
|
-
pendingWriteTree_: WriteTree;
|
|
62
|
-
readonly tagToQueryMap: Map<number, string>;
|
|
63
|
-
readonly queryToTagMap: Map<string, number>;
|
|
64
|
-
/**
|
|
65
|
-
* @param listenProvider_ - Used by SyncTree to start / stop listening
|
|
66
|
-
* to server data.
|
|
67
|
-
*/
|
|
68
|
-
constructor(listenProvider_: ListenProvider);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Apply the data changes for a user-generated set() or transaction() call.
|
|
72
|
-
*
|
|
73
|
-
* @returns Events to raise.
|
|
74
|
-
*/
|
|
75
|
-
export declare function syncTreeApplyUserOverwrite(syncTree: SyncTree, path: Path, newData: Node, writeId: number, visible?: boolean): Event[];
|
|
76
|
-
/**
|
|
77
|
-
* Apply the data from a user-generated update() call
|
|
78
|
-
*
|
|
79
|
-
* @returns Events to raise.
|
|
80
|
-
*/
|
|
81
|
-
export declare function syncTreeApplyUserMerge(syncTree: SyncTree, path: Path, changedChildren: {
|
|
82
|
-
[k: string]: Node;
|
|
83
|
-
}, writeId: number): Event[];
|
|
84
|
-
/**
|
|
85
|
-
* Acknowledge a pending user write that was previously registered with applyUserOverwrite() or applyUserMerge().
|
|
86
|
-
*
|
|
87
|
-
* @param revert - True if the given write failed and needs to be reverted
|
|
88
|
-
* @returns Events to raise.
|
|
89
|
-
*/
|
|
90
|
-
export declare function syncTreeAckUserWrite(syncTree: SyncTree, writeId: number, revert?: boolean): Event[];
|
|
91
|
-
/**
|
|
92
|
-
* Apply new server data for the specified path..
|
|
93
|
-
*
|
|
94
|
-
* @returns Events to raise.
|
|
95
|
-
*/
|
|
96
|
-
export declare function syncTreeApplyServerOverwrite(syncTree: SyncTree, path: Path, newData: Node): Event[];
|
|
97
|
-
/**
|
|
98
|
-
* Apply new server data to be merged in at the specified path.
|
|
99
|
-
*
|
|
100
|
-
* @returns Events to raise.
|
|
101
|
-
*/
|
|
102
|
-
export declare function syncTreeApplyServerMerge(syncTree: SyncTree, path: Path, changedChildren: {
|
|
103
|
-
[k: string]: Node;
|
|
104
|
-
}): Event[];
|
|
105
|
-
/**
|
|
106
|
-
* Apply a listen complete for a query
|
|
107
|
-
*
|
|
108
|
-
* @returns Events to raise.
|
|
109
|
-
*/
|
|
110
|
-
export declare function syncTreeApplyListenComplete(syncTree: SyncTree, path: Path): Event[];
|
|
111
|
-
/**
|
|
112
|
-
* Apply a listen complete for a tagged query
|
|
113
|
-
*
|
|
114
|
-
* @returns Events to raise.
|
|
115
|
-
*/
|
|
116
|
-
export declare function syncTreeApplyTaggedListenComplete(syncTree: SyncTree, path: Path, tag: number): Event[];
|
|
117
|
-
/**
|
|
118
|
-
* Remove event callback(s).
|
|
119
|
-
*
|
|
120
|
-
* If query is the default query, we'll check all queries for the specified eventRegistration.
|
|
121
|
-
* If eventRegistration is null, we'll remove all callbacks for the specified query/queries.
|
|
122
|
-
*
|
|
123
|
-
* @param eventRegistration - If null, all callbacks are removed.
|
|
124
|
-
* @param cancelError - If a cancelError is provided, appropriate cancel events will be returned.
|
|
125
|
-
* @param skipListenerDedup - When performing a `get()`, we don't add any new listeners, so no
|
|
126
|
-
* deduping needs to take place. This flag allows toggling of that behavior
|
|
127
|
-
* @returns Cancel events, if cancelError was provided.
|
|
128
|
-
*/
|
|
129
|
-
export declare function syncTreeRemoveEventRegistration(syncTree: SyncTree, query: QueryContext, eventRegistration: EventRegistration | null, cancelError?: Error, skipListenerDedup?: boolean): Event[];
|
|
130
|
-
/**
|
|
131
|
-
* Apply new server data for the specified tagged query.
|
|
132
|
-
*
|
|
133
|
-
* @returns Events to raise.
|
|
134
|
-
*/
|
|
135
|
-
export declare function syncTreeApplyTaggedQueryOverwrite(syncTree: SyncTree, path: Path, snap: Node, tag: number): Event[];
|
|
136
|
-
/**
|
|
137
|
-
* Apply server data to be merged in for the specified tagged query.
|
|
138
|
-
*
|
|
139
|
-
* @returns Events to raise.
|
|
140
|
-
*/
|
|
141
|
-
export declare function syncTreeApplyTaggedQueryMerge(syncTree: SyncTree, path: Path, changedChildren: {
|
|
142
|
-
[k: string]: Node;
|
|
143
|
-
}, tag: number): Event[];
|
|
144
|
-
/**
|
|
145
|
-
* Add an event callback for the specified query.
|
|
146
|
-
*
|
|
147
|
-
* @returns Events to raise.
|
|
148
|
-
*/
|
|
149
|
-
export declare function syncTreeAddEventRegistration(syncTree: SyncTree, query: QueryContext, eventRegistration: EventRegistration, skipSetupListener?: boolean): Event[];
|
|
150
|
-
/**
|
|
151
|
-
* Returns a complete cache, if we have one, of the data at a particular path. If the location does not have a
|
|
152
|
-
* listener above it, we will get a false "null". This shouldn't be a problem because transactions will always
|
|
153
|
-
* have a listener above, and atomic operations would correctly show a jitter of <increment value> ->
|
|
154
|
-
* <incremented total> as the write is applied locally and then acknowledged at the server.
|
|
155
|
-
*
|
|
156
|
-
* Note: this method will *include* hidden writes from transaction with applyLocally set to false.
|
|
157
|
-
*
|
|
158
|
-
* @param path - The path to the data we want
|
|
159
|
-
* @param writeIdsToExclude - A specific set to be excluded
|
|
160
|
-
*/
|
|
161
|
-
export declare function syncTreeCalcCompleteEventCache(syncTree: SyncTree, path: Path, writeIdsToExclude?: number[]): Node;
|
|
162
|
-
export declare function syncTreeGetServerValue(syncTree: SyncTree, query: QueryContext): Node | null;
|
|
163
|
-
/**
|
|
164
|
-
* Return the tag associated with the given query.
|
|
165
|
-
*/
|
|
166
|
-
export declare function syncTreeTagForQuery(syncTree: SyncTree, query: QueryContext): number | null;
|
|
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 { ReferenceConstructor } from '../api/Reference';
|
|
18
|
+
import { Node } from './snap/Node';
|
|
19
|
+
import { SyncPoint } from './SyncPoint';
|
|
20
|
+
import { ImmutableTree } from './util/ImmutableTree';
|
|
21
|
+
import { Path } from './util/Path';
|
|
22
|
+
import { Event } from './view/Event';
|
|
23
|
+
import { EventRegistration, QueryContext } from './view/EventRegistration';
|
|
24
|
+
import { WriteTree } from './WriteTree';
|
|
25
|
+
export declare function syncTreeSetReferenceConstructor(val: ReferenceConstructor): void;
|
|
26
|
+
export interface ListenProvider {
|
|
27
|
+
startListening(query: QueryContext, tag: number | null, hashFn: () => string, onComplete: (a: string, b?: unknown) => Event[]): Event[];
|
|
28
|
+
stopListening(a: QueryContext, b: number | null): void;
|
|
29
|
+
}
|
|
30
|
+
export declare function resetSyncTreeTag(): void;
|
|
31
|
+
/**
|
|
32
|
+
* SyncTree is the central class for managing event callback registration, data caching, views
|
|
33
|
+
* (query processing), and event generation. There are typically two SyncTree instances for
|
|
34
|
+
* each Repo, one for the normal Firebase data, and one for the .info data.
|
|
35
|
+
*
|
|
36
|
+
* It has a number of responsibilities, including:
|
|
37
|
+
* - Tracking all user event callbacks (registered via addEventRegistration() and removeEventRegistration()).
|
|
38
|
+
* - Applying and caching data changes for user set(), transaction(), and update() calls
|
|
39
|
+
* (applyUserOverwrite(), applyUserMerge()).
|
|
40
|
+
* - Applying and caching data changes for server data changes (applyServerOverwrite(),
|
|
41
|
+
* applyServerMerge()).
|
|
42
|
+
* - Generating user-facing events for server and user changes (all of the apply* methods
|
|
43
|
+
* return the set of events that need to be raised as a result).
|
|
44
|
+
* - Maintaining the appropriate set of server listens to ensure we are always subscribed
|
|
45
|
+
* to the correct set of paths and queries to satisfy the current set of user event
|
|
46
|
+
* callbacks (listens are started/stopped using the provided listenProvider).
|
|
47
|
+
*
|
|
48
|
+
* NOTE: Although SyncTree tracks event callbacks and calculates events to raise, the actual
|
|
49
|
+
* events are returned to the caller rather than raised synchronously.
|
|
50
|
+
*
|
|
51
|
+
*/
|
|
52
|
+
export declare class SyncTree {
|
|
53
|
+
listenProvider_: ListenProvider;
|
|
54
|
+
/**
|
|
55
|
+
* Tree of SyncPoints. There's a SyncPoint at any location that has 1 or more views.
|
|
56
|
+
*/
|
|
57
|
+
syncPointTree_: ImmutableTree<SyncPoint>;
|
|
58
|
+
/**
|
|
59
|
+
* A tree of all pending user writes (user-initiated set()'s, transaction()'s, update()'s, etc.).
|
|
60
|
+
*/
|
|
61
|
+
pendingWriteTree_: WriteTree;
|
|
62
|
+
readonly tagToQueryMap: Map<number, string>;
|
|
63
|
+
readonly queryToTagMap: Map<string, number>;
|
|
64
|
+
/**
|
|
65
|
+
* @param listenProvider_ - Used by SyncTree to start / stop listening
|
|
66
|
+
* to server data.
|
|
67
|
+
*/
|
|
68
|
+
constructor(listenProvider_: ListenProvider);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Apply the data changes for a user-generated set() or transaction() call.
|
|
72
|
+
*
|
|
73
|
+
* @returns Events to raise.
|
|
74
|
+
*/
|
|
75
|
+
export declare function syncTreeApplyUserOverwrite(syncTree: SyncTree, path: Path, newData: Node, writeId: number, visible?: boolean): Event[];
|
|
76
|
+
/**
|
|
77
|
+
* Apply the data from a user-generated update() call
|
|
78
|
+
*
|
|
79
|
+
* @returns Events to raise.
|
|
80
|
+
*/
|
|
81
|
+
export declare function syncTreeApplyUserMerge(syncTree: SyncTree, path: Path, changedChildren: {
|
|
82
|
+
[k: string]: Node;
|
|
83
|
+
}, writeId: number): Event[];
|
|
84
|
+
/**
|
|
85
|
+
* Acknowledge a pending user write that was previously registered with applyUserOverwrite() or applyUserMerge().
|
|
86
|
+
*
|
|
87
|
+
* @param revert - True if the given write failed and needs to be reverted
|
|
88
|
+
* @returns Events to raise.
|
|
89
|
+
*/
|
|
90
|
+
export declare function syncTreeAckUserWrite(syncTree: SyncTree, writeId: number, revert?: boolean): Event[];
|
|
91
|
+
/**
|
|
92
|
+
* Apply new server data for the specified path..
|
|
93
|
+
*
|
|
94
|
+
* @returns Events to raise.
|
|
95
|
+
*/
|
|
96
|
+
export declare function syncTreeApplyServerOverwrite(syncTree: SyncTree, path: Path, newData: Node): Event[];
|
|
97
|
+
/**
|
|
98
|
+
* Apply new server data to be merged in at the specified path.
|
|
99
|
+
*
|
|
100
|
+
* @returns Events to raise.
|
|
101
|
+
*/
|
|
102
|
+
export declare function syncTreeApplyServerMerge(syncTree: SyncTree, path: Path, changedChildren: {
|
|
103
|
+
[k: string]: Node;
|
|
104
|
+
}): Event[];
|
|
105
|
+
/**
|
|
106
|
+
* Apply a listen complete for a query
|
|
107
|
+
*
|
|
108
|
+
* @returns Events to raise.
|
|
109
|
+
*/
|
|
110
|
+
export declare function syncTreeApplyListenComplete(syncTree: SyncTree, path: Path): Event[];
|
|
111
|
+
/**
|
|
112
|
+
* Apply a listen complete for a tagged query
|
|
113
|
+
*
|
|
114
|
+
* @returns Events to raise.
|
|
115
|
+
*/
|
|
116
|
+
export declare function syncTreeApplyTaggedListenComplete(syncTree: SyncTree, path: Path, tag: number): Event[];
|
|
117
|
+
/**
|
|
118
|
+
* Remove event callback(s).
|
|
119
|
+
*
|
|
120
|
+
* If query is the default query, we'll check all queries for the specified eventRegistration.
|
|
121
|
+
* If eventRegistration is null, we'll remove all callbacks for the specified query/queries.
|
|
122
|
+
*
|
|
123
|
+
* @param eventRegistration - If null, all callbacks are removed.
|
|
124
|
+
* @param cancelError - If a cancelError is provided, appropriate cancel events will be returned.
|
|
125
|
+
* @param skipListenerDedup - When performing a `get()`, we don't add any new listeners, so no
|
|
126
|
+
* deduping needs to take place. This flag allows toggling of that behavior
|
|
127
|
+
* @returns Cancel events, if cancelError was provided.
|
|
128
|
+
*/
|
|
129
|
+
export declare function syncTreeRemoveEventRegistration(syncTree: SyncTree, query: QueryContext, eventRegistration: EventRegistration | null, cancelError?: Error, skipListenerDedup?: boolean): Event[];
|
|
130
|
+
/**
|
|
131
|
+
* Apply new server data for the specified tagged query.
|
|
132
|
+
*
|
|
133
|
+
* @returns Events to raise.
|
|
134
|
+
*/
|
|
135
|
+
export declare function syncTreeApplyTaggedQueryOverwrite(syncTree: SyncTree, path: Path, snap: Node, tag: number): Event[];
|
|
136
|
+
/**
|
|
137
|
+
* Apply server data to be merged in for the specified tagged query.
|
|
138
|
+
*
|
|
139
|
+
* @returns Events to raise.
|
|
140
|
+
*/
|
|
141
|
+
export declare function syncTreeApplyTaggedQueryMerge(syncTree: SyncTree, path: Path, changedChildren: {
|
|
142
|
+
[k: string]: Node;
|
|
143
|
+
}, tag: number): Event[];
|
|
144
|
+
/**
|
|
145
|
+
* Add an event callback for the specified query.
|
|
146
|
+
*
|
|
147
|
+
* @returns Events to raise.
|
|
148
|
+
*/
|
|
149
|
+
export declare function syncTreeAddEventRegistration(syncTree: SyncTree, query: QueryContext, eventRegistration: EventRegistration, skipSetupListener?: boolean): Event[];
|
|
150
|
+
/**
|
|
151
|
+
* Returns a complete cache, if we have one, of the data at a particular path. If the location does not have a
|
|
152
|
+
* listener above it, we will get a false "null". This shouldn't be a problem because transactions will always
|
|
153
|
+
* have a listener above, and atomic operations would correctly show a jitter of <increment value> ->
|
|
154
|
+
* <incremented total> as the write is applied locally and then acknowledged at the server.
|
|
155
|
+
*
|
|
156
|
+
* Note: this method will *include* hidden writes from transaction with applyLocally set to false.
|
|
157
|
+
*
|
|
158
|
+
* @param path - The path to the data we want
|
|
159
|
+
* @param writeIdsToExclude - A specific set to be excluded
|
|
160
|
+
*/
|
|
161
|
+
export declare function syncTreeCalcCompleteEventCache(syncTree: SyncTree, path: Path, writeIdsToExclude?: number[]): Node;
|
|
162
|
+
export declare function syncTreeGetServerValue(syncTree: SyncTree, query: QueryContext): Node | null;
|
|
163
|
+
/**
|
|
164
|
+
* Return the tag associated with the given query.
|
|
165
|
+
*/
|
|
166
|
+
export declare function syncTreeTagForQuery(syncTree: SyncTree, query: QueryContext): number | null;
|