@ceeblue/web-utils 3.0.0 → 3.2.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/commitlint.config.js +9 -0
- package/dist/web-utils.d.ts +146 -12
- package/dist/web-utils.js +535 -189
- package/dist/web-utils.js.map +1 -1
- package/dist/web-utils.min.js +1 -1
- package/dist/web-utils.min.js.map +1 -1
- package/package.json +1 -6
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2024 Ceeblue B.V.
|
|
3
|
+
* This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.
|
|
4
|
+
* See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.
|
|
5
|
+
*/
|
|
6
|
+
export default {
|
|
7
|
+
extends: ['@commitlint/config-conventional'],
|
|
8
|
+
ignores: [commit => /^[^\r\n]*\[skip ci\]/.test(commit)]
|
|
9
|
+
};
|
package/dist/web-utils.d.ts
CHANGED
|
@@ -53,7 +53,7 @@ declare class BinaryWriter {
|
|
|
53
53
|
* Write binary data
|
|
54
54
|
* @param data
|
|
55
55
|
*/
|
|
56
|
-
write(data: ArrayLike<number>): BinaryWriter;
|
|
56
|
+
write(data: ArrayLike<number> | BufferSource | string): BinaryWriter;
|
|
57
57
|
write8(value: number): BinaryWriter;
|
|
58
58
|
write16(value: number): BinaryWriter;
|
|
59
59
|
write24(value: number): BinaryWriter;
|
|
@@ -208,19 +208,69 @@ declare class BitReader extends Loggable {
|
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
/**
|
|
211
|
-
*
|
|
211
|
+
* Class to compute a weighted average byte rate over a specified time interval.
|
|
212
|
+
*
|
|
213
|
+
* This class continuously tracks data transmission and computes the byte rate
|
|
214
|
+
* based on a weighted average, considering both the duration and the number of
|
|
215
|
+
* bytes in each sample. It allows for real-time monitoring of bandwidth usage
|
|
216
|
+
* and provides mechanisms to dynamically adjust the measurement interval.
|
|
217
|
+
*
|
|
218
|
+
* Features:
|
|
219
|
+
* - Computes the byte rate using a **weighted average** approach.
|
|
220
|
+
* - Allows setting a custom interval for tracking.
|
|
221
|
+
* - Supports dynamic clipping to manually shrink the observation window.
|
|
212
222
|
*/
|
|
213
223
|
declare class ByteRate {
|
|
224
|
+
/**
|
|
225
|
+
* Raised when new bytes are added
|
|
226
|
+
*/
|
|
214
227
|
onBytes(bytes: number): void;
|
|
215
|
-
|
|
228
|
+
/**
|
|
229
|
+
* Returns the interval used for computing the byte rate
|
|
230
|
+
*/
|
|
231
|
+
get interval(): number;
|
|
232
|
+
/**
|
|
233
|
+
* Sets a new interval for computing the average byte rate
|
|
234
|
+
*/
|
|
235
|
+
set interval(value: number);
|
|
236
|
+
private _interval;
|
|
216
237
|
private _bytes;
|
|
217
238
|
private _time;
|
|
218
|
-
private
|
|
219
|
-
private
|
|
220
|
-
|
|
239
|
+
private _samples;
|
|
240
|
+
private _clip;
|
|
241
|
+
/**
|
|
242
|
+
* Constructor initializes the ByteRate object with a specified interval (default: 1000ms).
|
|
243
|
+
* It sets up necessary variables to track byte rate over time.
|
|
244
|
+
*
|
|
245
|
+
* @param interval - Time interval in milliseconds to compute the byte rate.
|
|
246
|
+
*/
|
|
247
|
+
constructor(interval?: number);
|
|
248
|
+
/**
|
|
249
|
+
* Returns the computed byte rate rounded to the nearest integer
|
|
250
|
+
*/
|
|
221
251
|
value(): number;
|
|
252
|
+
/**
|
|
253
|
+
* Computes the exact byte rate in bytes per second
|
|
254
|
+
*/
|
|
222
255
|
exact(): number;
|
|
223
|
-
|
|
256
|
+
/**
|
|
257
|
+
* Adds a new byte sample to the tracking system.
|
|
258
|
+
* Updates the list of samples and recomputes the byte rate
|
|
259
|
+
*
|
|
260
|
+
* @param bytes - Number of bytes added in this interval
|
|
261
|
+
*/
|
|
262
|
+
addBytes(bytes: number): ByteRate;
|
|
263
|
+
/**
|
|
264
|
+
* Clears all recorded byte rate data.
|
|
265
|
+
*/
|
|
266
|
+
clear(): ByteRate;
|
|
267
|
+
/**
|
|
268
|
+
* Clips the byte rate tracking by marking the last sample as clipped.
|
|
269
|
+
* If a previous clip exists, removes the clipped sample and all preceding samples.
|
|
270
|
+
* Allows to shrink the interval manually between two positions.
|
|
271
|
+
*/
|
|
272
|
+
clip(): ByteRate;
|
|
273
|
+
private updateSamples;
|
|
224
274
|
}
|
|
225
275
|
|
|
226
276
|
/**
|
|
@@ -350,16 +400,20 @@ declare class EventEmitter extends Loggable {
|
|
|
350
400
|
* Event subscription
|
|
351
401
|
* @param name Name of event without the `on` prefix (ex: `log` to `onLog` event declared)
|
|
352
402
|
* @param event Subscriber Function
|
|
353
|
-
* @param
|
|
403
|
+
* @param options.signal Optional `AbortSignal` to stop this or multiple subscriptions in same time
|
|
354
404
|
*/
|
|
355
|
-
on(name: string, event: Function,
|
|
405
|
+
on(name: string, event: Function, options?: {
|
|
406
|
+
signal?: AbortSignal;
|
|
407
|
+
}): void;
|
|
356
408
|
/**
|
|
357
409
|
* Event subscription only one time, once time fired it's automatically unsubscribe
|
|
358
410
|
* @param name Name of event without the `on` prefix (ex: `log` to `onLog` event declared)
|
|
359
411
|
* @param event Subscriber Function
|
|
360
|
-
* @param
|
|
412
|
+
* @param options.abortSignal Optional `AbortSignal` to stop this or multiple subscriptions in same time
|
|
361
413
|
*/
|
|
362
|
-
once(name: string, event: Function,
|
|
414
|
+
once(name: string, event: Function, options?: {
|
|
415
|
+
signal?: AbortSignal;
|
|
416
|
+
}): void;
|
|
363
417
|
/**
|
|
364
418
|
* Event unsubscription
|
|
365
419
|
* @param name Name of event without the 'on' prefix (ex: 'log' to 'onLog' event declared)
|
|
@@ -1033,6 +1087,86 @@ declare namespace EpochTime {
|
|
|
1033
1087
|
export { EpochTime_decodeTimestamp as decodeTimestamp, EpochTime_encodeTimestamp as encodeTimestamp, EpochTime_getLatency as getLatency };
|
|
1034
1088
|
}
|
|
1035
1089
|
|
|
1090
|
+
/**
|
|
1091
|
+
* Copyright 2024 Ceeblue B.V.
|
|
1092
|
+
* This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.
|
|
1093
|
+
* See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.
|
|
1094
|
+
*/
|
|
1095
|
+
/**
|
|
1096
|
+
* An user-interface compoment to vizualize real-time metrics
|
|
1097
|
+
*/
|
|
1098
|
+
declare class UIMetrics {
|
|
1099
|
+
/**
|
|
1100
|
+
* get graph margin in pixels
|
|
1101
|
+
*/
|
|
1102
|
+
get graphMargin(): number;
|
|
1103
|
+
/**
|
|
1104
|
+
* set graph margin in pixels
|
|
1105
|
+
*/
|
|
1106
|
+
set graphMargin(value: number);
|
|
1107
|
+
/**
|
|
1108
|
+
* get text margin in pixels
|
|
1109
|
+
*/
|
|
1110
|
+
get textMargin(): number;
|
|
1111
|
+
/**
|
|
1112
|
+
* set text margin in pixels
|
|
1113
|
+
*/
|
|
1114
|
+
set textMargin(value: number);
|
|
1115
|
+
/**
|
|
1116
|
+
* get metric line height in pixels
|
|
1117
|
+
*/
|
|
1118
|
+
get lineHeight(): number;
|
|
1119
|
+
/**
|
|
1120
|
+
* set metric line height in pixels
|
|
1121
|
+
*/
|
|
1122
|
+
set lineHeight(value: number);
|
|
1123
|
+
/**
|
|
1124
|
+
* get label width in pixels
|
|
1125
|
+
*/
|
|
1126
|
+
get labelWidth(): number;
|
|
1127
|
+
/**
|
|
1128
|
+
* set label width in pixels
|
|
1129
|
+
*/
|
|
1130
|
+
set labelWidth(value: number);
|
|
1131
|
+
/**
|
|
1132
|
+
* get legend font size in pixels
|
|
1133
|
+
*/
|
|
1134
|
+
get legendFontSize(): number;
|
|
1135
|
+
/**
|
|
1136
|
+
* set legend font size in pixels
|
|
1137
|
+
*/
|
|
1138
|
+
set legendFontSize(value: number);
|
|
1139
|
+
/**
|
|
1140
|
+
* get the metric unit-step in pixels
|
|
1141
|
+
*/
|
|
1142
|
+
get stepSize(): number;
|
|
1143
|
+
/**
|
|
1144
|
+
* set the metric unit-step in pixels
|
|
1145
|
+
*/
|
|
1146
|
+
set stepSize(value: number);
|
|
1147
|
+
private _ui;
|
|
1148
|
+
private _html?;
|
|
1149
|
+
private _lineHeight;
|
|
1150
|
+
private _labelWidth;
|
|
1151
|
+
private _graphMargin;
|
|
1152
|
+
private _textMargin;
|
|
1153
|
+
private _legendFontSize;
|
|
1154
|
+
private _stepSize;
|
|
1155
|
+
private _ranges;
|
|
1156
|
+
constructor(ui: HTMLElement);
|
|
1157
|
+
/**
|
|
1158
|
+
* Reset metrics stats, essentially rescaling the metrics
|
|
1159
|
+
*/
|
|
1160
|
+
reset(): void;
|
|
1161
|
+
/**
|
|
1162
|
+
* build metric from stats
|
|
1163
|
+
* @param stats Map with stats per entry
|
|
1164
|
+
* @returns
|
|
1165
|
+
*/
|
|
1166
|
+
display(stats: Map<string, Array<string | number>>): void;
|
|
1167
|
+
private _drawCircle;
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1036
1170
|
/**
|
|
1037
1171
|
* Copyright 2024 Ceeblue B.V.
|
|
1038
1172
|
* This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.
|
|
@@ -1041,4 +1175,4 @@ declare namespace EpochTime {
|
|
|
1041
1175
|
|
|
1042
1176
|
declare const VERSION: string;
|
|
1043
1177
|
|
|
1044
|
-
export { BinaryReader, BinaryWriter, BitReader, ByteRate, Connect, EpochTime, EventEmitter, FixMap, type ILog, Log, LogLevel, Loggable, NetAddress, Numbers, Queue, SDP, Util, VERSION, WebSocketReliable, type WebSocketReliableError, log };
|
|
1178
|
+
export { BinaryReader, BinaryWriter, BitReader, ByteRate, Connect, EpochTime, EventEmitter, FixMap, type ILog, Log, LogLevel, Loggable, NetAddress, Numbers, Queue, SDP, UIMetrics, Util, VERSION, WebSocketReliable, type WebSocketReliableError, log };
|