tevrocsdk 0.1.71 → 0.1.73
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/package.json +5 -7
- package/tevroc-sdk.cjs.js +50104 -48906
- package/tevroc-sdk.cjs.js.map +7 -7
- package/tevroc-sdk.esm.js +275 -190
- package/tevroc-sdk.esm.js.map +4 -4
- package/tevroc-sdk.min.js +43 -43
package/tevroc-sdk.esm.js
CHANGED
|
@@ -352,8 +352,8 @@ var init_dist = __esm({
|
|
|
352
352
|
registered: false,
|
|
353
353
|
windowEventName,
|
|
354
354
|
pluginEventName,
|
|
355
|
-
handler: (
|
|
356
|
-
this.notifyListeners(pluginEventName,
|
|
355
|
+
handler: (event) => {
|
|
356
|
+
this.notifyListeners(pluginEventName, event);
|
|
357
357
|
}
|
|
358
358
|
};
|
|
359
359
|
}
|
|
@@ -1100,41 +1100,41 @@ __export(event_exports, {
|
|
|
1100
1100
|
listen: () => listen,
|
|
1101
1101
|
once: () => once
|
|
1102
1102
|
});
|
|
1103
|
-
async function _unlisten(
|
|
1104
|
-
window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(
|
|
1103
|
+
async function _unlisten(event, eventId) {
|
|
1104
|
+
window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(event, eventId);
|
|
1105
1105
|
await invoke("plugin:event|unlisten", {
|
|
1106
|
-
event
|
|
1106
|
+
event,
|
|
1107
1107
|
eventId
|
|
1108
1108
|
});
|
|
1109
1109
|
}
|
|
1110
|
-
async function listen(
|
|
1110
|
+
async function listen(event, handler, options) {
|
|
1111
1111
|
var _a2;
|
|
1112
1112
|
const target = typeof (options === null || options === void 0 ? void 0 : options.target) === "string" ? { kind: "AnyLabel", label: options.target } : (_a2 = options === null || options === void 0 ? void 0 : options.target) !== null && _a2 !== void 0 ? _a2 : { kind: "Any" };
|
|
1113
1113
|
return invoke("plugin:event|listen", {
|
|
1114
|
-
event
|
|
1114
|
+
event,
|
|
1115
1115
|
target,
|
|
1116
1116
|
handler: transformCallback(handler)
|
|
1117
1117
|
}).then((eventId) => {
|
|
1118
|
-
return async () => _unlisten(
|
|
1118
|
+
return async () => _unlisten(event, eventId);
|
|
1119
1119
|
});
|
|
1120
1120
|
}
|
|
1121
|
-
async function once(
|
|
1122
|
-
return listen(
|
|
1123
|
-
void _unlisten(
|
|
1121
|
+
async function once(event, handler, options) {
|
|
1122
|
+
return listen(event, (eventData) => {
|
|
1123
|
+
void _unlisten(event, eventData.id);
|
|
1124
1124
|
handler(eventData);
|
|
1125
1125
|
}, options);
|
|
1126
1126
|
}
|
|
1127
|
-
async function emit(
|
|
1127
|
+
async function emit(event, payload) {
|
|
1128
1128
|
await invoke("plugin:event|emit", {
|
|
1129
|
-
event
|
|
1129
|
+
event,
|
|
1130
1130
|
payload
|
|
1131
1131
|
});
|
|
1132
1132
|
}
|
|
1133
|
-
async function emitTo(target,
|
|
1133
|
+
async function emitTo(target, event, payload) {
|
|
1134
1134
|
const eventTarget = typeof target === "string" ? { kind: "AnyLabel", label: target } : target;
|
|
1135
1135
|
await invoke("plugin:event|emit_to", {
|
|
1136
1136
|
target: eventTarget,
|
|
1137
|
-
event
|
|
1137
|
+
event,
|
|
1138
1138
|
payload
|
|
1139
1139
|
});
|
|
1140
1140
|
}
|
|
@@ -1262,10 +1262,10 @@ var init_window = __esm({
|
|
|
1262
1262
|
UserAttentionType2[UserAttentionType2["Informational"] = 2] = "Informational";
|
|
1263
1263
|
})(UserAttentionType || (UserAttentionType = {}));
|
|
1264
1264
|
CloseRequestedEvent = class {
|
|
1265
|
-
constructor(
|
|
1265
|
+
constructor(event) {
|
|
1266
1266
|
this._preventDefault = false;
|
|
1267
|
-
this.event =
|
|
1268
|
-
this.id =
|
|
1267
|
+
this.event = event.event;
|
|
1268
|
+
this.id = event.id;
|
|
1269
1269
|
}
|
|
1270
1270
|
preventDefault() {
|
|
1271
1271
|
this._preventDefault = true;
|
|
@@ -1378,14 +1378,14 @@ var init_window = __esm({
|
|
|
1378
1378
|
* @returns A promise resolving to a function to unlisten to the event.
|
|
1379
1379
|
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
|
1380
1380
|
*/
|
|
1381
|
-
async listen(
|
|
1382
|
-
if (this._handleTauriEvent(
|
|
1381
|
+
async listen(event, handler) {
|
|
1382
|
+
if (this._handleTauriEvent(event, handler)) {
|
|
1383
1383
|
return () => {
|
|
1384
|
-
const listeners2 = this.listeners[
|
|
1384
|
+
const listeners2 = this.listeners[event];
|
|
1385
1385
|
listeners2.splice(listeners2.indexOf(handler), 1);
|
|
1386
1386
|
};
|
|
1387
1387
|
}
|
|
1388
|
-
return listen(
|
|
1388
|
+
return listen(event, handler, {
|
|
1389
1389
|
target: { kind: "Window", label: this.label }
|
|
1390
1390
|
});
|
|
1391
1391
|
}
|
|
@@ -1408,14 +1408,14 @@ var init_window = __esm({
|
|
|
1408
1408
|
* @returns A promise resolving to a function to unlisten to the event.
|
|
1409
1409
|
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
|
1410
1410
|
*/
|
|
1411
|
-
async once(
|
|
1412
|
-
if (this._handleTauriEvent(
|
|
1411
|
+
async once(event, handler) {
|
|
1412
|
+
if (this._handleTauriEvent(event, handler)) {
|
|
1413
1413
|
return () => {
|
|
1414
|
-
const listeners2 = this.listeners[
|
|
1414
|
+
const listeners2 = this.listeners[event];
|
|
1415
1415
|
listeners2.splice(listeners2.indexOf(handler), 1);
|
|
1416
1416
|
};
|
|
1417
1417
|
}
|
|
1418
|
-
return once(
|
|
1418
|
+
return once(event, handler, {
|
|
1419
1419
|
target: { kind: "Window", label: this.label }
|
|
1420
1420
|
});
|
|
1421
1421
|
}
|
|
@@ -1430,18 +1430,18 @@ var init_window = __esm({
|
|
|
1430
1430
|
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
|
1431
1431
|
* @param payload Event payload.
|
|
1432
1432
|
*/
|
|
1433
|
-
async emit(
|
|
1434
|
-
if (localTauriEvents.includes(
|
|
1435
|
-
for (const handler of this.listeners[
|
|
1433
|
+
async emit(event, payload) {
|
|
1434
|
+
if (localTauriEvents.includes(event)) {
|
|
1435
|
+
for (const handler of this.listeners[event] || []) {
|
|
1436
1436
|
handler({
|
|
1437
|
-
event
|
|
1437
|
+
event,
|
|
1438
1438
|
id: -1,
|
|
1439
1439
|
payload
|
|
1440
1440
|
});
|
|
1441
1441
|
}
|
|
1442
1442
|
return;
|
|
1443
1443
|
}
|
|
1444
|
-
return emit(
|
|
1444
|
+
return emit(event, payload);
|
|
1445
1445
|
}
|
|
1446
1446
|
/**
|
|
1447
1447
|
* Emits an event to all {@link EventTarget|targets} matching the given target.
|
|
@@ -1455,26 +1455,26 @@ var init_window = __esm({
|
|
|
1455
1455
|
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
|
1456
1456
|
* @param payload Event payload.
|
|
1457
1457
|
*/
|
|
1458
|
-
async emitTo(target,
|
|
1459
|
-
if (localTauriEvents.includes(
|
|
1460
|
-
for (const handler of this.listeners[
|
|
1458
|
+
async emitTo(target, event, payload) {
|
|
1459
|
+
if (localTauriEvents.includes(event)) {
|
|
1460
|
+
for (const handler of this.listeners[event] || []) {
|
|
1461
1461
|
handler({
|
|
1462
|
-
event
|
|
1462
|
+
event,
|
|
1463
1463
|
id: -1,
|
|
1464
1464
|
payload
|
|
1465
1465
|
});
|
|
1466
1466
|
}
|
|
1467
1467
|
return;
|
|
1468
1468
|
}
|
|
1469
|
-
return emitTo(target,
|
|
1469
|
+
return emitTo(target, event, payload);
|
|
1470
1470
|
}
|
|
1471
1471
|
/** @ignore */
|
|
1472
|
-
_handleTauriEvent(
|
|
1473
|
-
if (localTauriEvents.includes(
|
|
1474
|
-
if (!(
|
|
1475
|
-
this.listeners[
|
|
1472
|
+
_handleTauriEvent(event, handler) {
|
|
1473
|
+
if (localTauriEvents.includes(event)) {
|
|
1474
|
+
if (!(event in this.listeners)) {
|
|
1475
|
+
this.listeners[event] = [handler];
|
|
1476
1476
|
} else {
|
|
1477
|
-
this.listeners[
|
|
1477
|
+
this.listeners[event].push(handler);
|
|
1478
1478
|
}
|
|
1479
1479
|
return true;
|
|
1480
1480
|
}
|
|
@@ -2769,8 +2769,8 @@ var init_window = __esm({
|
|
|
2769
2769
|
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
|
2770
2770
|
*/
|
|
2771
2771
|
async onCloseRequested(handler) {
|
|
2772
|
-
return this.listen(TauriEvent.WINDOW_CLOSE_REQUESTED, async (
|
|
2773
|
-
const evt = new CloseRequestedEvent(
|
|
2772
|
+
return this.listen(TauriEvent.WINDOW_CLOSE_REQUESTED, async (event) => {
|
|
2773
|
+
const evt = new CloseRequestedEvent(event);
|
|
2774
2774
|
await handler(evt);
|
|
2775
2775
|
if (!evt.isPreventDefault()) {
|
|
2776
2776
|
await this.destroy();
|
|
@@ -2803,37 +2803,37 @@ var init_window = __esm({
|
|
|
2803
2803
|
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
|
2804
2804
|
*/
|
|
2805
2805
|
async onDragDropEvent(handler) {
|
|
2806
|
-
const unlistenDrag = await this.listen(TauriEvent.DRAG_ENTER, (
|
|
2806
|
+
const unlistenDrag = await this.listen(TauriEvent.DRAG_ENTER, (event) => {
|
|
2807
2807
|
handler({
|
|
2808
|
-
...
|
|
2808
|
+
...event,
|
|
2809
2809
|
payload: {
|
|
2810
2810
|
type: "enter",
|
|
2811
|
-
paths:
|
|
2812
|
-
position: new PhysicalPosition(
|
|
2811
|
+
paths: event.payload.paths,
|
|
2812
|
+
position: new PhysicalPosition(event.payload.position)
|
|
2813
2813
|
}
|
|
2814
2814
|
});
|
|
2815
2815
|
});
|
|
2816
|
-
const unlistenDragOver = await this.listen(TauriEvent.DRAG_OVER, (
|
|
2816
|
+
const unlistenDragOver = await this.listen(TauriEvent.DRAG_OVER, (event) => {
|
|
2817
2817
|
handler({
|
|
2818
|
-
...
|
|
2818
|
+
...event,
|
|
2819
2819
|
payload: {
|
|
2820
2820
|
type: "over",
|
|
2821
|
-
position: new PhysicalPosition(
|
|
2821
|
+
position: new PhysicalPosition(event.payload.position)
|
|
2822
2822
|
}
|
|
2823
2823
|
});
|
|
2824
2824
|
});
|
|
2825
|
-
const unlistenDrop = await this.listen(TauriEvent.DRAG_DROP, (
|
|
2825
|
+
const unlistenDrop = await this.listen(TauriEvent.DRAG_DROP, (event) => {
|
|
2826
2826
|
handler({
|
|
2827
|
-
...
|
|
2827
|
+
...event,
|
|
2828
2828
|
payload: {
|
|
2829
2829
|
type: "drop",
|
|
2830
|
-
paths:
|
|
2831
|
-
position: new PhysicalPosition(
|
|
2830
|
+
paths: event.payload.paths,
|
|
2831
|
+
position: new PhysicalPosition(event.payload.position)
|
|
2832
2832
|
}
|
|
2833
2833
|
});
|
|
2834
2834
|
});
|
|
2835
|
-
const unlistenCancel = await this.listen(TauriEvent.DRAG_LEAVE, (
|
|
2836
|
-
handler({ ...
|
|
2835
|
+
const unlistenCancel = await this.listen(TauriEvent.DRAG_LEAVE, (event) => {
|
|
2836
|
+
handler({ ...event, payload: { type: "leave" } });
|
|
2837
2837
|
});
|
|
2838
2838
|
return () => {
|
|
2839
2839
|
unlistenDrag();
|
|
@@ -2860,11 +2860,11 @@ var init_window = __esm({
|
|
|
2860
2860
|
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
|
2861
2861
|
*/
|
|
2862
2862
|
async onFocusChanged(handler) {
|
|
2863
|
-
const unlistenFocus = await this.listen(TauriEvent.WINDOW_FOCUS, (
|
|
2864
|
-
handler({ ...
|
|
2863
|
+
const unlistenFocus = await this.listen(TauriEvent.WINDOW_FOCUS, (event) => {
|
|
2864
|
+
handler({ ...event, payload: true });
|
|
2865
2865
|
});
|
|
2866
|
-
const unlistenBlur = await this.listen(TauriEvent.WINDOW_BLUR, (
|
|
2867
|
-
handler({ ...
|
|
2866
|
+
const unlistenBlur = await this.listen(TauriEvent.WINDOW_BLUR, (event) => {
|
|
2867
|
+
handler({ ...event, payload: false });
|
|
2868
2868
|
});
|
|
2869
2869
|
return () => {
|
|
2870
2870
|
unlistenFocus();
|
|
@@ -3077,14 +3077,14 @@ var init_webview = __esm({
|
|
|
3077
3077
|
* @returns A promise resolving to a function to unlisten to the event.
|
|
3078
3078
|
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
|
3079
3079
|
*/
|
|
3080
|
-
async listen(
|
|
3081
|
-
if (this._handleTauriEvent(
|
|
3080
|
+
async listen(event, handler) {
|
|
3081
|
+
if (this._handleTauriEvent(event, handler)) {
|
|
3082
3082
|
return () => {
|
|
3083
|
-
const listeners2 = this.listeners[
|
|
3083
|
+
const listeners2 = this.listeners[event];
|
|
3084
3084
|
listeners2.splice(listeners2.indexOf(handler), 1);
|
|
3085
3085
|
};
|
|
3086
3086
|
}
|
|
3087
|
-
return listen(
|
|
3087
|
+
return listen(event, handler, {
|
|
3088
3088
|
target: { kind: "Webview", label: this.label }
|
|
3089
3089
|
});
|
|
3090
3090
|
}
|
|
@@ -3107,14 +3107,14 @@ var init_webview = __esm({
|
|
|
3107
3107
|
* @returns A promise resolving to a function to unlisten to the event.
|
|
3108
3108
|
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
|
3109
3109
|
*/
|
|
3110
|
-
async once(
|
|
3111
|
-
if (this._handleTauriEvent(
|
|
3110
|
+
async once(event, handler) {
|
|
3111
|
+
if (this._handleTauriEvent(event, handler)) {
|
|
3112
3112
|
return () => {
|
|
3113
|
-
const listeners2 = this.listeners[
|
|
3113
|
+
const listeners2 = this.listeners[event];
|
|
3114
3114
|
listeners2.splice(listeners2.indexOf(handler), 1);
|
|
3115
3115
|
};
|
|
3116
3116
|
}
|
|
3117
|
-
return once(
|
|
3117
|
+
return once(event, handler, {
|
|
3118
3118
|
target: { kind: "Webview", label: this.label }
|
|
3119
3119
|
});
|
|
3120
3120
|
}
|
|
@@ -3130,18 +3130,18 @@ var init_webview = __esm({
|
|
|
3130
3130
|
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
|
3131
3131
|
* @param payload Event payload.
|
|
3132
3132
|
*/
|
|
3133
|
-
async emit(
|
|
3134
|
-
if (localTauriEvents2.includes(
|
|
3135
|
-
for (const handler of this.listeners[
|
|
3133
|
+
async emit(event, payload) {
|
|
3134
|
+
if (localTauriEvents2.includes(event)) {
|
|
3135
|
+
for (const handler of this.listeners[event] || []) {
|
|
3136
3136
|
handler({
|
|
3137
|
-
event
|
|
3137
|
+
event,
|
|
3138
3138
|
id: -1,
|
|
3139
3139
|
payload
|
|
3140
3140
|
});
|
|
3141
3141
|
}
|
|
3142
3142
|
return;
|
|
3143
3143
|
}
|
|
3144
|
-
return emit(
|
|
3144
|
+
return emit(event, payload);
|
|
3145
3145
|
}
|
|
3146
3146
|
/**
|
|
3147
3147
|
* Emits an event to all {@link EventTarget|targets} matching the given target.
|
|
@@ -3156,26 +3156,26 @@ var init_webview = __esm({
|
|
|
3156
3156
|
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
|
3157
3157
|
* @param payload Event payload.
|
|
3158
3158
|
*/
|
|
3159
|
-
async emitTo(target,
|
|
3160
|
-
if (localTauriEvents2.includes(
|
|
3161
|
-
for (const handler of this.listeners[
|
|
3159
|
+
async emitTo(target, event, payload) {
|
|
3160
|
+
if (localTauriEvents2.includes(event)) {
|
|
3161
|
+
for (const handler of this.listeners[event] || []) {
|
|
3162
3162
|
handler({
|
|
3163
|
-
event
|
|
3163
|
+
event,
|
|
3164
3164
|
id: -1,
|
|
3165
3165
|
payload
|
|
3166
3166
|
});
|
|
3167
3167
|
}
|
|
3168
3168
|
return;
|
|
3169
3169
|
}
|
|
3170
|
-
return emitTo(target,
|
|
3170
|
+
return emitTo(target, event, payload);
|
|
3171
3171
|
}
|
|
3172
3172
|
/** @ignore */
|
|
3173
|
-
_handleTauriEvent(
|
|
3174
|
-
if (localTauriEvents2.includes(
|
|
3175
|
-
if (!(
|
|
3176
|
-
this.listeners[
|
|
3173
|
+
_handleTauriEvent(event, handler) {
|
|
3174
|
+
if (localTauriEvents2.includes(event)) {
|
|
3175
|
+
if (!(event in this.listeners)) {
|
|
3176
|
+
this.listeners[event] = [handler];
|
|
3177
3177
|
} else {
|
|
3178
|
-
this.listeners[
|
|
3178
|
+
this.listeners[event].push(handler);
|
|
3179
3179
|
}
|
|
3180
3180
|
return true;
|
|
3181
3181
|
}
|
|
@@ -3416,37 +3416,37 @@ var init_webview = __esm({
|
|
|
3416
3416
|
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
|
3417
3417
|
*/
|
|
3418
3418
|
async onDragDropEvent(handler) {
|
|
3419
|
-
const unlistenDragEnter = await this.listen(TauriEvent.DRAG_ENTER, (
|
|
3419
|
+
const unlistenDragEnter = await this.listen(TauriEvent.DRAG_ENTER, (event) => {
|
|
3420
3420
|
handler({
|
|
3421
|
-
...
|
|
3421
|
+
...event,
|
|
3422
3422
|
payload: {
|
|
3423
3423
|
type: "enter",
|
|
3424
|
-
paths:
|
|
3425
|
-
position: new PhysicalPosition(
|
|
3424
|
+
paths: event.payload.paths,
|
|
3425
|
+
position: new PhysicalPosition(event.payload.position)
|
|
3426
3426
|
}
|
|
3427
3427
|
});
|
|
3428
3428
|
});
|
|
3429
|
-
const unlistenDragOver = await this.listen(TauriEvent.DRAG_OVER, (
|
|
3429
|
+
const unlistenDragOver = await this.listen(TauriEvent.DRAG_OVER, (event) => {
|
|
3430
3430
|
handler({
|
|
3431
|
-
...
|
|
3431
|
+
...event,
|
|
3432
3432
|
payload: {
|
|
3433
3433
|
type: "over",
|
|
3434
|
-
position: new PhysicalPosition(
|
|
3434
|
+
position: new PhysicalPosition(event.payload.position)
|
|
3435
3435
|
}
|
|
3436
3436
|
});
|
|
3437
3437
|
});
|
|
3438
|
-
const unlistenDragDrop = await this.listen(TauriEvent.DRAG_DROP, (
|
|
3438
|
+
const unlistenDragDrop = await this.listen(TauriEvent.DRAG_DROP, (event) => {
|
|
3439
3439
|
handler({
|
|
3440
|
-
...
|
|
3440
|
+
...event,
|
|
3441
3441
|
payload: {
|
|
3442
3442
|
type: "drop",
|
|
3443
|
-
paths:
|
|
3444
|
-
position: new PhysicalPosition(
|
|
3443
|
+
paths: event.payload.paths,
|
|
3444
|
+
position: new PhysicalPosition(event.payload.position)
|
|
3445
3445
|
}
|
|
3446
3446
|
});
|
|
3447
3447
|
});
|
|
3448
|
-
const unlistenDragLeave = await this.listen(TauriEvent.DRAG_LEAVE, (
|
|
3449
|
-
handler({ ...
|
|
3448
|
+
const unlistenDragLeave = await this.listen(TauriEvent.DRAG_LEAVE, (event) => {
|
|
3449
|
+
handler({ ...event, payload: { type: "leave" } });
|
|
3450
3450
|
});
|
|
3451
3451
|
return () => {
|
|
3452
3452
|
unlistenDragEnter();
|
|
@@ -3582,14 +3582,14 @@ var init_webviewWindow = __esm({
|
|
|
3582
3582
|
* @returns A promise resolving to a function to unlisten to the event.
|
|
3583
3583
|
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
|
3584
3584
|
*/
|
|
3585
|
-
async listen(
|
|
3586
|
-
if (this._handleTauriEvent(
|
|
3585
|
+
async listen(event, handler) {
|
|
3586
|
+
if (this._handleTauriEvent(event, handler)) {
|
|
3587
3587
|
return () => {
|
|
3588
|
-
const listeners2 = this.listeners[
|
|
3588
|
+
const listeners2 = this.listeners[event];
|
|
3589
3589
|
listeners2.splice(listeners2.indexOf(handler), 1);
|
|
3590
3590
|
};
|
|
3591
3591
|
}
|
|
3592
|
-
return listen(
|
|
3592
|
+
return listen(event, handler, {
|
|
3593
3593
|
target: { kind: "WebviewWindow", label: this.label }
|
|
3594
3594
|
});
|
|
3595
3595
|
}
|
|
@@ -3612,14 +3612,14 @@ var init_webviewWindow = __esm({
|
|
|
3612
3612
|
* @returns A promise resolving to a function to unlisten to the event.
|
|
3613
3613
|
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
|
3614
3614
|
*/
|
|
3615
|
-
async once(
|
|
3616
|
-
if (this._handleTauriEvent(
|
|
3615
|
+
async once(event, handler) {
|
|
3616
|
+
if (this._handleTauriEvent(event, handler)) {
|
|
3617
3617
|
return () => {
|
|
3618
|
-
const listeners2 = this.listeners[
|
|
3618
|
+
const listeners2 = this.listeners[event];
|
|
3619
3619
|
listeners2.splice(listeners2.indexOf(handler), 1);
|
|
3620
3620
|
};
|
|
3621
3621
|
}
|
|
3622
|
-
return once(
|
|
3622
|
+
return once(event, handler, {
|
|
3623
3623
|
target: { kind: "WebviewWindow", label: this.label }
|
|
3624
3624
|
});
|
|
3625
3625
|
}
|
|
@@ -3797,14 +3797,14 @@ var init_useGoogleAuth = __esm({
|
|
|
3797
3797
|
googleInitialized = true;
|
|
3798
3798
|
if (isCapacitor) {
|
|
3799
3799
|
const { App: App2 } = await getCapacitorPlugins();
|
|
3800
|
-
App2.addListener("appUrlOpen", (
|
|
3801
|
-
handleCallback(
|
|
3800
|
+
App2.addListener("appUrlOpen", (event) => {
|
|
3801
|
+
handleCallback(event.url);
|
|
3802
3802
|
});
|
|
3803
3803
|
}
|
|
3804
3804
|
if (isTauri) {
|
|
3805
3805
|
const { listen: listen2 } = await Promise.resolve().then(() => (init_event(), event_exports));
|
|
3806
|
-
await listen2("deep-link://open-url", async (
|
|
3807
|
-
let url =
|
|
3806
|
+
await listen2("deep-link://open-url", async (event) => {
|
|
3807
|
+
let url = event.payload;
|
|
3808
3808
|
if (typeof url === "object") {
|
|
3809
3809
|
url = url?.url || url?.payload || null;
|
|
3810
3810
|
}
|
|
@@ -3864,11 +3864,11 @@ var init_useGoogleAuth = __esm({
|
|
|
3864
3864
|
debugError("Popup blocked");
|
|
3865
3865
|
}
|
|
3866
3866
|
authWindowRef = popup;
|
|
3867
|
-
authMessageListener = async (
|
|
3867
|
+
authMessageListener = async (event) => {
|
|
3868
3868
|
const serviceOrigin = new URL(serviceUrl).origin;
|
|
3869
|
-
if (
|
|
3870
|
-
if (
|
|
3871
|
-
const token =
|
|
3869
|
+
if (event.origin !== serviceOrigin) return;
|
|
3870
|
+
if (event.data?.type === "google-auth") {
|
|
3871
|
+
const token = event.data?.token || null;
|
|
3872
3872
|
const url = token ? `${window.location.href}${window.location.href.includes("?") ? "&" : "?"}token=${token}` : window.location.href;
|
|
3873
3873
|
await handleCallback(url);
|
|
3874
3874
|
}
|
|
@@ -3957,17 +3957,17 @@ var init_useYocoPayment = __esm({
|
|
|
3957
3957
|
paymentInitialized = true;
|
|
3958
3958
|
if (isCapacitor) {
|
|
3959
3959
|
const { App: App2 } = await getCapacitorPlugins2();
|
|
3960
|
-
App2.addListener("appUrlOpen", (
|
|
3960
|
+
App2.addListener("appUrlOpen", (event) => {
|
|
3961
3961
|
handlePaymentCallback(
|
|
3962
|
-
|
|
3962
|
+
event.url,
|
|
3963
3963
|
externalCallback
|
|
3964
3964
|
);
|
|
3965
3965
|
});
|
|
3966
3966
|
}
|
|
3967
3967
|
if (isTauri) {
|
|
3968
3968
|
const { listen: listen2 } = await Promise.resolve().then(() => (init_event(), event_exports));
|
|
3969
|
-
await listen2("deep-link://open-url", async (
|
|
3970
|
-
let url =
|
|
3969
|
+
await listen2("deep-link://open-url", async (event) => {
|
|
3970
|
+
let url = event.payload;
|
|
3971
3971
|
if (typeof url === "object") {
|
|
3972
3972
|
url = url?.url || url?.payload || null;
|
|
3973
3973
|
}
|
|
@@ -4036,12 +4036,12 @@ var init_useYocoPayment = __esm({
|
|
|
4036
4036
|
}
|
|
4037
4037
|
let listenerAttached = true;
|
|
4038
4038
|
let timerRunning = true;
|
|
4039
|
-
const listener = (
|
|
4039
|
+
const listener = (event) => {
|
|
4040
4040
|
try {
|
|
4041
4041
|
const serviceOrigin = new URL(serviceUrl).origin;
|
|
4042
|
-
if (
|
|
4043
|
-
if (
|
|
4044
|
-
const status =
|
|
4042
|
+
if (event.origin !== serviceOrigin) return;
|
|
4043
|
+
if (event.data?.type === "payment-result") {
|
|
4044
|
+
const status = event.data?.status || null;
|
|
4045
4045
|
listenerAttached = false;
|
|
4046
4046
|
timerRunning = false;
|
|
4047
4047
|
window.removeEventListener("message", listener);
|
|
@@ -14928,8 +14928,8 @@ var require_task = __commonJS({
|
|
|
14928
14928
|
run(id);
|
|
14929
14929
|
};
|
|
14930
14930
|
};
|
|
14931
|
-
var eventListener = function(
|
|
14932
|
-
run(
|
|
14931
|
+
var eventListener = function(event) {
|
|
14932
|
+
run(event.data);
|
|
14933
14933
|
};
|
|
14934
14934
|
var globalPostMessageDefer = function(id) {
|
|
14935
14935
|
globalThis2.postMessage(String2(id), $location.protocol + "//" + $location.host);
|
|
@@ -15328,15 +15328,15 @@ var require_es_promise_constructor = __commonJS({
|
|
|
15328
15328
|
});
|
|
15329
15329
|
};
|
|
15330
15330
|
var dispatchEvent = function(name, promise, reason) {
|
|
15331
|
-
var
|
|
15331
|
+
var event, handler;
|
|
15332
15332
|
if (DISPATCH_EVENT) {
|
|
15333
|
-
|
|
15334
|
-
|
|
15335
|
-
|
|
15336
|
-
|
|
15337
|
-
globalThis2.dispatchEvent(
|
|
15338
|
-
} else
|
|
15339
|
-
if (!NATIVE_PROMISE_REJECTION_EVENT && (handler = globalThis2["on" + name])) handler(
|
|
15333
|
+
event = document2.createEvent("Event");
|
|
15334
|
+
event.promise = promise;
|
|
15335
|
+
event.reason = reason;
|
|
15336
|
+
event.initEvent(name, false, true);
|
|
15337
|
+
globalThis2.dispatchEvent(event);
|
|
15338
|
+
} else event = { promise, reason };
|
|
15339
|
+
if (!NATIVE_PROMISE_REJECTION_EVENT && (handler = globalThis2["on" + name])) handler(event);
|
|
15340
15340
|
else if (name === UNHANDLED_REJECTION) hostReportErrors("Unhandled promise rejection", reason);
|
|
15341
15341
|
};
|
|
15342
15342
|
var onUnhandled = function(state) {
|
|
@@ -19393,11 +19393,11 @@ var init_index_es = __esm({
|
|
|
19393
19393
|
}
|
|
19394
19394
|
return point;
|
|
19395
19395
|
}
|
|
19396
|
-
onClick(
|
|
19396
|
+
onClick(event) {
|
|
19397
19397
|
var {
|
|
19398
19398
|
x: x3,
|
|
19399
19399
|
y: y3
|
|
19400
|
-
} = this.mapXY(
|
|
19400
|
+
} = this.mapXY(event.clientX, event.clientY);
|
|
19401
19401
|
this.events.push({
|
|
19402
19402
|
type: "onclick",
|
|
19403
19403
|
x: x3,
|
|
@@ -19409,11 +19409,11 @@ var init_index_es = __esm({
|
|
|
19409
19409
|
}
|
|
19410
19410
|
});
|
|
19411
19411
|
}
|
|
19412
|
-
onMouseMove(
|
|
19412
|
+
onMouseMove(event) {
|
|
19413
19413
|
var {
|
|
19414
19414
|
x: x3,
|
|
19415
19415
|
y: y3
|
|
19416
|
-
} = this.mapXY(
|
|
19416
|
+
} = this.mapXY(event.clientX, event.clientY);
|
|
19417
19417
|
this.events.push({
|
|
19418
19418
|
type: "onmousemove",
|
|
19419
19419
|
x: x3,
|
|
@@ -24030,10 +24030,10 @@ var init_web3 = __esm({
|
|
|
24030
24030
|
};
|
|
24031
24031
|
});
|
|
24032
24032
|
}
|
|
24033
|
-
static doUpgrade(
|
|
24034
|
-
const eventTarget =
|
|
24033
|
+
static doUpgrade(event) {
|
|
24034
|
+
const eventTarget = event.target;
|
|
24035
24035
|
const db = eventTarget.result;
|
|
24036
|
-
switch (
|
|
24036
|
+
switch (event.oldVersion) {
|
|
24037
24037
|
case 0:
|
|
24038
24038
|
case 1:
|
|
24039
24039
|
default: {
|
|
@@ -26206,20 +26206,20 @@ var init_web5 = __esm({
|
|
|
26206
26206
|
await customElements.whenDefined("jeep-sqlite");
|
|
26207
26207
|
this.jeepSqliteElement = document.querySelector("jeep-sqlite");
|
|
26208
26208
|
this.ensureJeepSqliteIsAvailable();
|
|
26209
|
-
this.jeepSqliteElement.addEventListener("jeepSqliteImportProgress", (
|
|
26210
|
-
this.notifyListeners("sqliteImportProgressEvent",
|
|
26209
|
+
this.jeepSqliteElement.addEventListener("jeepSqliteImportProgress", (event) => {
|
|
26210
|
+
this.notifyListeners("sqliteImportProgressEvent", event.detail);
|
|
26211
26211
|
});
|
|
26212
|
-
this.jeepSqliteElement.addEventListener("jeepSqliteExportProgress", (
|
|
26213
|
-
this.notifyListeners("sqliteExportProgressEvent",
|
|
26212
|
+
this.jeepSqliteElement.addEventListener("jeepSqliteExportProgress", (event) => {
|
|
26213
|
+
this.notifyListeners("sqliteExportProgressEvent", event.detail);
|
|
26214
26214
|
});
|
|
26215
|
-
this.jeepSqliteElement.addEventListener("jeepSqliteHTTPRequestEnded", (
|
|
26216
|
-
this.notifyListeners("sqliteHTTPRequestEndedEvent",
|
|
26215
|
+
this.jeepSqliteElement.addEventListener("jeepSqliteHTTPRequestEnded", (event) => {
|
|
26216
|
+
this.notifyListeners("sqliteHTTPRequestEndedEvent", event.detail);
|
|
26217
26217
|
});
|
|
26218
|
-
this.jeepSqliteElement.addEventListener("jeepSqlitePickDatabaseEnded", (
|
|
26219
|
-
this.notifyListeners("sqlitePickDatabaseEndedEvent",
|
|
26218
|
+
this.jeepSqliteElement.addEventListener("jeepSqlitePickDatabaseEnded", (event) => {
|
|
26219
|
+
this.notifyListeners("sqlitePickDatabaseEndedEvent", event.detail);
|
|
26220
26220
|
});
|
|
26221
|
-
this.jeepSqliteElement.addEventListener("jeepSqliteSaveDatabaseToDisk", (
|
|
26222
|
-
this.notifyListeners("sqliteSaveDatabaseToDiskEvent",
|
|
26221
|
+
this.jeepSqliteElement.addEventListener("jeepSqliteSaveDatabaseToDisk", (event) => {
|
|
26222
|
+
this.notifyListeners("sqliteSaveDatabaseToDiskEvent", event.detail);
|
|
26223
26223
|
});
|
|
26224
26224
|
if (!this.isWebStoreOpen) {
|
|
26225
26225
|
this.isWebStoreOpen = await this.jeepSqliteElement.isStoreOpen();
|
|
@@ -40774,7 +40774,7 @@ function createAgentNotificationService(client) {
|
|
|
40774
40774
|
let stopped = true;
|
|
40775
40775
|
const seen = /* @__PURE__ */ new Map();
|
|
40776
40776
|
const listeners2 = /* @__PURE__ */ new Set();
|
|
40777
|
-
const notify = (
|
|
40777
|
+
const notify = (event) => listeners2.forEach((listener) => listener(event));
|
|
40778
40778
|
const getSessionId = (session) => session.sessionId || session.session_id || session.id;
|
|
40779
40779
|
const getMessages = async (sessionId, appId) => {
|
|
40780
40780
|
const result = await client.entities.ChatMessage.query({ filter: { appId, sessionId }, limit: 100 });
|
|
@@ -40785,6 +40785,15 @@ function createAgentNotificationService(client) {
|
|
|
40785
40785
|
connection.publish({ type: "chat_message", sessionId, session_id: sessionId, message: payload, payload });
|
|
40786
40786
|
setTimeout(() => connection.close(), 1e3);
|
|
40787
40787
|
};
|
|
40788
|
+
const publishStatus = (sessionId, status, session) => publish(sessionId, {
|
|
40789
|
+
id: `status_${status}_${Date.now()}`,
|
|
40790
|
+
type: "chat_status",
|
|
40791
|
+
status,
|
|
40792
|
+
sessionId,
|
|
40793
|
+
session_id: sessionId,
|
|
40794
|
+
visitor_name: session?.visitor_name || "",
|
|
40795
|
+
createdAt: Date.now()
|
|
40796
|
+
});
|
|
40788
40797
|
const accept = async (session) => {
|
|
40789
40798
|
const sessionId = getSessionId(session);
|
|
40790
40799
|
await client.entities.ChatSession.update(session.id, {
|
|
@@ -40792,11 +40801,13 @@ function createAgentNotificationService(client) {
|
|
|
40792
40801
|
agent_email: client.agentIdentity || "agent",
|
|
40793
40802
|
updatedAt: Date.now()
|
|
40794
40803
|
});
|
|
40804
|
+
publishStatus(sessionId, "agent_active", session);
|
|
40795
40805
|
notify({ type: "accepted", sessionId, session });
|
|
40796
40806
|
};
|
|
40797
40807
|
const reject = async (session) => {
|
|
40798
40808
|
const sessionId = getSessionId(session);
|
|
40799
40809
|
await client.entities.ChatSession.update(session.id, { status: "agent_rejected", updatedAt: Date.now() });
|
|
40810
|
+
publishStatus(sessionId, "agent_rejected", session);
|
|
40800
40811
|
notify({ type: "rejected", sessionId, session });
|
|
40801
40812
|
};
|
|
40802
40813
|
const reply = async (session, content) => {
|
|
@@ -40831,11 +40842,14 @@ function createAgentNotificationService(client) {
|
|
|
40831
40842
|
id: `agent-request-${request.sessionId}`,
|
|
40832
40843
|
title: request.title,
|
|
40833
40844
|
body: request.body,
|
|
40834
|
-
data: { sessionId: request.sessionId },
|
|
40845
|
+
data: { sessionId: request.sessionId, kind: request.kind || "agent_request" },
|
|
40835
40846
|
channel: "agent_requests",
|
|
40836
40847
|
actions: [
|
|
40837
|
-
|
|
40838
|
-
|
|
40848
|
+
...request.kind === "agent_message" ? [] : [
|
|
40849
|
+
{ id: "accept", title: "Accept" },
|
|
40850
|
+
{ id: "reject", title: "Reject" }
|
|
40851
|
+
],
|
|
40852
|
+
{ id: "open", title: "Open" },
|
|
40839
40853
|
{ id: "reply", title: "Reply", input: true }
|
|
40840
40854
|
]
|
|
40841
40855
|
});
|
|
@@ -40850,6 +40864,7 @@ function createAgentNotificationService(client) {
|
|
|
40850
40864
|
seen.set(sessionId, fingerprint);
|
|
40851
40865
|
const request = {
|
|
40852
40866
|
sessionId,
|
|
40867
|
+
kind: "agent_request",
|
|
40853
40868
|
title: `Support request from ${session.visitor_name || "a visitor"}`,
|
|
40854
40869
|
body: latest?.content || "A visitor is requesting a human agent.",
|
|
40855
40870
|
latestMessage: latest,
|
|
@@ -40858,9 +40873,33 @@ function createAgentNotificationService(client) {
|
|
|
40858
40873
|
await showNative(request);
|
|
40859
40874
|
notify({ type: "request", ...request });
|
|
40860
40875
|
}
|
|
40876
|
+
if (client.agentIdentity) {
|
|
40877
|
+
const active = toList(await client.entities.ChatSession.query({ filter: { appId, status: "agent_active", agent_email: client.agentIdentity }, limit: 100 }));
|
|
40878
|
+
for (const session of active) {
|
|
40879
|
+
const sessionId = getSessionId(session);
|
|
40880
|
+
if (!sessionId) continue;
|
|
40881
|
+
const messages2 = await getMessages(sessionId, appId);
|
|
40882
|
+
const latestVisitor = latestByTime(messages2.filter((message2) => message2?.role === "visitor" || message2?.role === "user"));
|
|
40883
|
+
if (!latestVisitor) continue;
|
|
40884
|
+
const fingerprint = `message:${latestVisitor.id || latestVisitor.createdAt || latestVisitor.content}`;
|
|
40885
|
+
if (seen.get(`message:${sessionId}`) === fingerprint) continue;
|
|
40886
|
+
seen.set(`message:${sessionId}`, fingerprint);
|
|
40887
|
+
const request = {
|
|
40888
|
+
sessionId,
|
|
40889
|
+
kind: "agent_message",
|
|
40890
|
+
title: `New message from ${session.visitor_name || "visitor"}`,
|
|
40891
|
+
body: latestVisitor.content || "The visitor sent an attachment.",
|
|
40892
|
+
latestMessage: latestVisitor,
|
|
40893
|
+
session
|
|
40894
|
+
};
|
|
40895
|
+
await showNative(request);
|
|
40896
|
+
notify({ type: "message", ...request });
|
|
40897
|
+
}
|
|
40898
|
+
}
|
|
40861
40899
|
};
|
|
40862
40900
|
const start = async ({ pollMs = 8e3, agentIdentity, ...options } = {}) => {
|
|
40863
40901
|
if (agentIdentity) client.agentIdentity = agentIdentity;
|
|
40902
|
+
if (options.appId) client.appId = options.appId;
|
|
40864
40903
|
stopped = false;
|
|
40865
40904
|
await check(options);
|
|
40866
40905
|
clearInterval(timer);
|
|
@@ -40876,7 +40915,9 @@ function createAgentNotificationService(client) {
|
|
|
40876
40915
|
return () => listeners2.delete(listener);
|
|
40877
40916
|
};
|
|
40878
40917
|
client.notifications.onAction(({ action, data, reply: text2 }) => {
|
|
40879
|
-
if (data?.sessionId
|
|
40918
|
+
if (data?.sessionId && String(data.kind || "").startsWith("agent_")) {
|
|
40919
|
+
dispatchAction({ action, sessionId: data.sessionId, reply: text2 }).catch((error) => notify({ type: "error", error }));
|
|
40920
|
+
}
|
|
40880
40921
|
});
|
|
40881
40922
|
return { start, stop, check, onEvent, accept, reject, reply, dispatchAction };
|
|
40882
40923
|
}
|
|
@@ -40887,28 +40928,30 @@ function createNotificationService() {
|
|
|
40887
40928
|
const listeners2 = /* @__PURE__ */ new Set();
|
|
40888
40929
|
const scheduled = /* @__PURE__ */ new Map();
|
|
40889
40930
|
let nativeListenerInstalled = false;
|
|
40890
|
-
const emit2 = (
|
|
40931
|
+
const emit2 = (event) => listeners2.forEach((listener) => listener(event));
|
|
40891
40932
|
const appPlugin = () => globalThis?.Capacitor?.Plugins?.AppNotifications;
|
|
40892
40933
|
const installNativeListener = () => {
|
|
40893
40934
|
if (nativeListenerInstalled) return;
|
|
40894
40935
|
const plugin = appPlugin();
|
|
40895
40936
|
if (!plugin?.addListener) return;
|
|
40896
40937
|
nativeListenerInstalled = true;
|
|
40897
|
-
|
|
40898
|
-
|
|
40899
|
-
|
|
40900
|
-
|
|
40901
|
-
|
|
40902
|
-
|
|
40938
|
+
plugin.addListener("notificationAction", (event) => {
|
|
40939
|
+
let data = event?.data || {};
|
|
40940
|
+
if (typeof data === "string") {
|
|
40941
|
+
try {
|
|
40942
|
+
data = JSON.parse(data);
|
|
40943
|
+
} catch {
|
|
40944
|
+
data = {};
|
|
40945
|
+
}
|
|
40903
40946
|
}
|
|
40904
|
-
|
|
40905
|
-
|
|
40906
|
-
|
|
40907
|
-
|
|
40908
|
-
|
|
40909
|
-
|
|
40910
|
-
|
|
40911
|
-
})
|
|
40947
|
+
emit2({
|
|
40948
|
+
id: event?.id,
|
|
40949
|
+
action: event?.action || "open",
|
|
40950
|
+
reply: event?.reply || "",
|
|
40951
|
+
data,
|
|
40952
|
+
platform: "capacitor"
|
|
40953
|
+
});
|
|
40954
|
+
});
|
|
40912
40955
|
plugin.consumePendingAction?.().catch?.(() => {
|
|
40913
40956
|
});
|
|
40914
40957
|
};
|
|
@@ -41003,6 +41046,47 @@ function createNotificationService() {
|
|
|
41003
41046
|
return { permission, requestPermission, show, schedule, cancel, cancelAll, onAction };
|
|
41004
41047
|
}
|
|
41005
41048
|
|
|
41049
|
+
// src/services/chatNotifications.js
|
|
41050
|
+
function createChatNotificationService(client) {
|
|
41051
|
+
const listeners2 = /* @__PURE__ */ new Set();
|
|
41052
|
+
const emit2 = (event) => listeners2.forEach((listener) => listener(event));
|
|
41053
|
+
const showMessage = async ({ sessionId, title = "New chat message", body = "", data = {} } = {}) => {
|
|
41054
|
+
if (!sessionId) return null;
|
|
41055
|
+
return client.notifications.show({
|
|
41056
|
+
id: `chat-message-${sessionId}-${Date.now()}`,
|
|
41057
|
+
title,
|
|
41058
|
+
body,
|
|
41059
|
+
data: { ...data, sessionId, kind: "chat_message" },
|
|
41060
|
+
channel: "chat_messages",
|
|
41061
|
+
actions: [
|
|
41062
|
+
{ id: "open", title: "Open chat" },
|
|
41063
|
+
{ id: "reply", title: "Reply", input: true }
|
|
41064
|
+
]
|
|
41065
|
+
});
|
|
41066
|
+
};
|
|
41067
|
+
const showStatus = async ({ sessionId, title = "Chat update", body = "", data = {} } = {}) => {
|
|
41068
|
+
if (!sessionId) return null;
|
|
41069
|
+
return client.notifications.show({
|
|
41070
|
+
id: `chat-status-${sessionId}-${Date.now()}`,
|
|
41071
|
+
title,
|
|
41072
|
+
body,
|
|
41073
|
+
data: { ...data, sessionId, kind: "chat_status" },
|
|
41074
|
+
channel: "chat_messages",
|
|
41075
|
+
actions: [{ id: "open", title: "Open chat" }]
|
|
41076
|
+
});
|
|
41077
|
+
};
|
|
41078
|
+
const onEvent = (listener) => {
|
|
41079
|
+
listeners2.add(listener);
|
|
41080
|
+
return () => listeners2.delete(listener);
|
|
41081
|
+
};
|
|
41082
|
+
client.notifications.onAction(({ action, data, reply }) => {
|
|
41083
|
+
if (data?.sessionId && ["chat_message", "chat_status"].includes(data.kind)) {
|
|
41084
|
+
emit2({ type: action === "reply" ? "reply" : action, action, sessionId: data.sessionId, reply: reply || "", data });
|
|
41085
|
+
}
|
|
41086
|
+
});
|
|
41087
|
+
return { showMessage, showStatus, onEvent };
|
|
41088
|
+
}
|
|
41089
|
+
|
|
41006
41090
|
// src/index.js
|
|
41007
41091
|
init_usePlatform();
|
|
41008
41092
|
|
|
@@ -41927,10 +42011,10 @@ function createOfflineManager(client) {
|
|
|
41927
42011
|
autoInterval = null;
|
|
41928
42012
|
}
|
|
41929
42013
|
}
|
|
41930
|
-
function emit2(
|
|
42014
|
+
function emit2(event, payload) {
|
|
41931
42015
|
try {
|
|
41932
|
-
if (!listeners2.has(
|
|
41933
|
-
for (const cb of listeners2.get(
|
|
42016
|
+
if (!listeners2.has(event)) return;
|
|
42017
|
+
for (const cb of listeners2.get(event)) {
|
|
41934
42018
|
try {
|
|
41935
42019
|
cb(payload);
|
|
41936
42020
|
} catch (e2) {
|
|
@@ -41950,14 +42034,14 @@ function createOfflineManager(client) {
|
|
|
41950
42034
|
stopAutoSync,
|
|
41951
42035
|
getQueue,
|
|
41952
42036
|
// events
|
|
41953
|
-
on: (
|
|
41954
|
-
if (!listeners2.has(
|
|
41955
|
-
listeners2.get(
|
|
41956
|
-
return () => listeners2.get(
|
|
42037
|
+
on: (event, cb) => {
|
|
42038
|
+
if (!listeners2.has(event)) listeners2.set(event, /* @__PURE__ */ new Set());
|
|
42039
|
+
listeners2.get(event).add(cb);
|
|
42040
|
+
return () => listeners2.get(event).delete(cb);
|
|
41957
42041
|
},
|
|
41958
|
-
off: (
|
|
41959
|
-
if (!listeners2.has(
|
|
41960
|
-
listeners2.get(
|
|
42042
|
+
off: (event, cb) => {
|
|
42043
|
+
if (!listeners2.has(event)) return;
|
|
42044
|
+
listeners2.get(event).delete(cb);
|
|
41961
42045
|
},
|
|
41962
42046
|
getPendingUploads: async () => {
|
|
41963
42047
|
const snapshot = await store.get("pending_uploads");
|
|
@@ -42124,6 +42208,7 @@ var TevrocClient = class {
|
|
|
42124
42208
|
this.commerce = createCommerceApi(this);
|
|
42125
42209
|
this.realtime = createRealtimeApi(this);
|
|
42126
42210
|
this.notifications = createNotificationService();
|
|
42211
|
+
this.chatNotifications = createChatNotificationService(this);
|
|
42127
42212
|
this.agentNotifications = createAgentNotificationService(this);
|
|
42128
42213
|
this.shiplogic = createShiplogicApi(this);
|
|
42129
42214
|
this.platform = createPlatformApi(this);
|
|
@@ -42270,27 +42355,27 @@ function createRealtimeApi(client) {
|
|
|
42270
42355
|
if (closedByUser) return;
|
|
42271
42356
|
debugError2(client, "[tevrocsdk] opening realtime socket", { room, roomName, url, appId: client.appId });
|
|
42272
42357
|
socket = new WebSocket(url);
|
|
42273
|
-
socket.addEventListener("open", (
|
|
42358
|
+
socket.addEventListener("open", (event) => {
|
|
42274
42359
|
reconnectCount = 0;
|
|
42275
42360
|
debugError2(client, "[tevrocsdk] realtime socket open", { room, roomName, readyState: socket.readyState, url });
|
|
42276
|
-
handlers.open?.(
|
|
42361
|
+
handlers.open?.(event);
|
|
42277
42362
|
while (pendingMessages.length && sendNow(pendingMessages[0])) {
|
|
42278
42363
|
pendingMessages.shift();
|
|
42279
42364
|
}
|
|
42280
42365
|
});
|
|
42281
|
-
socket.addEventListener("message", (
|
|
42282
|
-
let data =
|
|
42366
|
+
socket.addEventListener("message", (event) => {
|
|
42367
|
+
let data = event.data;
|
|
42283
42368
|
try {
|
|
42284
|
-
data = JSON.parse(
|
|
42369
|
+
data = JSON.parse(event.data);
|
|
42285
42370
|
} catch {
|
|
42286
42371
|
}
|
|
42287
42372
|
debugError2(client, "[tevrocsdk] realtime socket message", { room, roomName, data });
|
|
42288
|
-
handlers.message?.(data,
|
|
42373
|
+
handlers.message?.(data, event);
|
|
42289
42374
|
});
|
|
42290
|
-
socket.addEventListener("close", (
|
|
42291
|
-
debugLog2(client, "[tevrocsdk] realtime socket close", { room, roomName, code:
|
|
42292
|
-
handlers.close?.(
|
|
42293
|
-
const wasNeverOpen =
|
|
42375
|
+
socket.addEventListener("close", (event) => {
|
|
42376
|
+
debugLog2(client, "[tevrocsdk] realtime socket close", { room, roomName, code: event.code, reason: event.reason, wasClean: event.wasClean, url });
|
|
42377
|
+
handlers.close?.(event);
|
|
42378
|
+
const wasNeverOpen = event?.code === 1006 || socket?.readyState !== WebSocket.OPEN;
|
|
42294
42379
|
if (wasNeverOpen && !attemptedRawFallback && rawUrl && rawUrl !== url) {
|
|
42295
42380
|
attemptedRawFallback = true;
|
|
42296
42381
|
debugWarn2(client, "[tevrocsdk] realtime fallback to raw URL after failed encoded handshake", { encodedUrl: url, rawUrl });
|
|
@@ -42305,9 +42390,9 @@ function createRealtimeApi(client) {
|
|
|
42305
42390
|
openSocket();
|
|
42306
42391
|
}, reconnectMs);
|
|
42307
42392
|
});
|
|
42308
|
-
socket.addEventListener("error", (
|
|
42309
|
-
debugLog2(client, "[tevrocsdk] realtime socket error", { room, roomName, event
|
|
42310
|
-
handlers.error?.(
|
|
42393
|
+
socket.addEventListener("error", (event) => {
|
|
42394
|
+
debugLog2(client, "[tevrocsdk] realtime socket error", { room, roomName, event });
|
|
42395
|
+
handlers.error?.(event);
|
|
42311
42396
|
});
|
|
42312
42397
|
};
|
|
42313
42398
|
openSocket();
|