moqtail 0.15.0 → 0.17.0

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 (43) hide show
  1. package/README.md +153 -473
  2. package/dist/client-CjdF7_cL.d.cts +1928 -0
  3. package/dist/{client-BviQ20Lc.cjs → client-FnSNJocV.cjs} +1102 -1192
  4. package/dist/client-I8mDg-Ls.d.mts +1928 -0
  5. package/dist/{client-zi0lmuIL.mjs → client-MXn-lkAA.mjs} +940 -1018
  6. package/dist/client.cjs +202 -7
  7. package/dist/client.d.cts +23 -1944
  8. package/dist/client.d.mts +23 -1944
  9. package/dist/client.mjs +195 -2
  10. package/dist/emitter-UbeRcbuf.mjs +109 -0
  11. package/dist/{logger-c2NoQqtx.cjs → emitter-qNJYD3yQ.cjs} +61 -2
  12. package/dist/{index-BY6e1obL.d.cts → index-BaZgHZ8D.d.mts} +124 -324
  13. package/dist/index-Bn8VlVoN.d.cts +2261 -0
  14. package/dist/index-Ch5QUygw.d.mts +2261 -0
  15. package/dist/index.cjs +18 -14
  16. package/dist/index.d.cts +20 -4
  17. package/dist/index.d.mts +20 -4
  18. package/dist/index.mjs +5 -4
  19. package/dist/logger-B8IYkljn.d.cts +64 -0
  20. package/dist/logger-B8IYkljn.d.mts +64 -0
  21. package/dist/model.cjs +380 -572
  22. package/dist/model.d.cts +2901 -2
  23. package/dist/model.d.mts +17 -2
  24. package/dist/model.mjs +380 -572
  25. package/dist/player/component.cjs +364 -0
  26. package/dist/player/component.d.cts +59 -0
  27. package/dist/player/component.d.mts +59 -0
  28. package/dist/player/component.mjs +362 -0
  29. package/dist/player-C6y-qpHz.cjs +8488 -0
  30. package/dist/player-DfJB6vBH.mjs +8293 -0
  31. package/dist/player.cjs +31 -0
  32. package/dist/player.d.cts +17 -0
  33. package/dist/player.d.mts +17 -0
  34. package/dist/player.mjs +1 -0
  35. package/dist/util.cjs +9 -10
  36. package/dist/util.d.cts +20 -13
  37. package/dist/util.d.mts +20 -13
  38. package/dist/util.mjs +4 -6
  39. package/package.json +46 -5
  40. package/dist/index-BY6e1obL.d.mts +0 -3087
  41. package/dist/logger-ByDB8lYF.mjs +0 -56
  42. package/dist/logger-dEoueCj7.d.cts +0 -35
  43. package/dist/logger-dEoueCj7.d.mts +0 -35
package/dist/client.cjs CHANGED
@@ -1,28 +1,223 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_client = require("./client-BviQ20Lc.cjs");
2
+ const require_client = require("./client-FnSNJocV.cjs");
3
+ const require_emitter = require("./emitter-qNJYD3yQ.cjs");
4
+ const require_model = require("./model.cjs");
5
+ // src/client/track/content_source.ts
6
+ var StaticTrackSource = class {
7
+ cache;
8
+ constructor(cache) {
9
+ this.cache = cache;
10
+ }
11
+ async getRange(start, end) {
12
+ return this.cache.getRange(start, end);
13
+ }
14
+ };
15
+ var LiveTrackSource = class {
16
+ stream;
17
+ #listeners = /* @__PURE__ */ new Set();
18
+ /** Each listener's queue tail, so done waits for the objects still being delivered. */
19
+ #queues = /* @__PURE__ */ new Map();
20
+ #doneListeners = /* @__PURE__ */ new Set();
21
+ #largestLocation;
22
+ #ingestActive = false;
23
+ #reader;
24
+ constructor(stream) {
25
+ this.stream = stream;
26
+ this.#startIngest();
27
+ }
28
+ get largestLocation() {
29
+ return this.#largestLocation;
30
+ }
31
+ async #startIngest() {
32
+ if (this.#ingestActive) return;
33
+ this.#ingestActive = true;
34
+ try {
35
+ this.#reader = this.stream.getReader();
36
+ while (this.#ingestActive) {
37
+ const { value, done } = await this.#reader.read();
38
+ if (done) break;
39
+ this.#largestLocation = value.location;
40
+ for (const listener of this.#listeners) listener(value);
41
+ }
42
+ } catch (error) {
43
+ require_emitter.logger.error("track/content_source", "Error during live object ingestion:", error);
44
+ } finally {
45
+ this.#ingestActive = false;
46
+ this.#reader?.releaseLock();
47
+ const drained = Promise.all([...this.#queues.values()].map((tail) => tail()));
48
+ for (const doneListener of this.#doneListeners) drained.then(() => doneListener());
49
+ }
50
+ }
51
+ onNewObject(listener) {
52
+ let queue = Promise.resolve();
53
+ const queuedListener = (obj) => {
54
+ queue = queue.then(() => listener(obj)).catch((err) => {
55
+ require_emitter.logger.error("track/content_source", "Error in subscriber listener:", err);
56
+ });
57
+ };
58
+ this.#listeners.add(queuedListener);
59
+ this.#queues.set(queuedListener, () => queue);
60
+ return () => {
61
+ this.#queues.delete(queuedListener);
62
+ return this.#listeners.delete(queuedListener);
63
+ };
64
+ }
65
+ onDone(listener) {
66
+ this.#doneListeners.add(listener);
67
+ return () => this.#doneListeners.delete(listener);
68
+ }
69
+ stop() {
70
+ this.#ingestActive = false;
71
+ this.#reader?.cancel();
72
+ }
73
+ };
74
+ var HybridTrackSource = class {
75
+ past;
76
+ live;
77
+ constructor(cache, stream) {
78
+ this.past = new StaticTrackSource(cache);
79
+ this.live = new LiveTrackSource(stream);
80
+ }
81
+ };
82
+ // src/client/track/object_cache.ts
83
+ /**
84
+ * Copyright 2025 The MOQtail Authors
85
+ *
86
+ * Licensed under the Apache License, Version 2.0 (the "License");
87
+ * you may not use this file except in compliance with the License.
88
+ * You may obtain a copy of the License at
89
+ *
90
+ * http://www.apache.org/licenses/LICENSE-2.0
91
+ *
92
+ * Unless required by applicable law or agreed to in writing, software
93
+ * distributed under the License is distributed on an "AS IS" BASIS,
94
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
95
+ * See the License for the specific language governing permissions and
96
+ * limitations under the License.
97
+ */
98
+ var MemoryObjectCache = class {
99
+ objects = [];
100
+ add(obj) {
101
+ const idx = this._findInsertIndex(obj);
102
+ this.objects.splice(idx, 0, obj);
103
+ }
104
+ getRange(start, end) {
105
+ const startIdx = start ? this._findIndex(start, false) : 0;
106
+ const endIdx = end ? this._findIndex(end, true) : this.objects.length;
107
+ return this.objects.slice(startIdx, endIdx);
108
+ }
109
+ getByLocation(location) {
110
+ const idx = this._findIndex(location, false);
111
+ const obj = this.objects[idx];
112
+ if (obj && obj.groupId === location.group && obj.objectId === location.object) return obj;
113
+ }
114
+ size() {
115
+ return this.objects.length;
116
+ }
117
+ clear() {
118
+ this.objects = [];
119
+ }
120
+ _findInsertIndex(obj) {
121
+ let low = 0, high = this.objects.length;
122
+ while (low < high) {
123
+ const mid = low + high >> 1;
124
+ const midObj = this.objects[mid];
125
+ if (!midObj) break;
126
+ if (new require_model.Location(midObj.groupId, midObj.objectId).compare(new require_model.Location(obj.groupId, obj.objectId)) < 0) low = mid + 1;
127
+ else high = mid;
128
+ }
129
+ return low;
130
+ }
131
+ _findIndex(location, exclusive) {
132
+ let low = 0, high = this.objects.length;
133
+ while (low < high) {
134
+ const mid = low + high >> 1;
135
+ const midObj = this.objects[mid];
136
+ if (!midObj) break;
137
+ const cmp = new require_model.Location(midObj.groupId, midObj.objectId).compare(location);
138
+ if (cmp < 0 || exclusive && cmp === 0) low = mid + 1;
139
+ else high = mid;
140
+ }
141
+ return low;
142
+ }
143
+ };
144
+ var RingBufferObjectCache = class {
145
+ buffer;
146
+ maxSize;
147
+ constructor(maxSize = 100) {
148
+ this.buffer = [];
149
+ this.maxSize = maxSize;
150
+ }
151
+ add(obj) {
152
+ const idx = this._findInsertIndex(obj);
153
+ this.buffer.splice(idx, 0, obj);
154
+ if (this.buffer.length > this.maxSize) this.buffer.shift();
155
+ }
156
+ getRange(start, end) {
157
+ const startIdx = start ? this._findIndex(start, false) : 0;
158
+ const endIdx = end ? this._findIndex(end, true) : this.buffer.length;
159
+ return this.buffer.slice(startIdx, endIdx);
160
+ }
161
+ getByLocation(location) {
162
+ const idx = this._findIndex(location, false);
163
+ const obj = this.buffer[idx];
164
+ if (obj && obj.groupId === location.group && obj.objectId === location.object) return obj;
165
+ }
166
+ size() {
167
+ return this.buffer.length;
168
+ }
169
+ clear() {
170
+ this.buffer = [];
171
+ }
172
+ _findInsertIndex(obj) {
173
+ let low = 0, high = this.buffer.length;
174
+ while (low < high) {
175
+ const mid = low + high >> 1;
176
+ const midObj = this.buffer[mid];
177
+ if (!midObj) break;
178
+ if (new require_model.Location(midObj.groupId, midObj.objectId).compare(new require_model.Location(obj.groupId, obj.objectId)) < 0) low = mid + 1;
179
+ else high = mid;
180
+ }
181
+ return low;
182
+ }
183
+ _findIndex(location, exclusive) {
184
+ let low = 0, high = this.buffer.length;
185
+ while (low < high) {
186
+ const mid = low + high >> 1;
187
+ const midObj = this.buffer[mid];
188
+ if (!midObj) break;
189
+ const cmp = new require_model.Location(midObj.groupId, midObj.objectId).compare(location);
190
+ if (cmp < 0 || exclusive && cmp === 0) low = mid + 1;
191
+ else high = mid;
192
+ }
193
+ return low;
194
+ }
195
+ };
3
196
  exports.ControlRecvStream = require_client.ControlRecvStream;
4
197
  exports.ControlSendStream = require_client.ControlSendStream;
5
198
  exports.ControlStream = require_client.ControlStream;
199
+ exports.DEFAULT_FILL_OPEN_TIMEOUT_MS = require_client.DEFAULT_FILL_OPEN_TIMEOUT_MS;
6
200
  exports.DEFAULT_MAX_FILTER_RANGES = require_client.DEFAULT_MAX_FILTER_RANGES;
7
201
  exports.DEFAULT_SWITCH_DRAIN_TIMEOUT_MS = require_client.DEFAULT_SWITCH_DRAIN_TIMEOUT_MS;
8
202
  exports.DEFAULT_TRACK_ALIAS_RESOLUTION_TIMEOUT_MS = require_client.DEFAULT_TRACK_ALIAS_RESOLUTION_TIMEOUT_MS;
9
203
  exports.DataStreamReporter = require_client.DataStreamReporter;
10
204
  exports.FetchPublication = require_client.FetchPublication;
11
205
  exports.FetchRequest = require_client.FetchRequest;
12
- exports.HybridTrackSource = require_client.HybridTrackSource;
13
- exports.LiveTrackSource = require_client.LiveTrackSource;
206
+ exports.HybridTrackSource = HybridTrackSource;
207
+ exports.LiveTrackSource = LiveTrackSource;
14
208
  exports.MOQtailClient = require_client.MOQtailClient;
15
- exports.MemoryObjectCache = require_client.MemoryObjectCache;
209
+ exports.MemoryObjectCache = MemoryObjectCache;
210
+ exports.ObjectOrderer = require_client.ObjectOrderer;
211
+ exports.ObjectStream = require_client.ObjectStream;
16
212
  exports.PublishNamespaceRequest = require_client.PublishNamespaceRequest;
17
213
  exports.PublishPublication = require_client.PublishPublication;
18
214
  exports.PublishRequest = require_client.PublishRequest;
19
- exports.RecvDatagramStream = require_client.RecvDatagramStream;
20
215
  exports.RecvStream = require_client.RecvStream;
21
216
  exports.RequestStream = require_client.RequestStream;
22
- exports.RingBufferObjectCache = require_client.RingBufferObjectCache;
217
+ exports.RingBufferObjectCache = RingBufferObjectCache;
23
218
  exports.SendDatagramStream = require_client.SendDatagramStream;
24
219
  exports.SendStream = require_client.SendStream;
25
- exports.StaticTrackSource = require_client.StaticTrackSource;
220
+ exports.StaticTrackSource = StaticTrackSource;
26
221
  exports.SubscribeNamespaceRequest = require_client.SubscribeNamespaceRequest;
27
222
  exports.SubscribePublication = require_client.SubscribePublication;
28
223
  exports.SubscribeRequest = require_client.SubscribeRequest;