@auxilium/datalynk-client 1.5.2 → 1.6.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/dist/api.d.ts +25 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/chat-entry.d.ts +3 -0
- package/dist/chat-entry.d.ts.map +1 -0
- package/dist/chat-gui.d.ts +64 -0
- package/dist/chat-gui.d.ts.map +1 -0
- package/dist/chat-gui.view.d.ts +3 -0
- package/dist/chat-gui.view.d.ts.map +1 -0
- package/dist/chat.cjs +2202 -0
- package/dist/chat.d.ts +75 -0
- package/dist/chat.d.ts.map +1 -0
- package/dist/chat.mjs +2198 -0
- package/dist/index.cjs +235 -7
- package/dist/index.mjs +235 -7
- package/dist/socket.d.ts +14 -1
- package/dist/socket.d.ts.map +1 -1
- package/package.json +7 -2
package/dist/index.mjs
CHANGED
|
@@ -3102,6 +3102,7 @@ class Socket {
|
|
|
3102
3102
|
// [ Callback, Re-subscribe ]
|
|
3103
3103
|
__publicField(this, "retry");
|
|
3104
3104
|
__publicField(this, "socket");
|
|
3105
|
+
__publicField(this, "connectGeneration", 0);
|
|
3105
3106
|
__publicField(this, "open", false);
|
|
3106
3107
|
this.api = api;
|
|
3107
3108
|
this.options = options;
|
|
@@ -3110,7 +3111,7 @@ class Socket {
|
|
|
3110
3111
|
this.options.url = origin.replace("http", "ws").replace(/:\d+/g, "") + `/s/`;
|
|
3111
3112
|
}
|
|
3112
3113
|
if (this.options.url !== false)
|
|
3113
|
-
api.token$.pipe(filter((u) => u !== void 0), distinctUntilChanged()).subscribe(() => this.connect());
|
|
3114
|
+
api.token$.pipe(filter((u) => u !== void 0), distinctUntilChanged()).subscribe(() => void this.connect());
|
|
3114
3115
|
}
|
|
3115
3116
|
/**
|
|
3116
3117
|
* Add listener for all socket events
|
|
@@ -3132,6 +3133,7 @@ class Socket {
|
|
|
3132
3133
|
*/
|
|
3133
3134
|
close() {
|
|
3134
3135
|
var _a;
|
|
3136
|
+
if (this.options.authentication === "ticket") this.connectGeneration++;
|
|
3135
3137
|
if (this.open) console.debug("Datalynk socket: disconnected");
|
|
3136
3138
|
this.open = false;
|
|
3137
3139
|
(_a = this.socket) == null ? void 0 : _a.close();
|
|
@@ -3144,6 +3146,7 @@ class Socket {
|
|
|
3144
3146
|
* @param {number} timeout Retry to connect every x seconds
|
|
3145
3147
|
*/
|
|
3146
3148
|
connect(timeout = 30) {
|
|
3149
|
+
if (this.options.authentication === "ticket") return this.connectWithTicket(timeout);
|
|
3147
3150
|
if (this.options.url === false) return console.warn("Datalynk socket disabled");
|
|
3148
3151
|
if (this.open) this.close();
|
|
3149
3152
|
this.retry = setTimeout(() => {
|
|
@@ -3173,6 +3176,80 @@ class Socket {
|
|
|
3173
3176
|
};
|
|
3174
3177
|
}
|
|
3175
3178
|
}
|
|
3179
|
+
/**
|
|
3180
|
+
* Ticket-authenticated connection path, used only once a chat-capable host switches
|
|
3181
|
+
* this instance to `authentication: 'ticket'` (see Api.openChat). Entirely separate
|
|
3182
|
+
* from the token path above so existing non-chat consumers are never affected.
|
|
3183
|
+
*/
|
|
3184
|
+
async connectWithTicket(timeout = 30) {
|
|
3185
|
+
var _a;
|
|
3186
|
+
if (this.options.url === false) return console.warn("Datalynk socket disabled");
|
|
3187
|
+
const generation = ++this.connectGeneration;
|
|
3188
|
+
if (this.open || this.socket) {
|
|
3189
|
+
this.open = false;
|
|
3190
|
+
(_a = this.socket) == null ? void 0 : _a.close();
|
|
3191
|
+
this.socket = void 0;
|
|
3192
|
+
}
|
|
3193
|
+
if (this.retry) clearTimeout(this.retry);
|
|
3194
|
+
this.retry = setTimeout(() => {
|
|
3195
|
+
if (this.open || generation !== this.connectGeneration) return;
|
|
3196
|
+
void this.connect(timeout);
|
|
3197
|
+
}, timeout * 1e3);
|
|
3198
|
+
if (!this.api.online || !this.api.token) return;
|
|
3199
|
+
let socketUrl = this.normalizeUrl(String(this.options.url || ""));
|
|
3200
|
+
try {
|
|
3201
|
+
const response = await this.api.request({ "$/chat/socketTicket": {} }, { noOptimize: true });
|
|
3202
|
+
if (generation !== this.connectGeneration) return;
|
|
3203
|
+
if (response == null ? void 0 : response.ticket) socketUrl += `${socketUrl.includes("?") ? "&" : "?"}ticket=${encodeURIComponent(response.ticket)}`;
|
|
3204
|
+
else throw new Error("Missing socket ticket");
|
|
3205
|
+
} catch (_) {
|
|
3206
|
+
if (generation !== this.connectGeneration) return;
|
|
3207
|
+
this.scheduleReconnect(generation, timeout);
|
|
3208
|
+
return;
|
|
3209
|
+
}
|
|
3210
|
+
if (generation !== this.connectGeneration) return;
|
|
3211
|
+
this.socket = new WebSocket(socketUrl);
|
|
3212
|
+
this.socket.onopen = () => void 0;
|
|
3213
|
+
this.socket.onclose = () => {
|
|
3214
|
+
this.open = false;
|
|
3215
|
+
this.socket = void 0;
|
|
3216
|
+
this.scheduleReconnect(generation, timeout);
|
|
3217
|
+
};
|
|
3218
|
+
this.socket.onerror = () => {
|
|
3219
|
+
};
|
|
3220
|
+
this.socket.onmessage = (message) => {
|
|
3221
|
+
var _a2;
|
|
3222
|
+
let payload;
|
|
3223
|
+
try {
|
|
3224
|
+
payload = JSON.parse(message.data);
|
|
3225
|
+
} catch {
|
|
3226
|
+
return;
|
|
3227
|
+
}
|
|
3228
|
+
if (payload.connected != void 0) {
|
|
3229
|
+
if (payload.connected) {
|
|
3230
|
+
this.open = true;
|
|
3231
|
+
if (this.retry) clearTimeout(this.retry);
|
|
3232
|
+
this.retry = null;
|
|
3233
|
+
console.debug("Datalynk socket: connected");
|
|
3234
|
+
this.listeners.forEach((l) => l[1]());
|
|
3235
|
+
} else {
|
|
3236
|
+
this.open = false;
|
|
3237
|
+
console.warn(`Datalynk socket failed: ${payload.error || "authentication failed"}`);
|
|
3238
|
+
(_a2 = this.socket) == null ? void 0 : _a2.close();
|
|
3239
|
+
}
|
|
3240
|
+
} else {
|
|
3241
|
+
this.listeners.forEach((l) => l[0](payload));
|
|
3242
|
+
}
|
|
3243
|
+
};
|
|
3244
|
+
}
|
|
3245
|
+
scheduleReconnect(generation, timeout) {
|
|
3246
|
+
if (generation !== this.connectGeneration || this.options.url === false) return;
|
|
3247
|
+
if (this.retry) clearTimeout(this.retry);
|
|
3248
|
+
this.retry = setTimeout(() => {
|
|
3249
|
+
if (generation !== this.connectGeneration) return;
|
|
3250
|
+
void this.connect(timeout);
|
|
3251
|
+
}, timeout * 1e3);
|
|
3252
|
+
}
|
|
3176
3253
|
/**
|
|
3177
3254
|
* Send data to socket server
|
|
3178
3255
|
*
|
|
@@ -3199,6 +3276,17 @@ class Socket {
|
|
|
3199
3276
|
unsubscribe();
|
|
3200
3277
|
};
|
|
3201
3278
|
}
|
|
3279
|
+
normalizeUrl(value) {
|
|
3280
|
+
let url = value.replace(/^http:\/\//i, "ws://").replace(/^https:\/\//i, "wss://");
|
|
3281
|
+
try {
|
|
3282
|
+
const parsed = new URL(url);
|
|
3283
|
+
if (parsed.pathname === "/" || parsed.pathname === "") parsed.pathname = "/s/";
|
|
3284
|
+
else if (parsed.pathname === "/s") parsed.pathname = "/s/";
|
|
3285
|
+
url = parsed.toString();
|
|
3286
|
+
} catch {
|
|
3287
|
+
}
|
|
3288
|
+
return url;
|
|
3289
|
+
}
|
|
3202
3290
|
}
|
|
3203
3291
|
class Superuser {
|
|
3204
3292
|
constructor(api) {
|
|
@@ -3230,7 +3318,7 @@ class Superuser {
|
|
|
3230
3318
|
} });
|
|
3231
3319
|
}
|
|
3232
3320
|
}
|
|
3233
|
-
const version = "1.
|
|
3321
|
+
const version = "1.6.0";
|
|
3234
3322
|
class WebRtc {
|
|
3235
3323
|
constructor(api) {
|
|
3236
3324
|
__publicField(this, "ice");
|
|
@@ -3797,6 +3885,10 @@ const _Api = class _Api {
|
|
|
3797
3885
|
__publicField(this, "tokenStorageListener", null);
|
|
3798
3886
|
/** Pending requests cache */
|
|
3799
3887
|
__publicField(this, "pending", {});
|
|
3888
|
+
__publicField(this, "chatModulePromise", null);
|
|
3889
|
+
__publicField(this, "chatInstance", null);
|
|
3890
|
+
__publicField(this, "chatLauncherHost", null);
|
|
3891
|
+
__publicField(this, "chatLauncherButton", null);
|
|
3800
3892
|
/** Helpers */
|
|
3801
3893
|
/** Authentication */
|
|
3802
3894
|
__publicField(this, "auth");
|
|
@@ -3851,6 +3943,8 @@ const _Api = class _Api {
|
|
|
3851
3943
|
offline: [],
|
|
3852
3944
|
origin: typeof location !== "undefined" ? location.host : "Unknown",
|
|
3853
3945
|
saveSession: true,
|
|
3946
|
+
manageSession: true,
|
|
3947
|
+
chat: false,
|
|
3854
3948
|
replayOfflineQueue: true,
|
|
3855
3949
|
watchTokenExpiry: true,
|
|
3856
3950
|
serviceWorker: "/service.worker.mjs",
|
|
@@ -3882,9 +3976,9 @@ const _Api = class _Api {
|
|
|
3882
3976
|
window.addEventListener("storage", this.tokenStorageListener);
|
|
3883
3977
|
}
|
|
3884
3978
|
}
|
|
3885
|
-
if (this.options.watchTokenExpiry)
|
|
3979
|
+
if (this.options.manageSession !== false && this.options.watchTokenExpiry)
|
|
3886
3980
|
this.token$.pipe(distinctUntilChanged()).subscribe((token) => this.scheduleTokenExpiry(token));
|
|
3887
|
-
this.socket = new Socket(this, { url: options.socket });
|
|
3981
|
+
this.socket = new Socket(this, { url: options.socket, authentication: options.socketAuthentication, realm: options.socketRealm });
|
|
3888
3982
|
this.gps = new Gps(this, options.gps);
|
|
3889
3983
|
this.auth = new Auth(this);
|
|
3890
3984
|
this.files = new Files(this);
|
|
@@ -3925,6 +4019,7 @@ const _Api = class _Api {
|
|
|
3925
4019
|
})();
|
|
3926
4020
|
}
|
|
3927
4021
|
}
|
|
4022
|
+
this.setupChatLauncher();
|
|
3928
4023
|
}
|
|
3929
4024
|
/** Is token expired */
|
|
3930
4025
|
get expired() {
|
|
@@ -3996,7 +4091,7 @@ const _Api = class _Api {
|
|
|
3996
4091
|
var _a;
|
|
3997
4092
|
if (this.recovery && token !== this.recovery.token)
|
|
3998
4093
|
this.cancelRecovery(errorFromCode(401, "Session changed during API recovery"));
|
|
3999
|
-
if (token && this.isTokenExpired(token)) {
|
|
4094
|
+
if (this.options.manageSession !== false && token && this.isTokenExpired(token)) {
|
|
4000
4095
|
if (this.adoptStoredToken(token)) return;
|
|
4001
4096
|
if (this.shouldDeferLocalExpiry()) {
|
|
4002
4097
|
this.deferOfflineExpiry(token);
|
|
@@ -4014,6 +4109,138 @@ const _Api = class _Api {
|
|
|
4014
4109
|
}
|
|
4015
4110
|
if (token && ((_a = this.options) == null ? void 0 : _a.replayOfflineQueue) !== false) void this.replayPendingQueue();
|
|
4016
4111
|
}
|
|
4112
|
+
/** Mount the optional launcher without loading or initializing the chat bundle. */
|
|
4113
|
+
setupChatLauncher() {
|
|
4114
|
+
if (!this.options.chat || typeof document === "undefined") return;
|
|
4115
|
+
const mount = () => {
|
|
4116
|
+
if (this.chatLauncherHost || !document.body || document.querySelector("[data-datalynk-chat-launcher]")) return;
|
|
4117
|
+
const host = document.createElement("div");
|
|
4118
|
+
host.setAttribute("data-datalynk-chat-launcher", "");
|
|
4119
|
+
const root = host.attachShadow({ mode: "open" });
|
|
4120
|
+
root.innerHTML = `
|
|
4121
|
+
<style>
|
|
4122
|
+
:host {
|
|
4123
|
+
all: initial;
|
|
4124
|
+
position: fixed;
|
|
4125
|
+
right: 20px;
|
|
4126
|
+
bottom: 20px;
|
|
4127
|
+
z-index: 2147482999;
|
|
4128
|
+
pointer-events: none;
|
|
4129
|
+
}
|
|
4130
|
+
button {
|
|
4131
|
+
display: grid;
|
|
4132
|
+
place-items: center;
|
|
4133
|
+
width: 52px;
|
|
4134
|
+
height: 52px;
|
|
4135
|
+
padding: 0;
|
|
4136
|
+
border: 1px solid #2f596d;
|
|
4137
|
+
border-radius: 50%;
|
|
4138
|
+
background: #3f6f85;
|
|
4139
|
+
color: #fff;
|
|
4140
|
+
box-shadow: 0 4px 14px rgb(15 42 54 / 24%);
|
|
4141
|
+
cursor: pointer;
|
|
4142
|
+
pointer-events: auto;
|
|
4143
|
+
transition: background-color 120ms ease-out, box-shadow 120ms ease-out, transform 120ms ease-out;
|
|
4144
|
+
}
|
|
4145
|
+
button:hover { background: #315d71; box-shadow: 0 6px 18px rgb(15 42 54 / 30%); }
|
|
4146
|
+
button:active { transform: translateY(1px); }
|
|
4147
|
+
button:focus-visible { outline: 3px solid #f2c94c; outline-offset: 3px; }
|
|
4148
|
+
button:disabled { cursor: wait; opacity: .72; }
|
|
4149
|
+
.status {
|
|
4150
|
+
position: absolute;
|
|
4151
|
+
right: 62px;
|
|
4152
|
+
bottom: 7px;
|
|
4153
|
+
width: max-content;
|
|
4154
|
+
max-width: min(260px, calc(100vw - 94px));
|
|
4155
|
+
padding: 9px 11px;
|
|
4156
|
+
border: 1px solid #c6d3d9;
|
|
4157
|
+
border-radius: 6px;
|
|
4158
|
+
background: #fff;
|
|
4159
|
+
box-shadow: 0 3px 12px rgb(15 42 54 / 16%);
|
|
4160
|
+
color: #263942;
|
|
4161
|
+
font: 600 13px/1.35 "Segoe UI", Arial, sans-serif;
|
|
4162
|
+
pointer-events: none;
|
|
4163
|
+
}
|
|
4164
|
+
.status:empty { display: none; }
|
|
4165
|
+
svg { width: 25px; height: 25px; }
|
|
4166
|
+
@media (max-width: 600px) { :host { right: 12px; bottom: 12px; } }
|
|
4167
|
+
@media (prefers-reduced-motion: reduce) { button { transition: none; } }
|
|
4168
|
+
</style>
|
|
4169
|
+
<button type="button" aria-label="Open Datalynk Chat" title="Chat">
|
|
4170
|
+
<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
|
4171
|
+
<path fill="currentColor" d="M4 4h16a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H9l-5 3v-3a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2Zm2.5 8.25a1.25 1.25 0 1 0 0-2.5 1.25 1.25 0 0 0 0 2.5Zm5.5 0a1.25 1.25 0 1 0 0-2.5 1.25 1.25 0 0 0 0 2.5Zm5.5 0a1.25 1.25 0 1 0 0-2.5 1.25 1.25 0 0 0 0 2.5Z"/>
|
|
4172
|
+
</svg>
|
|
4173
|
+
</button>
|
|
4174
|
+
<span class="status" role="status" aria-live="polite"></span>`;
|
|
4175
|
+
const button = root.querySelector("button");
|
|
4176
|
+
button.addEventListener("click", () => void this.openChatFromLauncher());
|
|
4177
|
+
document.body.appendChild(host);
|
|
4178
|
+
this.chatLauncherHost = host;
|
|
4179
|
+
this.chatLauncherButton = button;
|
|
4180
|
+
};
|
|
4181
|
+
if (document.body) mount();
|
|
4182
|
+
else document.addEventListener("DOMContentLoaded", mount, { once: true });
|
|
4183
|
+
}
|
|
4184
|
+
async openChatFromLauncher() {
|
|
4185
|
+
const button = this.chatLauncherButton;
|
|
4186
|
+
if (!button) return;
|
|
4187
|
+
const status = button.getRootNode().querySelector(".status");
|
|
4188
|
+
button.disabled = true;
|
|
4189
|
+
button.setAttribute("aria-busy", "true");
|
|
4190
|
+
status.textContent = "Opening chat…";
|
|
4191
|
+
try {
|
|
4192
|
+
await this.openChat();
|
|
4193
|
+
status.textContent = "";
|
|
4194
|
+
} catch (error) {
|
|
4195
|
+
button.disabled = false;
|
|
4196
|
+
button.removeAttribute("aria-busy");
|
|
4197
|
+
status.textContent = "Chat is unavailable for this session.";
|
|
4198
|
+
console.error("Unable to open Datalynk Chat.", error);
|
|
4199
|
+
}
|
|
4200
|
+
}
|
|
4201
|
+
restoreChatLauncher() {
|
|
4202
|
+
if (!this.chatLauncherHost || !this.chatLauncherButton) return;
|
|
4203
|
+
this.chatLauncherHost.hidden = false;
|
|
4204
|
+
this.chatLauncherButton.disabled = false;
|
|
4205
|
+
this.chatLauncherButton.removeAttribute("aria-busy");
|
|
4206
|
+
this.chatLauncherButton.focus();
|
|
4207
|
+
}
|
|
4208
|
+
/** Lazily load and construct chat. No chat code or requests run before this call. */
|
|
4209
|
+
async chat() {
|
|
4210
|
+
if (this.chatInstance) return this.chatInstance;
|
|
4211
|
+
const client = await this.loadChatModule();
|
|
4212
|
+
return this.chatInstance || (this.chatInstance = new client.Chat(this));
|
|
4213
|
+
}
|
|
4214
|
+
/** Lazily load, authorize, and open the reusable chat window. */
|
|
4215
|
+
async openChat(options = {}) {
|
|
4216
|
+
const client = await this.loadChatModule();
|
|
4217
|
+
const chat = await this.chat();
|
|
4218
|
+
if (!await chat.available()) throw new Error("Chat is disabled or this session is not authorized.");
|
|
4219
|
+
if (this.socket.options.authentication !== "ticket") {
|
|
4220
|
+
this.socket.options.authentication = "ticket";
|
|
4221
|
+
void this.socket.connect();
|
|
4222
|
+
}
|
|
4223
|
+
const onClose = options.onClose;
|
|
4224
|
+
const chatWindow = client.openChat(chat, {
|
|
4225
|
+
...options,
|
|
4226
|
+
onClose: () => {
|
|
4227
|
+
this.restoreChatLauncher();
|
|
4228
|
+
onClose == null ? void 0 : onClose();
|
|
4229
|
+
}
|
|
4230
|
+
});
|
|
4231
|
+
if (this.chatLauncherHost) this.chatLauncherHost.hidden = true;
|
|
4232
|
+
return chatWindow;
|
|
4233
|
+
}
|
|
4234
|
+
loadChatModule() {
|
|
4235
|
+
if (!this.chatModulePromise) {
|
|
4236
|
+
const moduleUrl = this.options.chatModule || "./chat.mjs";
|
|
4237
|
+
this.chatModulePromise = import(
|
|
4238
|
+
/* @vite-ignore */
|
|
4239
|
+
moduleUrl
|
|
4240
|
+
);
|
|
4241
|
+
}
|
|
4242
|
+
return this.chatModulePromise;
|
|
4243
|
+
}
|
|
4017
4244
|
async _request(req, options = {}) {
|
|
4018
4245
|
if (this.recovery) throw errorFromCode(503, "Datalynk is unavailable");
|
|
4019
4246
|
const retryRequest = deepCopy(req);
|
|
@@ -4030,7 +4257,7 @@ const _Api = class _Api {
|
|
|
4030
4257
|
/** Execute exactly one HTTP API attempt. Recovery uses this directly to avoid recursive retry loops. */
|
|
4031
4258
|
async _requestOnce(req, options = {}, recoveryAttempt = false) {
|
|
4032
4259
|
const token = options.token || this.token;
|
|
4033
|
-
if (token && this.isTokenExpired(token)) {
|
|
4260
|
+
if (this.options.manageSession !== false && token && this.isTokenExpired(token)) {
|
|
4034
4261
|
if (token === this.token) this.expireToken(token);
|
|
4035
4262
|
throw errorFromCode(401, "Session token expired");
|
|
4036
4263
|
}
|
|
@@ -4197,7 +4424,7 @@ const _Api = class _Api {
|
|
|
4197
4424
|
}
|
|
4198
4425
|
return;
|
|
4199
4426
|
}
|
|
4200
|
-
if (this.token && this.isTokenExpired(this.token)) {
|
|
4427
|
+
if (this.options.manageSession !== false && this.token && this.isTokenExpired(this.token)) {
|
|
4201
4428
|
this.expireToken(this.token);
|
|
4202
4429
|
return;
|
|
4203
4430
|
}
|
|
@@ -4316,6 +4543,7 @@ const _Api = class _Api {
|
|
|
4316
4543
|
}
|
|
4317
4544
|
async finishUnauthorizedLogout(preservePending = false) {
|
|
4318
4545
|
var _a;
|
|
4546
|
+
if (this.options.manageSession === false) return;
|
|
4319
4547
|
if (typeof localStorage != "undefined") {
|
|
4320
4548
|
localStorage.removeItem(this.localStorageKey);
|
|
4321
4549
|
localStorage.removeItem("datalynk-user");
|
package/dist/socket.d.ts
CHANGED
|
@@ -43,6 +43,10 @@ export type WebRTCEvent = {
|
|
|
43
43
|
export type SocketOptions = {
|
|
44
44
|
/** Set connection URL or disable with false */
|
|
45
45
|
url?: string | false;
|
|
46
|
+
/** Use one-time socket tickets only when explicitly enabled by a chat-capable host. */
|
|
47
|
+
authentication?: 'token' | 'ticket';
|
|
48
|
+
/** Optional realm used by backward-compatible token authentication. */
|
|
49
|
+
realm?: string;
|
|
46
50
|
};
|
|
47
51
|
/** Callback shape */
|
|
48
52
|
export type SocketListener<T = SocketEvent<any>> = (event: T) => any;
|
|
@@ -55,6 +59,7 @@ export declare class Socket {
|
|
|
55
59
|
private listeners;
|
|
56
60
|
private retry?;
|
|
57
61
|
private socket?;
|
|
62
|
+
private connectGeneration;
|
|
58
63
|
open: boolean;
|
|
59
64
|
constructor(api: Api, options?: SocketOptions);
|
|
60
65
|
/**
|
|
@@ -76,7 +81,14 @@ export declare class Socket {
|
|
|
76
81
|
* Connect socket client to socket server
|
|
77
82
|
* @param {number} timeout Retry to connect every x seconds
|
|
78
83
|
*/
|
|
79
|
-
connect(timeout?: number): void
|
|
84
|
+
connect(timeout?: number): void | Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Ticket-authenticated connection path, used only once a chat-capable host switches
|
|
87
|
+
* this instance to `authentication: 'ticket'` (see Api.openChat). Entirely separate
|
|
88
|
+
* from the token path above so existing non-chat consumers are never affected.
|
|
89
|
+
*/
|
|
90
|
+
private connectWithTicket;
|
|
91
|
+
private scheduleReconnect;
|
|
80
92
|
/**
|
|
81
93
|
* Send data to socket server
|
|
82
94
|
*
|
|
@@ -91,5 +103,6 @@ export declare class Socket {
|
|
|
91
103
|
* @return {Unsubscribe} Run returned function to unsubscribe callback
|
|
92
104
|
*/
|
|
93
105
|
sliceEvents(slice: number | number[] | string | string[], callback: SocketListener<SocketEventSlice>): Unsubscribe;
|
|
106
|
+
private normalizeUrl;
|
|
94
107
|
}
|
|
95
108
|
//# sourceMappingURL=socket.d.ts.map
|
package/dist/socket.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket.d.ts","sourceRoot":"","sources":["../src/socket.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,CAAC,CAAA;CACP,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,WAAW,CAAC;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC,CAAC;AAEH,MAAM,MAAM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B,OAAO,CAAC,MAAM,CAAC,CAAY;IAC3B,OAAO,CAAC,iBAAiB,CAAK;IAE9B,IAAI,UAAS;gBAEgB,GAAG,EAAE,GAAG,EAAkB,OAAO,GAAE,aAAkB;IAWlF;;;;;;;;;OASG;IACH,WAAW,CAAC,EAAE,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,IAAI,GAAG,WAAW;IAOnE;;OAEG;IACH,KAAK;IAUL;;;OAGG;IACH,OAAO,CAAC,OAAO,GAAE,MAAW;IAiC5B;;;;OAIG;YACW,iBAAiB;IA6D/B,OAAO,CAAC,iBAAiB;IASzB;;;;OAIG;IACH,IAAI,CAAC,OAAO,EAAE,GAAG;IAKjB;;;;;;OAMG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,GAAG,MAAM,EAAE,EAAE,QAAQ,EAAE,cAAc,CAAC,gBAAgB,CAAC,GAAG,WAAW;IAWlH,OAAO,CAAC,YAAY;CAUpB"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@auxilium/datalynk-client",
|
|
3
3
|
"description": "Datalynk client library",
|
|
4
4
|
"repository": "https://gitlab.auxiliumgroup.com/auxilium/datalynk/datalynk-client",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.6.0",
|
|
6
6
|
"author": "Auxilium Group <devops@auxiliumgroup.com>",
|
|
7
7
|
"private": false,
|
|
8
8
|
"main": "./dist/index.cjs",
|
|
@@ -13,13 +13,18 @@
|
|
|
13
13
|
"types": "./dist/index.d.ts",
|
|
14
14
|
"import": "./dist/index.mjs",
|
|
15
15
|
"require": "./dist/index.cjs"
|
|
16
|
+
},
|
|
17
|
+
"./chat": {
|
|
18
|
+
"types": "./dist/chat-entry.d.ts",
|
|
19
|
+
"import": "./dist/chat.mjs",
|
|
20
|
+
"require": "./dist/chat.cjs"
|
|
16
21
|
}
|
|
17
22
|
},
|
|
18
23
|
"bin": {
|
|
19
24
|
"datalynk-models": "./bin/datalynk-models.mjs"
|
|
20
25
|
},
|
|
21
26
|
"scripts": {
|
|
22
|
-
"build": "tsc && npx vite build",
|
|
27
|
+
"build": "tsc && npx vite build && npx vite build --config vite.chat.config.ts",
|
|
23
28
|
"postbuild": "node -e \"const fs=require('fs');fs.cpSync('src/service.worker.mjs','dist/service.worker.mjs')\"",
|
|
24
29
|
"test": "npm run build && node --test test/*.test.mjs",
|
|
25
30
|
"datalynk-models": "node --no-warnings ./bin/datalynk-models.mjs",
|