@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.mjs
CHANGED
|
@@ -9492,33 +9492,70 @@ const originalFactory = defaultLogger.methodFactory;
|
|
|
9492
9492
|
defaultLogger.methodFactory = (methodName, logLevel, loggerName) => {
|
|
9493
9493
|
const rawMethod = originalFactory(methodName, logLevel, loggerName);
|
|
9494
9494
|
return function(...args) {
|
|
9495
|
-
|
|
9496
|
-
|
|
9495
|
+
const prefixed = [
|
|
9496
|
+
datetime(),
|
|
9497
|
+
"-",
|
|
9498
|
+
...args
|
|
9499
|
+
];
|
|
9500
|
+
rawMethod.apply(void 0, prefixed);
|
|
9497
9501
|
};
|
|
9498
9502
|
};
|
|
9499
|
-
const defaultLoggerLevel = defaultLogger.levels.
|
|
9503
|
+
const defaultLoggerLevel = defaultLogger.levels.WARN;
|
|
9500
9504
|
defaultLogger.setLevel(defaultLoggerLevel);
|
|
9501
|
-
let userLogger;
|
|
9505
|
+
let userLogger = null;
|
|
9506
|
+
/** Replace the built-in logger with a custom implementation. Pass `null` to restore defaults. */
|
|
9507
|
+
const setLogger = (logger$30) => {
|
|
9508
|
+
userLogger = logger$30;
|
|
9509
|
+
};
|
|
9502
9510
|
let debugOptions = {};
|
|
9511
|
+
/** Configure debug options (e.g., `{ logWsTraffic: true }`). */
|
|
9512
|
+
const setDebugOptions = (options) => {
|
|
9513
|
+
if (options == null) {
|
|
9514
|
+
debugOptions = {};
|
|
9515
|
+
return;
|
|
9516
|
+
}
|
|
9517
|
+
debugOptions = {
|
|
9518
|
+
...debugOptions,
|
|
9519
|
+
...options
|
|
9520
|
+
};
|
|
9521
|
+
};
|
|
9522
|
+
/**
|
|
9523
|
+
* Set the log level for the built-in logger.
|
|
9524
|
+
* Has no effect when a custom logger is set via `setLogger()`.
|
|
9525
|
+
*/
|
|
9526
|
+
const setLogLevel = (level) => {
|
|
9527
|
+
defaultLogger.setLevel(level);
|
|
9528
|
+
};
|
|
9503
9529
|
const getLoggerInstance = () => {
|
|
9504
9530
|
return userLogger ?? defaultLogger;
|
|
9505
9531
|
};
|
|
9506
9532
|
const shouldStringify = (payload) => {
|
|
9507
|
-
if ("method" in payload
|
|
9533
|
+
if (payload != null && typeof payload === "object" && "method" in payload) return payload.method !== "signalwire.ping";
|
|
9508
9534
|
return true;
|
|
9509
9535
|
};
|
|
9510
|
-
const wsTraffic = (
|
|
9511
|
-
const
|
|
9512
|
-
const { logWsTraffic } = debugOptions ?? {};
|
|
9536
|
+
const wsTraffic = (options) => {
|
|
9537
|
+
const { logWsTraffic } = debugOptions;
|
|
9513
9538
|
if (!logWsTraffic) return;
|
|
9539
|
+
const loggerInstance = getLoggerInstance();
|
|
9540
|
+
let payload;
|
|
9541
|
+
if ("raw" in options) try {
|
|
9542
|
+
payload = JSON.parse(options.raw);
|
|
9543
|
+
} catch {
|
|
9544
|
+
loggerInstance.debug(`[WebSocket] ${options.type.toUpperCase()}: non-JSON message`);
|
|
9545
|
+
return;
|
|
9546
|
+
}
|
|
9547
|
+
else payload = options.payload;
|
|
9514
9548
|
const msg = shouldStringify(payload) ? JSON.stringify(payload, null, 2) : payload;
|
|
9515
|
-
|
|
9549
|
+
loggerInstance.debug(`${options.type.toUpperCase()}: \n`, msg, "\n");
|
|
9516
9550
|
};
|
|
9517
9551
|
const getLogger = () => {
|
|
9518
9552
|
const logger$30 = getLoggerInstance();
|
|
9519
|
-
return new Proxy(logger$30, { get(
|
|
9553
|
+
return new Proxy(logger$30, { get(_target, prop, _receiver) {
|
|
9520
9554
|
if (prop === "wsTraffic") return wsTraffic;
|
|
9521
|
-
|
|
9555
|
+
const instance = getLoggerInstance();
|
|
9556
|
+
const value = Reflect.get(instance, prop);
|
|
9557
|
+
if (typeof value === "function") return value.bind(instance);
|
|
9558
|
+
return value;
|
|
9522
9559
|
} });
|
|
9523
9560
|
};
|
|
9524
9561
|
|
|
@@ -20112,11 +20149,10 @@ var WebSocketController = class WebSocketController extends Destroyable {
|
|
|
20112
20149
|
}
|
|
20113
20150
|
send(data) {
|
|
20114
20151
|
if (this._status$.value === "connected" && this.socket?.readyState === 1) {
|
|
20115
|
-
|
|
20116
|
-
|
|
20117
|
-
|
|
20118
|
-
|
|
20119
|
-
}
|
|
20152
|
+
logger$3.wsTraffic({
|
|
20153
|
+
type: "send",
|
|
20154
|
+
raw: data
|
|
20155
|
+
});
|
|
20120
20156
|
this.socket.send(data);
|
|
20121
20157
|
} else this.messageQueue.push(data);
|
|
20122
20158
|
}
|
|
@@ -20179,11 +20215,10 @@ var WebSocketController = class WebSocketController extends Destroyable {
|
|
|
20179
20215
|
this.handleConnectionError();
|
|
20180
20216
|
}
|
|
20181
20217
|
handleMessage(event) {
|
|
20182
|
-
|
|
20183
|
-
|
|
20184
|
-
|
|
20185
|
-
|
|
20186
|
-
}
|
|
20218
|
+
logger$3.wsTraffic({
|
|
20219
|
+
type: "recv",
|
|
20220
|
+
raw: event.data
|
|
20221
|
+
});
|
|
20187
20222
|
this._incomingMessages$.next(event);
|
|
20188
20223
|
}
|
|
20189
20224
|
handleConnectionError() {
|
|
@@ -20486,6 +20521,9 @@ var SignalWire = class extends Destroyable {
|
|
|
20486
20521
|
if (this._options.webSocketConstructor) this._deps.WebSocket = this._options.webSocketConstructor;
|
|
20487
20522
|
if (this._options.savePreferences) this.preferences.enableSavePreferences(this._deps.storage);
|
|
20488
20523
|
if (this._options.webRTCApiProvider) this._deps.webRTCApiProvider = this._options.webRTCApiProvider;
|
|
20524
|
+
if (this._options.logger !== void 0) setLogger(this._options.logger);
|
|
20525
|
+
if (this._options.logLevel) setLogLevel(this._options.logLevel);
|
|
20526
|
+
if (this._options.debug) setDebugOptions(this._options.debug);
|
|
20489
20527
|
this._deviceController = this._deps.deviceController;
|
|
20490
20528
|
if (!this._options.skipDeviceMonitoring) this._deviceController.enableDeviceMonitoring();
|
|
20491
20529
|
this.subscribeTo(this._deviceController.errors$, (error) => {
|
|
@@ -20562,7 +20600,7 @@ var SignalWire = class extends Destroyable {
|
|
|
20562
20600
|
if (_credentials.expiry_at && credentialProvider?.refresh) this.scheduleCredentialRefresh(credentialProvider, _credentials.expiry_at);
|
|
20563
20601
|
this._deps.credential = _credentials;
|
|
20564
20602
|
this.persistCredential(_credentials);
|
|
20565
|
-
if (this.isConnected && this._clientSession
|
|
20603
|
+
if (this.isConnected && this._clientSession.authenticated && _credentials.token) try {
|
|
20566
20604
|
await this._clientSession.reauthenticate(_credentials.token);
|
|
20567
20605
|
logger$1.info("[SignalWire] Session refreshed with new credentials.");
|
|
20568
20606
|
} catch (error) {
|
|
@@ -20640,9 +20678,9 @@ var SignalWire = class extends Destroyable {
|
|
|
20640
20678
|
* unexpectedly (e.g. network change, server restart). Reconnection uses an
|
|
20641
20679
|
* **exponential back-off** strategy:
|
|
20642
20680
|
*
|
|
20643
|
-
* - First retry after `reconnectDelayMin` (default **1 s**).
|
|
20681
|
+
* - First retry after `reconnectDelayMin` (default **0.1 s**).
|
|
20644
20682
|
* - Each subsequent retry doubles the delay up to `reconnectDelayMax`
|
|
20645
|
-
* (default **
|
|
20683
|
+
* (default **3 s**).
|
|
20646
20684
|
* - The delay resets to `reconnectDelayMin` once a connection succeeds.
|
|
20647
20685
|
* - A per-attempt `connectionTimeout` (default **10 s**) aborts the
|
|
20648
20686
|
* attempt and schedules the next retry if the server does not respond.
|
|
@@ -21397,5 +21435,5 @@ emitReadyEvent();
|
|
|
21397
21435
|
if (typeof process === "undefined") globalThis.process = { env: { NODE_ENV: "production" } };
|
|
21398
21436
|
|
|
21399
21437
|
//#endregion
|
|
21400
|
-
export { Address, CallCreateError, ClientPreferences, CollectionFetchError, DPoPInitError, DeviceTokenError, InvalidCredentialsError, MediaTrackError, MessageParseError, OverconstrainedFallbackError, Participant, PreflightError, RecoveryError, SelfCapabilities, SelfParticipant, SignalWire, StaticCredentialProvider, Subscriber, TokenRefreshError, UnexpectedError, VertoPongError, WebRTCCall, embeddableCall, isSelfParticipant, ready, version };
|
|
21438
|
+
export { Address, CallCreateError, ClientPreferences, CollectionFetchError, DPoPInitError, DeviceTokenError, InvalidCredentialsError, MediaTrackError, MessageParseError, OverconstrainedFallbackError, Participant, PreflightError, RecoveryError, SelfCapabilities, SelfParticipant, SignalWire, StaticCredentialProvider, Subscriber, TokenRefreshError, UnexpectedError, VertoPongError, WebRTCCall, embeddableCall, isSelfParticipant, ready, setDebugOptions, setLogLevel, setLogger, version };
|
|
21401
21439
|
//# sourceMappingURL=browser.mjs.map
|