mongodb-livedata-server 0.1.3 → 0.1.5

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.
Files changed (92) hide show
  1. package/README.md +2 -2
  2. package/dist/livedata_server.d.ts +4 -4
  3. package/dist/livedata_server.js +11 -11
  4. package/dist/meteor/binary-heap/max_heap.d.ts +31 -31
  5. package/dist/meteor/binary-heap/max_heap.js +186 -186
  6. package/dist/meteor/binary-heap/min_heap.d.ts +6 -6
  7. package/dist/meteor/binary-heap/min_heap.js +17 -17
  8. package/dist/meteor/binary-heap/min_max_heap.d.ts +11 -11
  9. package/dist/meteor/binary-heap/min_max_heap.js +48 -48
  10. package/dist/meteor/callback-hook/hook.d.ts +11 -11
  11. package/dist/meteor/callback-hook/hook.js +78 -78
  12. package/dist/meteor/ddp/crossbar.d.ts +15 -15
  13. package/dist/meteor/ddp/crossbar.js +136 -136
  14. package/dist/meteor/ddp/heartbeat.d.ts +19 -19
  15. package/dist/meteor/ddp/heartbeat.js +77 -77
  16. package/dist/meteor/ddp/livedata_server.d.ts +141 -142
  17. package/dist/meteor/ddp/livedata_server.js +403 -403
  18. package/dist/meteor/ddp/method-invocation.d.ts +35 -35
  19. package/dist/meteor/ddp/method-invocation.js +72 -72
  20. package/dist/meteor/ddp/random-stream.d.ts +8 -8
  21. package/dist/meteor/ddp/random-stream.js +100 -100
  22. package/dist/meteor/ddp/session-collection-view.d.ts +20 -20
  23. package/dist/meteor/ddp/session-collection-view.js +106 -106
  24. package/dist/meteor/ddp/session-document-view.d.ts +8 -8
  25. package/dist/meteor/ddp/session-document-view.js +82 -82
  26. package/dist/meteor/ddp/session.d.ts +75 -75
  27. package/dist/meteor/ddp/session.js +590 -590
  28. package/dist/meteor/ddp/stream_server.d.ts +20 -21
  29. package/dist/meteor/ddp/stream_server.js +181 -181
  30. package/dist/meteor/ddp/subscription.d.ts +94 -94
  31. package/dist/meteor/ddp/subscription.js +370 -370
  32. package/dist/meteor/ddp/utils.d.ts +8 -8
  33. package/dist/meteor/ddp/utils.js +104 -104
  34. package/dist/meteor/ddp/writefence.d.ts +20 -20
  35. package/dist/meteor/ddp/writefence.js +111 -111
  36. package/dist/meteor/diff-sequence/diff.d.ts +17 -17
  37. package/dist/meteor/diff-sequence/diff.js +257 -257
  38. package/dist/meteor/ejson/ejson.d.ts +82 -82
  39. package/dist/meteor/ejson/ejson.js +568 -569
  40. package/dist/meteor/ejson/stringify.d.ts +2 -2
  41. package/dist/meteor/ejson/stringify.js +119 -119
  42. package/dist/meteor/ejson/utils.d.ts +12 -12
  43. package/dist/meteor/ejson/utils.js +42 -42
  44. package/dist/meteor/mongo/caching_change_observer.d.ts +16 -16
  45. package/dist/meteor/mongo/caching_change_observer.js +63 -63
  46. package/dist/meteor/mongo/doc_fetcher.d.ts +7 -7
  47. package/dist/meteor/mongo/doc_fetcher.js +53 -53
  48. package/dist/meteor/mongo/geojson_utils.d.ts +3 -3
  49. package/dist/meteor/mongo/geojson_utils.js +40 -41
  50. package/dist/meteor/mongo/live_connection.d.ts +28 -28
  51. package/dist/meteor/mongo/live_connection.js +264 -264
  52. package/dist/meteor/mongo/live_cursor.d.ts +25 -25
  53. package/dist/meteor/mongo/live_cursor.js +60 -60
  54. package/dist/meteor/mongo/minimongo_common.d.ts +84 -84
  55. package/dist/meteor/mongo/minimongo_common.js +1998 -1998
  56. package/dist/meteor/mongo/minimongo_matcher.d.ts +23 -23
  57. package/dist/meteor/mongo/minimongo_matcher.js +283 -283
  58. package/dist/meteor/mongo/minimongo_sorter.d.ts +16 -16
  59. package/dist/meteor/mongo/minimongo_sorter.js +268 -268
  60. package/dist/meteor/mongo/observe_driver_utils.d.ts +9 -9
  61. package/dist/meteor/mongo/observe_driver_utils.js +72 -73
  62. package/dist/meteor/mongo/observe_multiplexer.d.ts +46 -46
  63. package/dist/meteor/mongo/observe_multiplexer.js +203 -203
  64. package/dist/meteor/mongo/oplog-observe-driver.d.ts +68 -68
  65. package/dist/meteor/mongo/oplog-observe-driver.js +918 -918
  66. package/dist/meteor/mongo/oplog_tailing.d.ts +35 -35
  67. package/dist/meteor/mongo/oplog_tailing.js +352 -352
  68. package/dist/meteor/mongo/oplog_v2_converter.d.ts +1 -1
  69. package/dist/meteor/mongo/oplog_v2_converter.js +125 -126
  70. package/dist/meteor/mongo/polling_observe_driver.d.ts +30 -30
  71. package/dist/meteor/mongo/polling_observe_driver.js +216 -221
  72. package/dist/meteor/mongo/synchronous-cursor.d.ts +17 -17
  73. package/dist/meteor/mongo/synchronous-cursor.js +261 -261
  74. package/dist/meteor/mongo/synchronous-queue.d.ts +13 -13
  75. package/dist/meteor/mongo/synchronous-queue.js +110 -110
  76. package/dist/meteor/ordered-dict/ordered_dict.d.ts +31 -31
  77. package/dist/meteor/ordered-dict/ordered_dict.js +198 -198
  78. package/dist/meteor/random/AbstractRandomGenerator.d.ts +42 -42
  79. package/dist/meteor/random/AbstractRandomGenerator.js +92 -92
  80. package/dist/meteor/random/AleaRandomGenerator.d.ts +13 -13
  81. package/dist/meteor/random/AleaRandomGenerator.js +90 -90
  82. package/dist/meteor/random/NodeRandomGenerator.d.ts +16 -16
  83. package/dist/meteor/random/NodeRandomGenerator.js +42 -42
  84. package/dist/meteor/random/createAleaGenerator.d.ts +2 -2
  85. package/dist/meteor/random/createAleaGenerator.js +32 -32
  86. package/dist/meteor/random/createRandom.d.ts +1 -1
  87. package/dist/meteor/random/createRandom.js +22 -22
  88. package/dist/meteor/random/main.d.ts +1 -1
  89. package/dist/meteor/random/main.js +12 -12
  90. package/dist/meteor/types.d.ts +1 -1
  91. package/dist/meteor/types.js +2 -2
  92. package/package.json +5 -5
@@ -1,11 +1,11 @@
1
- export declare class Hook {
2
- private nextCallbackId;
3
- private callbacks;
4
- private exceptionHandler;
5
- constructor(options?: any);
6
- register(callback: any): {
7
- callback: any;
8
- stop: () => void;
9
- };
10
- each(iterator: (callback: Function) => boolean): void;
11
- }
1
+ export declare class Hook {
2
+ private nextCallbackId;
3
+ private callbacks;
4
+ private exceptionHandler;
5
+ constructor(options?: any);
6
+ register(callback: any): {
7
+ callback: any;
8
+ stop: () => void;
9
+ };
10
+ each(iterator: (callback: Function) => boolean): void;
11
+ }
@@ -1,78 +1,78 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Hook = void 0;
4
- const hasOwn = Object.prototype.hasOwnProperty;
5
- class Hook {
6
- constructor(options) {
7
- options = options || {};
8
- this.nextCallbackId = 0;
9
- this.callbacks = Object.create(null);
10
- // Whether to wrap callbacks with Meteor.bindEnvironment
11
- if (options.exceptionHandler) {
12
- this.exceptionHandler = options.exceptionHandler;
13
- }
14
- else if (options.debugPrintExceptions) {
15
- if (typeof options.debugPrintExceptions !== "string") {
16
- throw new Error("Hook option debugPrintExceptions should be a string");
17
- }
18
- this.exceptionHandler = options.debugPrintExceptions;
19
- }
20
- }
21
- register(callback) {
22
- var exceptionHandler = this.exceptionHandler || function (exception) {
23
- // Note: this relies on the undocumented fact that if bindEnvironment's
24
- // onException throws, and you are invoking the callback either in the
25
- // browser or from within a Fiber in Node, the exception is propagated.
26
- throw exception;
27
- };
28
- callback = dontBindEnvironment(callback, exceptionHandler);
29
- var id = this.nextCallbackId++;
30
- this.callbacks[id] = callback;
31
- return {
32
- callback,
33
- stop: () => {
34
- delete this.callbacks[id];
35
- }
36
- };
37
- }
38
- // For each registered callback, call the passed iterator function
39
- // with the callback.
40
- //
41
- // The iterator function can choose whether or not to call the
42
- // callback. (For example, it might not call the callback if the
43
- // observed object has been closed or terminated).
44
- //
45
- // The iteration is stopped if the iterator function returns a falsy
46
- // value or throws an exception.
47
- each(iterator) {
48
- var ids = Object.keys(this.callbacks);
49
- for (var i = 0; i < ids.length; ++i) {
50
- var id = ids[i];
51
- // check to see if the callback was removed during iteration
52
- if (hasOwn.call(this.callbacks, id)) {
53
- var callback = this.callbacks[id];
54
- if (!iterator(callback)) {
55
- break;
56
- }
57
- }
58
- }
59
- }
60
- }
61
- exports.Hook = Hook;
62
- function dontBindEnvironment(func, onException, _this) {
63
- if (!onException || typeof (onException) === 'string') {
64
- var description = onException || "callback of async function";
65
- onException = function (error) {
66
- console.error("Exception in " + description, error);
67
- };
68
- }
69
- return function (...args) {
70
- try {
71
- var ret = func.apply(_this, args);
72
- }
73
- catch (e) {
74
- onException(e);
75
- }
76
- return ret;
77
- };
78
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Hook = void 0;
4
+ const hasOwn = Object.prototype.hasOwnProperty;
5
+ class Hook {
6
+ constructor(options) {
7
+ options = options || {};
8
+ this.nextCallbackId = 0;
9
+ this.callbacks = Object.create(null);
10
+ // Whether to wrap callbacks with Meteor.bindEnvironment
11
+ if (options.exceptionHandler) {
12
+ this.exceptionHandler = options.exceptionHandler;
13
+ }
14
+ else if (options.debugPrintExceptions) {
15
+ if (typeof options.debugPrintExceptions !== "string") {
16
+ throw new Error("Hook option debugPrintExceptions should be a string");
17
+ }
18
+ this.exceptionHandler = options.debugPrintExceptions;
19
+ }
20
+ }
21
+ register(callback) {
22
+ var exceptionHandler = this.exceptionHandler || function (exception) {
23
+ // Note: this relies on the undocumented fact that if bindEnvironment's
24
+ // onException throws, and you are invoking the callback either in the
25
+ // browser or from within a Fiber in Node, the exception is propagated.
26
+ throw exception;
27
+ };
28
+ callback = dontBindEnvironment(callback, exceptionHandler);
29
+ var id = this.nextCallbackId++;
30
+ this.callbacks[id] = callback;
31
+ return {
32
+ callback,
33
+ stop: () => {
34
+ delete this.callbacks[id];
35
+ }
36
+ };
37
+ }
38
+ // For each registered callback, call the passed iterator function
39
+ // with the callback.
40
+ //
41
+ // The iterator function can choose whether or not to call the
42
+ // callback. (For example, it might not call the callback if the
43
+ // observed object has been closed or terminated).
44
+ //
45
+ // The iteration is stopped if the iterator function returns a falsy
46
+ // value or throws an exception.
47
+ each(iterator) {
48
+ var ids = Object.keys(this.callbacks);
49
+ for (var i = 0; i < ids.length; ++i) {
50
+ var id = ids[i];
51
+ // check to see if the callback was removed during iteration
52
+ if (hasOwn.call(this.callbacks, id)) {
53
+ var callback = this.callbacks[id];
54
+ if (!iterator(callback)) {
55
+ break;
56
+ }
57
+ }
58
+ }
59
+ }
60
+ }
61
+ exports.Hook = Hook;
62
+ function dontBindEnvironment(func, onException, _this) {
63
+ if (!onException || typeof (onException) === 'string') {
64
+ var description = onException || "callback of async function";
65
+ onException = function (error) {
66
+ console.error("Exception in " + description, error);
67
+ };
68
+ }
69
+ return function (...args) {
70
+ try {
71
+ var ret = func.apply(_this, args);
72
+ }
73
+ catch (e) {
74
+ onException(e);
75
+ }
76
+ return ret;
77
+ };
78
+ }
@@ -1,15 +1,15 @@
1
- export declare class _Crossbar {
2
- private listenersByCollection;
3
- private listenersByCollectionCount;
4
- private nextId;
5
- constructor(options: any);
6
- _collectionForMessage(msg: {
7
- collection?: any;
8
- }): string;
9
- listen(trigger: any, callback: any): {
10
- stop: () => void;
11
- };
12
- fire(notification: Record<string, any>): void;
13
- _matches(notification: Record<string, any>, trigger: Record<string, any>): boolean;
14
- }
15
- export declare const _InvalidationCrossbar: _Crossbar;
1
+ export declare class _Crossbar {
2
+ private listenersByCollection;
3
+ private listenersByCollectionCount;
4
+ private nextId;
5
+ constructor(options: any);
6
+ _collectionForMessage(msg: {
7
+ collection?: any;
8
+ }): string;
9
+ listen(trigger: any, callback: any): {
10
+ stop: () => void;
11
+ };
12
+ fire(notification: Record<string, any>): void;
13
+ _matches(notification: Record<string, any>, trigger: Record<string, any>): boolean;
14
+ }
15
+ export declare const _InvalidationCrossbar: _Crossbar;
@@ -1,136 +1,136 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._InvalidationCrossbar = exports._Crossbar = void 0;
4
- const ejson_1 = require("../ejson/ejson");
5
- // A "crossbar" is a class that provides structured notification registration.
6
- // See _match for the definition of how a notification matches a trigger.
7
- // All notifications and triggers must have a string key named 'collection'.
8
- class _Crossbar {
9
- constructor(options) {
10
- this.listenersByCollection = {};
11
- this.listenersByCollectionCount = {};
12
- options = options || {};
13
- this.nextId = 1;
14
- }
15
- // msg is a trigger or a notification
16
- _collectionForMessage(msg) {
17
- if (!msg.hasOwnProperty('collection')) {
18
- return '';
19
- }
20
- else if (typeof (msg.collection) === 'string') {
21
- if (msg.collection === '')
22
- throw Error("Message has empty collection!");
23
- return msg.collection;
24
- }
25
- else {
26
- throw Error("Message has non-string collection!");
27
- }
28
- }
29
- // Listen for notification that match 'trigger'. A notification
30
- // matches if it has the key-value pairs in trigger as a
31
- // subset. When a notification matches, call 'callback', passing
32
- // the actual notification.
33
- //
34
- // Returns a listen handle, which is an object with a method
35
- // stop(). Call stop() to stop listening.
36
- //
37
- // XXX It should be legal to call fire() from inside a listen()
38
- // callback?
39
- listen(trigger, callback) {
40
- var self = this;
41
- var id = self.nextId++;
42
- var collection = self._collectionForMessage(trigger);
43
- var record = { trigger: (0, ejson_1.clone)(trigger), callback: callback };
44
- if (!self.listenersByCollection.hasOwnProperty(collection)) {
45
- self.listenersByCollection[collection] = {};
46
- self.listenersByCollectionCount[collection] = 0;
47
- }
48
- self.listenersByCollection[collection][id] = record;
49
- self.listenersByCollectionCount[collection]++;
50
- return {
51
- stop: function () {
52
- delete self.listenersByCollection[collection][id];
53
- self.listenersByCollectionCount[collection]--;
54
- if (self.listenersByCollectionCount[collection] === 0) {
55
- delete self.listenersByCollection[collection];
56
- delete self.listenersByCollectionCount[collection];
57
- }
58
- }
59
- };
60
- }
61
- // Fire the provided 'notification' (an object whose attribute
62
- // values are all JSON-compatibile) -- inform all matching listeners
63
- // (registered with listen()).
64
- //
65
- // If fire() is called inside a write fence, then each of the
66
- // listener callbacks will be called inside the write fence as well.
67
- //
68
- // The listeners may be invoked in parallel, rather than serially.
69
- fire(notification) {
70
- var self = this;
71
- var collection = self._collectionForMessage(notification);
72
- if (!self.listenersByCollection.hasOwnProperty(collection)) {
73
- return;
74
- }
75
- var listenersForCollection = self.listenersByCollection[collection];
76
- var callbackIds = [];
77
- Object.entries(listenersForCollection).forEach(function ([id, l]) {
78
- if (self._matches(notification, l.trigger)) {
79
- callbackIds.push(id);
80
- }
81
- });
82
- // Listener callbacks can yield, so we need to first find all the ones that
83
- // match in a single iteration over self.listenersByCollection (which can't
84
- // be mutated during this iteration), and then invoke the matching
85
- // callbacks, checking before each call to ensure they haven't stopped.
86
- // Note that we don't have to check that
87
- // self.listenersByCollection[collection] still === listenersForCollection,
88
- // because the only way that stops being true is if listenersForCollection
89
- // first gets reduced down to the empty object (and then never gets
90
- // increased again).
91
- for (const id of callbackIds) {
92
- if (listenersForCollection.hasOwnProperty(id)) {
93
- listenersForCollection[id].callback(notification);
94
- }
95
- }
96
- }
97
- // A notification matches a trigger if all keys that exist in both are equal.
98
- //
99
- // Examples:
100
- // N:{collection: "C"} matches T:{collection: "C"}
101
- // (a non-targeted write to a collection matches a
102
- // non-targeted query)
103
- // N:{collection: "C", id: "X"} matches T:{collection: "C"}
104
- // (a targeted write to a collection matches a non-targeted query)
105
- // N:{collection: "C"} matches T:{collection: "C", id: "X"}
106
- // (a non-targeted write to a collection matches a
107
- // targeted query)
108
- // N:{collection: "C", id: "X"} matches T:{collection: "C", id: "X"}
109
- // (a targeted write to a collection matches a targeted query targeted
110
- // at the same document)
111
- // N:{collection: "C", id: "X"} does not match T:{collection: "C", id: "Y"}
112
- // (a targeted write to a collection does not match a targeted query
113
- // targeted at a different document)
114
- _matches(notification, trigger) {
115
- // Most notifications that use the crossbar have a string `collection` and
116
- // maybe an `id` that is a string or ObjectID. We're already dividing up
117
- // triggers by collection, but let's fast-track "nope, different ID" (and
118
- // avoid the overly generic EJSON.equals). This makes a noticeable
119
- // performance difference; see https://github.com/meteor/meteor/pull/3697
120
- if (typeof (notification.id) === 'string' && typeof (trigger.id) === 'string' && notification.id !== trigger.id) {
121
- return false;
122
- }
123
- return Object.entries(trigger).every(([key, triggerValue]) => {
124
- return !notification.hasOwnProperty(key) || (0, ejson_1.equals)(triggerValue, notification[key]);
125
- });
126
- }
127
- }
128
- exports._Crossbar = _Crossbar;
129
- // The "invalidation crossbar" is a specific instance used by the DDP server to
130
- // implement write fence notifications. Listener callbacks on this crossbar
131
- // should call beginWrite on the current write fence before they return, if they
132
- // want to delay the write fence from firing (ie, the DDP method-data-updated
133
- // message from being sent).
134
- exports._InvalidationCrossbar = new _Crossbar({
135
- factName: "invalidation-crossbar-listeners"
136
- });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports._InvalidationCrossbar = exports._Crossbar = void 0;
4
+ const ejson_1 = require("../ejson/ejson");
5
+ // A "crossbar" is a class that provides structured notification registration.
6
+ // See _match for the definition of how a notification matches a trigger.
7
+ // All notifications and triggers must have a string key named 'collection'.
8
+ class _Crossbar {
9
+ constructor(options) {
10
+ this.listenersByCollection = {};
11
+ this.listenersByCollectionCount = {};
12
+ options = options || {};
13
+ this.nextId = 1;
14
+ }
15
+ // msg is a trigger or a notification
16
+ _collectionForMessage(msg) {
17
+ if (!msg.hasOwnProperty('collection')) {
18
+ return '';
19
+ }
20
+ else if (typeof (msg.collection) === 'string') {
21
+ if (msg.collection === '')
22
+ throw Error("Message has empty collection!");
23
+ return msg.collection;
24
+ }
25
+ else {
26
+ throw Error("Message has non-string collection!");
27
+ }
28
+ }
29
+ // Listen for notification that match 'trigger'. A notification
30
+ // matches if it has the key-value pairs in trigger as a
31
+ // subset. When a notification matches, call 'callback', passing
32
+ // the actual notification.
33
+ //
34
+ // Returns a listen handle, which is an object with a method
35
+ // stop(). Call stop() to stop listening.
36
+ //
37
+ // XXX It should be legal to call fire() from inside a listen()
38
+ // callback?
39
+ listen(trigger, callback) {
40
+ var self = this;
41
+ var id = self.nextId++;
42
+ var collection = self._collectionForMessage(trigger);
43
+ var record = { trigger: (0, ejson_1.clone)(trigger), callback: callback };
44
+ if (!self.listenersByCollection.hasOwnProperty(collection)) {
45
+ self.listenersByCollection[collection] = {};
46
+ self.listenersByCollectionCount[collection] = 0;
47
+ }
48
+ self.listenersByCollection[collection][id] = record;
49
+ self.listenersByCollectionCount[collection]++;
50
+ return {
51
+ stop: function () {
52
+ delete self.listenersByCollection[collection][id];
53
+ self.listenersByCollectionCount[collection]--;
54
+ if (self.listenersByCollectionCount[collection] === 0) {
55
+ delete self.listenersByCollection[collection];
56
+ delete self.listenersByCollectionCount[collection];
57
+ }
58
+ }
59
+ };
60
+ }
61
+ // Fire the provided 'notification' (an object whose attribute
62
+ // values are all JSON-compatibile) -- inform all matching listeners
63
+ // (registered with listen()).
64
+ //
65
+ // If fire() is called inside a write fence, then each of the
66
+ // listener callbacks will be called inside the write fence as well.
67
+ //
68
+ // The listeners may be invoked in parallel, rather than serially.
69
+ fire(notification) {
70
+ var self = this;
71
+ var collection = self._collectionForMessage(notification);
72
+ if (!self.listenersByCollection.hasOwnProperty(collection)) {
73
+ return;
74
+ }
75
+ var listenersForCollection = self.listenersByCollection[collection];
76
+ var callbackIds = [];
77
+ Object.entries(listenersForCollection).forEach(function ([id, l]) {
78
+ if (self._matches(notification, l.trigger)) {
79
+ callbackIds.push(id);
80
+ }
81
+ });
82
+ // Listener callbacks can yield, so we need to first find all the ones that
83
+ // match in a single iteration over self.listenersByCollection (which can't
84
+ // be mutated during this iteration), and then invoke the matching
85
+ // callbacks, checking before each call to ensure they haven't stopped.
86
+ // Note that we don't have to check that
87
+ // self.listenersByCollection[collection] still === listenersForCollection,
88
+ // because the only way that stops being true is if listenersForCollection
89
+ // first gets reduced down to the empty object (and then never gets
90
+ // increased again).
91
+ for (const id of callbackIds) {
92
+ if (listenersForCollection.hasOwnProperty(id)) {
93
+ listenersForCollection[id].callback(notification);
94
+ }
95
+ }
96
+ }
97
+ // A notification matches a trigger if all keys that exist in both are equal.
98
+ //
99
+ // Examples:
100
+ // N:{collection: "C"} matches T:{collection: "C"}
101
+ // (a non-targeted write to a collection matches a
102
+ // non-targeted query)
103
+ // N:{collection: "C", id: "X"} matches T:{collection: "C"}
104
+ // (a targeted write to a collection matches a non-targeted query)
105
+ // N:{collection: "C"} matches T:{collection: "C", id: "X"}
106
+ // (a non-targeted write to a collection matches a
107
+ // targeted query)
108
+ // N:{collection: "C", id: "X"} matches T:{collection: "C", id: "X"}
109
+ // (a targeted write to a collection matches a targeted query targeted
110
+ // at the same document)
111
+ // N:{collection: "C", id: "X"} does not match T:{collection: "C", id: "Y"}
112
+ // (a targeted write to a collection does not match a targeted query
113
+ // targeted at a different document)
114
+ _matches(notification, trigger) {
115
+ // Most notifications that use the crossbar have a string `collection` and
116
+ // maybe an `id` that is a string or ObjectID. We're already dividing up
117
+ // triggers by collection, but let's fast-track "nope, different ID" (and
118
+ // avoid the overly generic EJSON.equals). This makes a noticeable
119
+ // performance difference; see https://github.com/meteor/meteor/pull/3697
120
+ if (typeof (notification.id) === 'string' && typeof (trigger.id) === 'string' && notification.id !== trigger.id) {
121
+ return false;
122
+ }
123
+ return Object.entries(trigger).every(([key, triggerValue]) => {
124
+ return !notification.hasOwnProperty(key) || (0, ejson_1.equals)(triggerValue, notification[key]);
125
+ });
126
+ }
127
+ }
128
+ exports._Crossbar = _Crossbar;
129
+ // The "invalidation crossbar" is a specific instance used by the DDP server to
130
+ // implement write fence notifications. Listener callbacks on this crossbar
131
+ // should call beginWrite on the current write fence before they return, if they
132
+ // want to delay the write fence from firing (ie, the DDP method-data-updated
133
+ // message from being sent).
134
+ exports._InvalidationCrossbar = new _Crossbar({
135
+ factName: "invalidation-crossbar-listeners"
136
+ });
@@ -1,19 +1,19 @@
1
- export declare class Heartbeat {
2
- private heartbeatInterval;
3
- private heartbeatTimeout;
4
- private _sendPing;
5
- private _onTimeout;
6
- private _seenPacket;
7
- private _heartbeatIntervalHandle;
8
- private _heartbeatTimeoutHandle;
9
- constructor(options: any);
10
- stop(): void;
11
- start(): void;
12
- _startHeartbeatIntervalTimer(): void;
13
- _startHeartbeatTimeoutTimer(): void;
14
- _clearHeartbeatIntervalTimer(): void;
15
- _clearHeartbeatTimeoutTimer(): void;
16
- _heartbeatIntervalFired(): void;
17
- _heartbeatTimeoutFired(): void;
18
- messageReceived(): void;
19
- }
1
+ export declare class Heartbeat {
2
+ private heartbeatInterval;
3
+ private heartbeatTimeout;
4
+ private _sendPing;
5
+ private _onTimeout;
6
+ private _seenPacket;
7
+ private _heartbeatIntervalHandle;
8
+ private _heartbeatTimeoutHandle;
9
+ constructor(options: any);
10
+ stop(): void;
11
+ start(): void;
12
+ _startHeartbeatIntervalTimer(): void;
13
+ _startHeartbeatTimeoutTimer(): void;
14
+ _clearHeartbeatIntervalTimer(): void;
15
+ _clearHeartbeatTimeoutTimer(): void;
16
+ _heartbeatIntervalFired(): void;
17
+ _heartbeatTimeoutFired(): void;
18
+ messageReceived(): void;
19
+ }