moqtail 0.14.0 → 0.16.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.
- package/README.md +153 -473
- package/dist/{client-Z7egUKTO.cjs → client-DQ5aGbLR.cjs} +1100 -1099
- package/dist/client-DUzLw_Y8.d.cts +1932 -0
- package/dist/{client-BW1agDFV.mjs → client-DVi4Nh1J.mjs} +942 -947
- package/dist/client-epHqMdHm.d.mts +1932 -0
- package/dist/client.cjs +121 -4
- package/dist/client.d.cts +23 -1933
- package/dist/client.d.mts +23 -1933
- package/dist/client.mjs +117 -2
- package/dist/emitter-UbeRcbuf.mjs +109 -0
- package/dist/{logger-c2NoQqtx.cjs → emitter-qNJYD3yQ.cjs} +61 -2
- package/dist/index-B-BMK-b6.d.mts +2090 -0
- package/dist/index-BtemTtwe.d.cts +2090 -0
- package/dist/{index-DBbxKcc1.d.cts → index-CNn9BgO6.d.mts} +168 -337
- package/dist/index.cjs +39 -34
- package/dist/index.d.cts +20 -4
- package/dist/index.d.mts +20 -4
- package/dist/index.mjs +5 -4
- package/dist/logger-B8IYkljn.d.cts +64 -0
- package/dist/logger-B8IYkljn.d.mts +64 -0
- package/dist/model.cjs +208 -359
- package/dist/model.d.cts +2896 -2
- package/dist/model.d.mts +17 -2
- package/dist/model.mjs +207 -359
- package/dist/player/component.cjs +317 -0
- package/dist/player/component.d.cts +50 -0
- package/dist/player/component.d.mts +50 -0
- package/dist/player/component.mjs +315 -0
- package/dist/player-CJayEzwt.cjs +6750 -0
- package/dist/player-DcctWhyM.mjs +6599 -0
- package/dist/player.cjs +27 -0
- package/dist/player.d.cts +17 -0
- package/dist/player.d.mts +17 -0
- package/dist/player.mjs +1 -0
- package/dist/rolldown-runtime-CmQyd0Gu.cjs +27 -0
- package/dist/util.cjs +9 -10
- package/dist/util.d.cts +20 -13
- package/dist/util.d.mts +20 -13
- package/dist/util.mjs +4 -6
- package/package.json +45 -5
- package/dist/index-DBbxKcc1.d.mts +0 -3051
- package/dist/logger-ByDB8lYF.mjs +0 -56
- package/dist/logger-dEoueCj7.d.cts +0 -35
- package/dist/logger-dEoueCj7.d.mts +0 -35
package/dist/client.mjs
CHANGED
|
@@ -1,2 +1,117 @@
|
|
|
1
|
-
import { C as SendStream, D as ControlSendStream, E as ControlRecvStream, O as ControlStream, S as RecvStream, T as RequestStream, _ as
|
|
2
|
-
|
|
1
|
+
import { C as SendStream, D as ControlSendStream, E as ControlRecvStream, O as ControlStream, S as RecvStream, T as RequestStream, _ as ObjectStream, a as SubscribeNamespaceRequest, b as LiveTrackSource, c as TrackStatusRequest, d as Subscription, f as DEFAULT_FILL_OPEN_TIMEOUT_MS, g as FetchRequest, h as DEFAULT_TRACK_ALIAS_RESOLUTION_TIMEOUT_MS, i as PublishPublication, l as PublishRequest, m as DEFAULT_SWITCH_DRAIN_TIMEOUT_MS, n as ObjectOrderer, o as SubscribePublication, p as DEFAULT_MAX_FILTER_RANGES, r as SendDatagramStream, s as FetchPublication, t as MOQtailClient, u as SubscribeRequest, v as PublishNamespaceRequest, w as DataStreamReporter, x as StaticTrackSource, y as HybridTrackSource } from "./client-DVi4Nh1J.mjs";
|
|
2
|
+
import { Location } from "./model.mjs";
|
|
3
|
+
// src/client/track/object_cache.ts
|
|
4
|
+
/**
|
|
5
|
+
* Copyright 2025 The MOQtail Authors
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
var MemoryObjectCache = class {
|
|
20
|
+
objects = [];
|
|
21
|
+
add(obj) {
|
|
22
|
+
const idx = this._findInsertIndex(obj);
|
|
23
|
+
this.objects.splice(idx, 0, obj);
|
|
24
|
+
}
|
|
25
|
+
getRange(start, end) {
|
|
26
|
+
const startIdx = start ? this._findIndex(start, false) : 0;
|
|
27
|
+
const endIdx = end ? this._findIndex(end, true) : this.objects.length;
|
|
28
|
+
return this.objects.slice(startIdx, endIdx);
|
|
29
|
+
}
|
|
30
|
+
getByLocation(location) {
|
|
31
|
+
const idx = this._findIndex(location, false);
|
|
32
|
+
const obj = this.objects[idx];
|
|
33
|
+
if (obj && obj.groupId === location.group && obj.objectId === location.object) return obj;
|
|
34
|
+
}
|
|
35
|
+
size() {
|
|
36
|
+
return this.objects.length;
|
|
37
|
+
}
|
|
38
|
+
clear() {
|
|
39
|
+
this.objects = [];
|
|
40
|
+
}
|
|
41
|
+
_findInsertIndex(obj) {
|
|
42
|
+
let low = 0, high = this.objects.length;
|
|
43
|
+
while (low < high) {
|
|
44
|
+
const mid = low + high >> 1;
|
|
45
|
+
const midObj = this.objects[mid];
|
|
46
|
+
if (!midObj) break;
|
|
47
|
+
if (new Location(midObj.groupId, midObj.objectId).compare(new Location(obj.groupId, obj.objectId)) < 0) low = mid + 1;
|
|
48
|
+
else high = mid;
|
|
49
|
+
}
|
|
50
|
+
return low;
|
|
51
|
+
}
|
|
52
|
+
_findIndex(location, exclusive) {
|
|
53
|
+
let low = 0, high = this.objects.length;
|
|
54
|
+
while (low < high) {
|
|
55
|
+
const mid = low + high >> 1;
|
|
56
|
+
const midObj = this.objects[mid];
|
|
57
|
+
if (!midObj) break;
|
|
58
|
+
const cmp = new Location(midObj.groupId, midObj.objectId).compare(location);
|
|
59
|
+
if (cmp < 0 || exclusive && cmp === 0) low = mid + 1;
|
|
60
|
+
else high = mid;
|
|
61
|
+
}
|
|
62
|
+
return low;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
var RingBufferObjectCache = class {
|
|
66
|
+
buffer;
|
|
67
|
+
maxSize;
|
|
68
|
+
constructor(maxSize = 100) {
|
|
69
|
+
this.buffer = [];
|
|
70
|
+
this.maxSize = maxSize;
|
|
71
|
+
}
|
|
72
|
+
add(obj) {
|
|
73
|
+
const idx = this._findInsertIndex(obj);
|
|
74
|
+
this.buffer.splice(idx, 0, obj);
|
|
75
|
+
if (this.buffer.length > this.maxSize) this.buffer.shift();
|
|
76
|
+
}
|
|
77
|
+
getRange(start, end) {
|
|
78
|
+
const startIdx = start ? this._findIndex(start, false) : 0;
|
|
79
|
+
const endIdx = end ? this._findIndex(end, true) : this.buffer.length;
|
|
80
|
+
return this.buffer.slice(startIdx, endIdx);
|
|
81
|
+
}
|
|
82
|
+
getByLocation(location) {
|
|
83
|
+
const idx = this._findIndex(location, false);
|
|
84
|
+
const obj = this.buffer[idx];
|
|
85
|
+
if (obj && obj.groupId === location.group && obj.objectId === location.object) return obj;
|
|
86
|
+
}
|
|
87
|
+
size() {
|
|
88
|
+
return this.buffer.length;
|
|
89
|
+
}
|
|
90
|
+
clear() {
|
|
91
|
+
this.buffer = [];
|
|
92
|
+
}
|
|
93
|
+
_findInsertIndex(obj) {
|
|
94
|
+
let low = 0, high = this.buffer.length;
|
|
95
|
+
while (low < high) {
|
|
96
|
+
const mid = low + high >> 1;
|
|
97
|
+
const midObj = this.buffer[mid];
|
|
98
|
+
if (!midObj) break;
|
|
99
|
+
if (new Location(midObj.groupId, midObj.objectId).compare(new Location(obj.groupId, obj.objectId)) < 0) low = mid + 1;
|
|
100
|
+
else high = mid;
|
|
101
|
+
}
|
|
102
|
+
return low;
|
|
103
|
+
}
|
|
104
|
+
_findIndex(location, exclusive) {
|
|
105
|
+
let low = 0, high = this.buffer.length;
|
|
106
|
+
while (low < high) {
|
|
107
|
+
const mid = low + high >> 1;
|
|
108
|
+
const midObj = this.buffer[mid];
|
|
109
|
+
if (!midObj) break;
|
|
110
|
+
const cmp = new Location(midObj.groupId, midObj.objectId).compare(location);
|
|
111
|
+
if (cmp < 0 || exclusive && cmp === 0) low = mid + 1;
|
|
112
|
+
else high = mid;
|
|
113
|
+
}
|
|
114
|
+
return low;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
export { ControlRecvStream, ControlSendStream, ControlStream, DEFAULT_FILL_OPEN_TIMEOUT_MS, DEFAULT_MAX_FILTER_RANGES, DEFAULT_SWITCH_DRAIN_TIMEOUT_MS, DEFAULT_TRACK_ALIAS_RESOLUTION_TIMEOUT_MS, DataStreamReporter, FetchPublication, FetchRequest, HybridTrackSource, LiveTrackSource, MOQtailClient, MemoryObjectCache, ObjectOrderer, ObjectStream, PublishNamespaceRequest, PublishPublication, PublishRequest, RecvStream, RequestStream, RingBufferObjectCache, SendDatagramStream, SendStream, StaticTrackSource, SubscribeNamespaceRequest, SubscribePublication, SubscribeRequest, Subscription, TrackStatusRequest };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// src/util/logger.ts
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2026 The MOQtail Authors
|
|
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
|
+
let LogLevel = /* @__PURE__ */ function(LogLevel) {
|
|
18
|
+
LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG";
|
|
19
|
+
LogLevel[LogLevel["LOG"] = 1] = "LOG";
|
|
20
|
+
LogLevel[LogLevel["WARN"] = 2] = "WARN";
|
|
21
|
+
LogLevel[LogLevel["ERROR"] = 3] = "ERROR";
|
|
22
|
+
LogLevel[LogLevel["NONE"] = 4] = "NONE";
|
|
23
|
+
return LogLevel;
|
|
24
|
+
}({});
|
|
25
|
+
const _config = {
|
|
26
|
+
level: 2,
|
|
27
|
+
enabledModules: null
|
|
28
|
+
};
|
|
29
|
+
function setLogLevel(level) {
|
|
30
|
+
_config.level = level;
|
|
31
|
+
}
|
|
32
|
+
function setLogEnabledModules(modules) {
|
|
33
|
+
_config.enabledModules = modules;
|
|
34
|
+
}
|
|
35
|
+
var Logger = class {
|
|
36
|
+
isEnabled(module, level) {
|
|
37
|
+
if (level < _config.level) return false;
|
|
38
|
+
if (_config.enabledModules !== null && !_config.enabledModules.includes(module)) return false;
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
debug(module, ...args) {
|
|
42
|
+
if (this.isEnabled(module, 0)) console.debug(`[MOQtail][${module}]`, ...args);
|
|
43
|
+
}
|
|
44
|
+
log(module, ...args) {
|
|
45
|
+
if (this.isEnabled(module, 1)) console.log(`[MOQtail][${module}]`, ...args);
|
|
46
|
+
}
|
|
47
|
+
warn(module, ...args) {
|
|
48
|
+
if (this.isEnabled(module, 2)) console.warn(`[MOQtail][${module}]`, ...args);
|
|
49
|
+
}
|
|
50
|
+
error(module, ...args) {
|
|
51
|
+
if (this.isEnabled(module, 3)) console.error(`[MOQtail][${module}]`, ...args);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const logger = new Logger();
|
|
55
|
+
// src/util/emitter.ts
|
|
56
|
+
/**
|
|
57
|
+
* Copyright 2026 The MOQtail Authors
|
|
58
|
+
*
|
|
59
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
60
|
+
* you may not use this file except in compliance with the License.
|
|
61
|
+
* You may obtain a copy of the License at
|
|
62
|
+
*
|
|
63
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
64
|
+
*
|
|
65
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
66
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
67
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
68
|
+
* See the License for the specific language governing permissions and
|
|
69
|
+
* limitations under the License.
|
|
70
|
+
*/
|
|
71
|
+
/**
|
|
72
|
+
* @public
|
|
73
|
+
* A typed event emitter over a private `EventTarget`. `Events` maps each event name to
|
|
74
|
+
* its listener signature, so the name decides what a listener receives and what
|
|
75
|
+
* `emit()` must be given. A throwing listener doesn't affect the others: `EventTarget`
|
|
76
|
+
* reports it to the global error handler.
|
|
77
|
+
*/
|
|
78
|
+
var Emitter = class {
|
|
79
|
+
#target = new EventTarget();
|
|
80
|
+
/** Maps each listener to the function given to `addEventListener`, which unpacks `detail`. */
|
|
81
|
+
#wrappers = /* @__PURE__ */ new Map();
|
|
82
|
+
/** Adds `listener` for `event`. Adding the same function twice has no effect. */
|
|
83
|
+
on(event, listener) {
|
|
84
|
+
let wrappers = this.#wrappers.get(event);
|
|
85
|
+
if (!wrappers) {
|
|
86
|
+
wrappers = /* @__PURE__ */ new Map();
|
|
87
|
+
this.#wrappers.set(event, wrappers);
|
|
88
|
+
}
|
|
89
|
+
if (wrappers.has(listener)) return;
|
|
90
|
+
const wrapper = (e) => listener(...e.detail);
|
|
91
|
+
wrappers.set(listener, wrapper);
|
|
92
|
+
this.#target.addEventListener(event, wrapper);
|
|
93
|
+
}
|
|
94
|
+
/** Removes `listener`, the same function given to {@link Emitter.on}, from `event`. */
|
|
95
|
+
off(event, listener) {
|
|
96
|
+
const wrappers = this.#wrappers.get(event);
|
|
97
|
+
const wrapper = wrappers?.get(listener);
|
|
98
|
+
if (!wrappers || !wrapper) return;
|
|
99
|
+
wrappers.delete(listener);
|
|
100
|
+
if (wrappers.size === 0) this.#wrappers.delete(event);
|
|
101
|
+
this.#target.removeEventListener(event, wrapper);
|
|
102
|
+
}
|
|
103
|
+
/** Calls every listener of `event` with `args`. Allocates nothing when there are none. */
|
|
104
|
+
emit(event, ...args) {
|
|
105
|
+
if (!this.#wrappers.has(event)) return;
|
|
106
|
+
this.#target.dispatchEvent(new CustomEvent(event, { detail: args }));
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
export { setLogEnabledModules as a, logger as i, LogLevel as n, setLogLevel as o, Logger as r, Emitter as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/util/logger.ts
|
|
2
2
|
/**
|
|
3
3
|
* Copyright 2026 The MOQtail Authors
|
|
4
4
|
*
|
|
@@ -52,7 +52,66 @@ var Logger = class {
|
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
54
|
const logger = new Logger();
|
|
55
|
-
|
|
55
|
+
// src/util/emitter.ts
|
|
56
|
+
/**
|
|
57
|
+
* Copyright 2026 The MOQtail Authors
|
|
58
|
+
*
|
|
59
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
60
|
+
* you may not use this file except in compliance with the License.
|
|
61
|
+
* You may obtain a copy of the License at
|
|
62
|
+
*
|
|
63
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
64
|
+
*
|
|
65
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
66
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
67
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
68
|
+
* See the License for the specific language governing permissions and
|
|
69
|
+
* limitations under the License.
|
|
70
|
+
*/
|
|
71
|
+
/**
|
|
72
|
+
* @public
|
|
73
|
+
* A typed event emitter over a private `EventTarget`. `Events` maps each event name to
|
|
74
|
+
* its listener signature, so the name decides what a listener receives and what
|
|
75
|
+
* `emit()` must be given. A throwing listener doesn't affect the others: `EventTarget`
|
|
76
|
+
* reports it to the global error handler.
|
|
77
|
+
*/
|
|
78
|
+
var Emitter = class {
|
|
79
|
+
#target = new EventTarget();
|
|
80
|
+
/** Maps each listener to the function given to `addEventListener`, which unpacks `detail`. */
|
|
81
|
+
#wrappers = /* @__PURE__ */ new Map();
|
|
82
|
+
/** Adds `listener` for `event`. Adding the same function twice has no effect. */
|
|
83
|
+
on(event, listener) {
|
|
84
|
+
let wrappers = this.#wrappers.get(event);
|
|
85
|
+
if (!wrappers) {
|
|
86
|
+
wrappers = /* @__PURE__ */ new Map();
|
|
87
|
+
this.#wrappers.set(event, wrappers);
|
|
88
|
+
}
|
|
89
|
+
if (wrappers.has(listener)) return;
|
|
90
|
+
const wrapper = (e) => listener(...e.detail);
|
|
91
|
+
wrappers.set(listener, wrapper);
|
|
92
|
+
this.#target.addEventListener(event, wrapper);
|
|
93
|
+
}
|
|
94
|
+
/** Removes `listener`, the same function given to {@link Emitter.on}, from `event`. */
|
|
95
|
+
off(event, listener) {
|
|
96
|
+
const wrappers = this.#wrappers.get(event);
|
|
97
|
+
const wrapper = wrappers?.get(listener);
|
|
98
|
+
if (!wrappers || !wrapper) return;
|
|
99
|
+
wrappers.delete(listener);
|
|
100
|
+
if (wrappers.size === 0) this.#wrappers.delete(event);
|
|
101
|
+
this.#target.removeEventListener(event, wrapper);
|
|
102
|
+
}
|
|
103
|
+
/** Calls every listener of `event` with `args`. Allocates nothing when there are none. */
|
|
104
|
+
emit(event, ...args) {
|
|
105
|
+
if (!this.#wrappers.has(event)) return;
|
|
106
|
+
this.#target.dispatchEvent(new CustomEvent(event, { detail: args }));
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
Object.defineProperty(exports, "Emitter", {
|
|
110
|
+
enumerable: true,
|
|
111
|
+
get: function() {
|
|
112
|
+
return Emitter;
|
|
113
|
+
}
|
|
114
|
+
});
|
|
56
115
|
Object.defineProperty(exports, "LogLevel", {
|
|
57
116
|
enumerable: true,
|
|
58
117
|
get: function() {
|