@signalwire/js 4.0.0-dev-20260416142417 → 4.0.0-dev-20260416174405
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/browser.mjs +63 -25
- package/dist/browser.mjs.map +1 -1
- package/dist/browser.umd.js +65 -24
- package/dist/browser.umd.js.map +1 -1
- package/dist/index.cjs +18 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +80 -12
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +80 -12
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +16 -15
- package/dist/index.mjs.map +1 -1
- package/dist/operators/index.cjs +1 -1
- package/dist/operators/index.mjs +1 -1
- package/dist/{operators-BwHr2-zw.mjs → operators-B1xH6k06.mjs} +50 -13
- package/dist/operators-B1xH6k06.mjs.map +1 -0
- package/dist/{operators-C3TtzZHH.cjs → operators-BT3jl--r.cjs} +67 -12
- package/dist/operators-BT3jl--r.cjs.map +1 -0
- package/package.json +1 -1
- package/dist/operators-BwHr2-zw.mjs.map +0 -1
- package/dist/operators-C3TtzZHH.cjs.map +0 -1
package/dist/browser.umd.js
CHANGED
|
@@ -9496,33 +9496,70 @@ const originalFactory = defaultLogger.methodFactory;
|
|
|
9496
9496
|
defaultLogger.methodFactory = (methodName, logLevel, loggerName) => {
|
|
9497
9497
|
const rawMethod = originalFactory(methodName, logLevel, loggerName);
|
|
9498
9498
|
return function(...args) {
|
|
9499
|
-
|
|
9500
|
-
|
|
9499
|
+
const prefixed = [
|
|
9500
|
+
datetime(),
|
|
9501
|
+
"-",
|
|
9502
|
+
...args
|
|
9503
|
+
];
|
|
9504
|
+
rawMethod.apply(void 0, prefixed);
|
|
9501
9505
|
};
|
|
9502
9506
|
};
|
|
9503
|
-
const defaultLoggerLevel = defaultLogger.levels.
|
|
9507
|
+
const defaultLoggerLevel = defaultLogger.levels.WARN;
|
|
9504
9508
|
defaultLogger.setLevel(defaultLoggerLevel);
|
|
9505
|
-
let userLogger;
|
|
9509
|
+
let userLogger = null;
|
|
9510
|
+
/** Replace the built-in logger with a custom implementation. Pass `null` to restore defaults. */
|
|
9511
|
+
const setLogger = (logger$30) => {
|
|
9512
|
+
userLogger = logger$30;
|
|
9513
|
+
};
|
|
9506
9514
|
let debugOptions = {};
|
|
9515
|
+
/** Configure debug options (e.g., `{ logWsTraffic: true }`). */
|
|
9516
|
+
const setDebugOptions = (options) => {
|
|
9517
|
+
if (options == null) {
|
|
9518
|
+
debugOptions = {};
|
|
9519
|
+
return;
|
|
9520
|
+
}
|
|
9521
|
+
debugOptions = {
|
|
9522
|
+
...debugOptions,
|
|
9523
|
+
...options
|
|
9524
|
+
};
|
|
9525
|
+
};
|
|
9526
|
+
/**
|
|
9527
|
+
* Set the log level for the built-in logger.
|
|
9528
|
+
* Has no effect when a custom logger is set via `setLogger()`.
|
|
9529
|
+
*/
|
|
9530
|
+
const setLogLevel = (level) => {
|
|
9531
|
+
defaultLogger.setLevel(level);
|
|
9532
|
+
};
|
|
9507
9533
|
const getLoggerInstance = () => {
|
|
9508
9534
|
return userLogger ?? defaultLogger;
|
|
9509
9535
|
};
|
|
9510
9536
|
const shouldStringify = (payload) => {
|
|
9511
|
-
if ("method" in payload
|
|
9537
|
+
if (payload != null && typeof payload === "object" && "method" in payload) return payload.method !== "signalwire.ping";
|
|
9512
9538
|
return true;
|
|
9513
9539
|
};
|
|
9514
|
-
const wsTraffic = (
|
|
9515
|
-
const
|
|
9516
|
-
const { logWsTraffic } = debugOptions ?? {};
|
|
9540
|
+
const wsTraffic = (options) => {
|
|
9541
|
+
const { logWsTraffic } = debugOptions;
|
|
9517
9542
|
if (!logWsTraffic) return;
|
|
9543
|
+
const loggerInstance = getLoggerInstance();
|
|
9544
|
+
let payload;
|
|
9545
|
+
if ("raw" in options) try {
|
|
9546
|
+
payload = JSON.parse(options.raw);
|
|
9547
|
+
} catch {
|
|
9548
|
+
loggerInstance.debug(`[WebSocket] ${options.type.toUpperCase()}: non-JSON message`);
|
|
9549
|
+
return;
|
|
9550
|
+
}
|
|
9551
|
+
else payload = options.payload;
|
|
9518
9552
|
const msg = shouldStringify(payload) ? JSON.stringify(payload, null, 2) : payload;
|
|
9519
|
-
|
|
9553
|
+
loggerInstance.debug(`${options.type.toUpperCase()}: \n`, msg, "\n");
|
|
9520
9554
|
};
|
|
9521
9555
|
const getLogger = () => {
|
|
9522
9556
|
const logger$30 = getLoggerInstance();
|
|
9523
|
-
return new Proxy(logger$30, { get(
|
|
9557
|
+
return new Proxy(logger$30, { get(_target, prop, _receiver) {
|
|
9524
9558
|
if (prop === "wsTraffic") return wsTraffic;
|
|
9525
|
-
|
|
9559
|
+
const instance = getLoggerInstance();
|
|
9560
|
+
const value = Reflect.get(instance, prop);
|
|
9561
|
+
if (typeof value === "function") return value.bind(instance);
|
|
9562
|
+
return value;
|
|
9526
9563
|
} });
|
|
9527
9564
|
};
|
|
9528
9565
|
|
|
@@ -20116,11 +20153,10 @@ var WebSocketController = class WebSocketController extends Destroyable {
|
|
|
20116
20153
|
}
|
|
20117
20154
|
send(data) {
|
|
20118
20155
|
if (this._status$.value === "connected" && this.socket?.readyState === 1) {
|
|
20119
|
-
|
|
20120
|
-
|
|
20121
|
-
|
|
20122
|
-
|
|
20123
|
-
}
|
|
20156
|
+
logger$3.wsTraffic({
|
|
20157
|
+
type: "send",
|
|
20158
|
+
raw: data
|
|
20159
|
+
});
|
|
20124
20160
|
this.socket.send(data);
|
|
20125
20161
|
} else this.messageQueue.push(data);
|
|
20126
20162
|
}
|
|
@@ -20183,11 +20219,10 @@ var WebSocketController = class WebSocketController extends Destroyable {
|
|
|
20183
20219
|
this.handleConnectionError();
|
|
20184
20220
|
}
|
|
20185
20221
|
handleMessage(event) {
|
|
20186
|
-
|
|
20187
|
-
|
|
20188
|
-
|
|
20189
|
-
|
|
20190
|
-
}
|
|
20222
|
+
logger$3.wsTraffic({
|
|
20223
|
+
type: "recv",
|
|
20224
|
+
raw: event.data
|
|
20225
|
+
});
|
|
20191
20226
|
this._incomingMessages$.next(event);
|
|
20192
20227
|
}
|
|
20193
20228
|
handleConnectionError() {
|
|
@@ -20490,6 +20525,9 @@ var SignalWire = class extends Destroyable {
|
|
|
20490
20525
|
if (this._options.webSocketConstructor) this._deps.WebSocket = this._options.webSocketConstructor;
|
|
20491
20526
|
if (this._options.savePreferences) this.preferences.enableSavePreferences(this._deps.storage);
|
|
20492
20527
|
if (this._options.webRTCApiProvider) this._deps.webRTCApiProvider = this._options.webRTCApiProvider;
|
|
20528
|
+
if (this._options.logger !== void 0) setLogger(this._options.logger);
|
|
20529
|
+
if (this._options.logLevel) setLogLevel(this._options.logLevel);
|
|
20530
|
+
if (this._options.debug) setDebugOptions(this._options.debug);
|
|
20493
20531
|
this._deviceController = this._deps.deviceController;
|
|
20494
20532
|
if (!this._options.skipDeviceMonitoring) this._deviceController.enableDeviceMonitoring();
|
|
20495
20533
|
this.subscribeTo(this._deviceController.errors$, (error) => {
|
|
@@ -20566,7 +20604,7 @@ var SignalWire = class extends Destroyable {
|
|
|
20566
20604
|
if (_credentials.expiry_at && credentialProvider?.refresh) this.scheduleCredentialRefresh(credentialProvider, _credentials.expiry_at);
|
|
20567
20605
|
this._deps.credential = _credentials;
|
|
20568
20606
|
this.persistCredential(_credentials);
|
|
20569
|
-
if (this.isConnected && this._clientSession
|
|
20607
|
+
if (this.isConnected && this._clientSession.authenticated && _credentials.token) try {
|
|
20570
20608
|
await this._clientSession.reauthenticate(_credentials.token);
|
|
20571
20609
|
logger$1.info("[SignalWire] Session refreshed with new credentials.");
|
|
20572
20610
|
} catch (error) {
|
|
@@ -20644,9 +20682,9 @@ var SignalWire = class extends Destroyable {
|
|
|
20644
20682
|
* unexpectedly (e.g. network change, server restart). Reconnection uses an
|
|
20645
20683
|
* **exponential back-off** strategy:
|
|
20646
20684
|
*
|
|
20647
|
-
* - First retry after `reconnectDelayMin` (default **1 s**).
|
|
20685
|
+
* - First retry after `reconnectDelayMin` (default **0.1 s**).
|
|
20648
20686
|
* - Each subsequent retry doubles the delay up to `reconnectDelayMax`
|
|
20649
|
-
* (default **
|
|
20687
|
+
* (default **3 s**).
|
|
20650
20688
|
* - The delay resets to `reconnectDelayMin` once a connection succeeds.
|
|
20651
20689
|
* - A per-attempt `connectionTimeout` (default **10 s**) aborts the
|
|
20652
20690
|
* attempt and schedules the next retry if the server does not respond.
|
|
@@ -21426,6 +21464,9 @@ exports.WebRTCCall = WebRTCCall;
|
|
|
21426
21464
|
exports.embeddableCall = embeddableCall;
|
|
21427
21465
|
exports.isSelfParticipant = isSelfParticipant;
|
|
21428
21466
|
exports.ready = ready;
|
|
21467
|
+
exports.setDebugOptions = setDebugOptions;
|
|
21468
|
+
exports.setLogLevel = setLogLevel;
|
|
21469
|
+
exports.setLogger = setLogger;
|
|
21429
21470
|
exports.version = version;
|
|
21430
21471
|
});
|
|
21431
21472
|
//# sourceMappingURL=browser.umd.js.map
|