tevrocsdk 0.1.75 → 0.1.77

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/tevroc-sdk.umd.js CHANGED
@@ -354,8 +354,8 @@ var Tevroc = (() => {
354
354
  registered: false,
355
355
  windowEventName,
356
356
  pluginEventName,
357
- handler: (event2) => {
358
- this.notifyListeners(pluginEventName, event2);
357
+ handler: (event) => {
358
+ this.notifyListeners(pluginEventName, event);
359
359
  }
360
360
  };
361
361
  }
@@ -1102,41 +1102,41 @@ var Tevroc = (() => {
1102
1102
  listen: () => listen,
1103
1103
  once: () => once
1104
1104
  });
1105
- async function _unlisten(event2, eventId) {
1106
- window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(event2, eventId);
1105
+ async function _unlisten(event, eventId) {
1106
+ window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(event, eventId);
1107
1107
  await invoke("plugin:event|unlisten", {
1108
- event: event2,
1108
+ event,
1109
1109
  eventId
1110
1110
  });
1111
1111
  }
1112
- async function listen(event2, handler, options) {
1112
+ async function listen(event, handler, options) {
1113
1113
  var _a2;
1114
1114
  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" };
1115
1115
  return invoke("plugin:event|listen", {
1116
- event: event2,
1116
+ event,
1117
1117
  target,
1118
1118
  handler: transformCallback(handler)
1119
1119
  }).then((eventId) => {
1120
- return async () => _unlisten(event2, eventId);
1120
+ return async () => _unlisten(event, eventId);
1121
1121
  });
1122
1122
  }
1123
- async function once(event2, handler, options) {
1124
- return listen(event2, (eventData) => {
1125
- void _unlisten(event2, eventData.id);
1123
+ async function once(event, handler, options) {
1124
+ return listen(event, (eventData) => {
1125
+ void _unlisten(event, eventData.id);
1126
1126
  handler(eventData);
1127
1127
  }, options);
1128
1128
  }
1129
- async function emit(event2, payload) {
1129
+ async function emit(event, payload) {
1130
1130
  await invoke("plugin:event|emit", {
1131
- event: event2,
1131
+ event,
1132
1132
  payload
1133
1133
  });
1134
1134
  }
1135
- async function emitTo(target, event2, payload) {
1135
+ async function emitTo(target, event, payload) {
1136
1136
  const eventTarget = typeof target === "string" ? { kind: "AnyLabel", label: target } : target;
1137
1137
  await invoke("plugin:event|emit_to", {
1138
1138
  target: eventTarget,
1139
- event: event2,
1139
+ event,
1140
1140
  payload
1141
1141
  });
1142
1142
  }
@@ -1264,10 +1264,10 @@ var Tevroc = (() => {
1264
1264
  UserAttentionType2[UserAttentionType2["Informational"] = 2] = "Informational";
1265
1265
  })(UserAttentionType || (UserAttentionType = {}));
1266
1266
  CloseRequestedEvent = class {
1267
- constructor(event2) {
1267
+ constructor(event) {
1268
1268
  this._preventDefault = false;
1269
- this.event = event2.event;
1270
- this.id = event2.id;
1269
+ this.event = event.event;
1270
+ this.id = event.id;
1271
1271
  }
1272
1272
  preventDefault() {
1273
1273
  this._preventDefault = true;
@@ -1380,14 +1380,14 @@ var Tevroc = (() => {
1380
1380
  * @returns A promise resolving to a function to unlisten to the event.
1381
1381
  * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
1382
1382
  */
1383
- async listen(event2, handler) {
1384
- if (this._handleTauriEvent(event2, handler)) {
1383
+ async listen(event, handler) {
1384
+ if (this._handleTauriEvent(event, handler)) {
1385
1385
  return () => {
1386
- const listeners2 = this.listeners[event2];
1386
+ const listeners2 = this.listeners[event];
1387
1387
  listeners2.splice(listeners2.indexOf(handler), 1);
1388
1388
  };
1389
1389
  }
1390
- return listen(event2, handler, {
1390
+ return listen(event, handler, {
1391
1391
  target: { kind: "Window", label: this.label }
1392
1392
  });
1393
1393
  }
@@ -1410,14 +1410,14 @@ var Tevroc = (() => {
1410
1410
  * @returns A promise resolving to a function to unlisten to the event.
1411
1411
  * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
1412
1412
  */
1413
- async once(event2, handler) {
1414
- if (this._handleTauriEvent(event2, handler)) {
1413
+ async once(event, handler) {
1414
+ if (this._handleTauriEvent(event, handler)) {
1415
1415
  return () => {
1416
- const listeners2 = this.listeners[event2];
1416
+ const listeners2 = this.listeners[event];
1417
1417
  listeners2.splice(listeners2.indexOf(handler), 1);
1418
1418
  };
1419
1419
  }
1420
- return once(event2, handler, {
1420
+ return once(event, handler, {
1421
1421
  target: { kind: "Window", label: this.label }
1422
1422
  });
1423
1423
  }
@@ -1432,18 +1432,18 @@ var Tevroc = (() => {
1432
1432
  * @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
1433
1433
  * @param payload Event payload.
1434
1434
  */
1435
- async emit(event2, payload) {
1436
- if (localTauriEvents.includes(event2)) {
1437
- for (const handler of this.listeners[event2] || []) {
1435
+ async emit(event, payload) {
1436
+ if (localTauriEvents.includes(event)) {
1437
+ for (const handler of this.listeners[event] || []) {
1438
1438
  handler({
1439
- event: event2,
1439
+ event,
1440
1440
  id: -1,
1441
1441
  payload
1442
1442
  });
1443
1443
  }
1444
1444
  return;
1445
1445
  }
1446
- return emit(event2, payload);
1446
+ return emit(event, payload);
1447
1447
  }
1448
1448
  /**
1449
1449
  * Emits an event to all {@link EventTarget|targets} matching the given target.
@@ -1457,26 +1457,26 @@ var Tevroc = (() => {
1457
1457
  * @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
1458
1458
  * @param payload Event payload.
1459
1459
  */
1460
- async emitTo(target, event2, payload) {
1461
- if (localTauriEvents.includes(event2)) {
1462
- for (const handler of this.listeners[event2] || []) {
1460
+ async emitTo(target, event, payload) {
1461
+ if (localTauriEvents.includes(event)) {
1462
+ for (const handler of this.listeners[event] || []) {
1463
1463
  handler({
1464
- event: event2,
1464
+ event,
1465
1465
  id: -1,
1466
1466
  payload
1467
1467
  });
1468
1468
  }
1469
1469
  return;
1470
1470
  }
1471
- return emitTo(target, event2, payload);
1471
+ return emitTo(target, event, payload);
1472
1472
  }
1473
1473
  /** @ignore */
1474
- _handleTauriEvent(event2, handler) {
1475
- if (localTauriEvents.includes(event2)) {
1476
- if (!(event2 in this.listeners)) {
1477
- this.listeners[event2] = [handler];
1474
+ _handleTauriEvent(event, handler) {
1475
+ if (localTauriEvents.includes(event)) {
1476
+ if (!(event in this.listeners)) {
1477
+ this.listeners[event] = [handler];
1478
1478
  } else {
1479
- this.listeners[event2].push(handler);
1479
+ this.listeners[event].push(handler);
1480
1480
  }
1481
1481
  return true;
1482
1482
  }
@@ -2771,8 +2771,8 @@ var Tevroc = (() => {
2771
2771
  * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
2772
2772
  */
2773
2773
  async onCloseRequested(handler) {
2774
- return this.listen(TauriEvent.WINDOW_CLOSE_REQUESTED, async (event2) => {
2775
- const evt = new CloseRequestedEvent(event2);
2774
+ return this.listen(TauriEvent.WINDOW_CLOSE_REQUESTED, async (event) => {
2775
+ const evt = new CloseRequestedEvent(event);
2776
2776
  await handler(evt);
2777
2777
  if (!evt.isPreventDefault()) {
2778
2778
  await this.destroy();
@@ -2805,37 +2805,37 @@ var Tevroc = (() => {
2805
2805
  * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
2806
2806
  */
2807
2807
  async onDragDropEvent(handler) {
2808
- const unlistenDrag = await this.listen(TauriEvent.DRAG_ENTER, (event2) => {
2808
+ const unlistenDrag = await this.listen(TauriEvent.DRAG_ENTER, (event) => {
2809
2809
  handler({
2810
- ...event2,
2810
+ ...event,
2811
2811
  payload: {
2812
2812
  type: "enter",
2813
- paths: event2.payload.paths,
2814
- position: new PhysicalPosition(event2.payload.position)
2813
+ paths: event.payload.paths,
2814
+ position: new PhysicalPosition(event.payload.position)
2815
2815
  }
2816
2816
  });
2817
2817
  });
2818
- const unlistenDragOver = await this.listen(TauriEvent.DRAG_OVER, (event2) => {
2818
+ const unlistenDragOver = await this.listen(TauriEvent.DRAG_OVER, (event) => {
2819
2819
  handler({
2820
- ...event2,
2820
+ ...event,
2821
2821
  payload: {
2822
2822
  type: "over",
2823
- position: new PhysicalPosition(event2.payload.position)
2823
+ position: new PhysicalPosition(event.payload.position)
2824
2824
  }
2825
2825
  });
2826
2826
  });
2827
- const unlistenDrop = await this.listen(TauriEvent.DRAG_DROP, (event2) => {
2827
+ const unlistenDrop = await this.listen(TauriEvent.DRAG_DROP, (event) => {
2828
2828
  handler({
2829
- ...event2,
2829
+ ...event,
2830
2830
  payload: {
2831
2831
  type: "drop",
2832
- paths: event2.payload.paths,
2833
- position: new PhysicalPosition(event2.payload.position)
2832
+ paths: event.payload.paths,
2833
+ position: new PhysicalPosition(event.payload.position)
2834
2834
  }
2835
2835
  });
2836
2836
  });
2837
- const unlistenCancel = await this.listen(TauriEvent.DRAG_LEAVE, (event2) => {
2838
- handler({ ...event2, payload: { type: "leave" } });
2837
+ const unlistenCancel = await this.listen(TauriEvent.DRAG_LEAVE, (event) => {
2838
+ handler({ ...event, payload: { type: "leave" } });
2839
2839
  });
2840
2840
  return () => {
2841
2841
  unlistenDrag();
@@ -2862,11 +2862,11 @@ var Tevroc = (() => {
2862
2862
  * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
2863
2863
  */
2864
2864
  async onFocusChanged(handler) {
2865
- const unlistenFocus = await this.listen(TauriEvent.WINDOW_FOCUS, (event2) => {
2866
- handler({ ...event2, payload: true });
2865
+ const unlistenFocus = await this.listen(TauriEvent.WINDOW_FOCUS, (event) => {
2866
+ handler({ ...event, payload: true });
2867
2867
  });
2868
- const unlistenBlur = await this.listen(TauriEvent.WINDOW_BLUR, (event2) => {
2869
- handler({ ...event2, payload: false });
2868
+ const unlistenBlur = await this.listen(TauriEvent.WINDOW_BLUR, (event) => {
2869
+ handler({ ...event, payload: false });
2870
2870
  });
2871
2871
  return () => {
2872
2872
  unlistenFocus();
@@ -3079,14 +3079,14 @@ var Tevroc = (() => {
3079
3079
  * @returns A promise resolving to a function to unlisten to the event.
3080
3080
  * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
3081
3081
  */
3082
- async listen(event2, handler) {
3083
- if (this._handleTauriEvent(event2, handler)) {
3082
+ async listen(event, handler) {
3083
+ if (this._handleTauriEvent(event, handler)) {
3084
3084
  return () => {
3085
- const listeners2 = this.listeners[event2];
3085
+ const listeners2 = this.listeners[event];
3086
3086
  listeners2.splice(listeners2.indexOf(handler), 1);
3087
3087
  };
3088
3088
  }
3089
- return listen(event2, handler, {
3089
+ return listen(event, handler, {
3090
3090
  target: { kind: "Webview", label: this.label }
3091
3091
  });
3092
3092
  }
@@ -3109,14 +3109,14 @@ var Tevroc = (() => {
3109
3109
  * @returns A promise resolving to a function to unlisten to the event.
3110
3110
  * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
3111
3111
  */
3112
- async once(event2, handler) {
3113
- if (this._handleTauriEvent(event2, handler)) {
3112
+ async once(event, handler) {
3113
+ if (this._handleTauriEvent(event, handler)) {
3114
3114
  return () => {
3115
- const listeners2 = this.listeners[event2];
3115
+ const listeners2 = this.listeners[event];
3116
3116
  listeners2.splice(listeners2.indexOf(handler), 1);
3117
3117
  };
3118
3118
  }
3119
- return once(event2, handler, {
3119
+ return once(event, handler, {
3120
3120
  target: { kind: "Webview", label: this.label }
3121
3121
  });
3122
3122
  }
@@ -3132,18 +3132,18 @@ var Tevroc = (() => {
3132
3132
  * @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
3133
3133
  * @param payload Event payload.
3134
3134
  */
3135
- async emit(event2, payload) {
3136
- if (localTauriEvents2.includes(event2)) {
3137
- for (const handler of this.listeners[event2] || []) {
3135
+ async emit(event, payload) {
3136
+ if (localTauriEvents2.includes(event)) {
3137
+ for (const handler of this.listeners[event] || []) {
3138
3138
  handler({
3139
- event: event2,
3139
+ event,
3140
3140
  id: -1,
3141
3141
  payload
3142
3142
  });
3143
3143
  }
3144
3144
  return;
3145
3145
  }
3146
- return emit(event2, payload);
3146
+ return emit(event, payload);
3147
3147
  }
3148
3148
  /**
3149
3149
  * Emits an event to all {@link EventTarget|targets} matching the given target.
@@ -3158,26 +3158,26 @@ var Tevroc = (() => {
3158
3158
  * @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
3159
3159
  * @param payload Event payload.
3160
3160
  */
3161
- async emitTo(target, event2, payload) {
3162
- if (localTauriEvents2.includes(event2)) {
3163
- for (const handler of this.listeners[event2] || []) {
3161
+ async emitTo(target, event, payload) {
3162
+ if (localTauriEvents2.includes(event)) {
3163
+ for (const handler of this.listeners[event] || []) {
3164
3164
  handler({
3165
- event: event2,
3165
+ event,
3166
3166
  id: -1,
3167
3167
  payload
3168
3168
  });
3169
3169
  }
3170
3170
  return;
3171
3171
  }
3172
- return emitTo(target, event2, payload);
3172
+ return emitTo(target, event, payload);
3173
3173
  }
3174
3174
  /** @ignore */
3175
- _handleTauriEvent(event2, handler) {
3176
- if (localTauriEvents2.includes(event2)) {
3177
- if (!(event2 in this.listeners)) {
3178
- this.listeners[event2] = [handler];
3175
+ _handleTauriEvent(event, handler) {
3176
+ if (localTauriEvents2.includes(event)) {
3177
+ if (!(event in this.listeners)) {
3178
+ this.listeners[event] = [handler];
3179
3179
  } else {
3180
- this.listeners[event2].push(handler);
3180
+ this.listeners[event].push(handler);
3181
3181
  }
3182
3182
  return true;
3183
3183
  }
@@ -3418,37 +3418,37 @@ var Tevroc = (() => {
3418
3418
  * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
3419
3419
  */
3420
3420
  async onDragDropEvent(handler) {
3421
- const unlistenDragEnter = await this.listen(TauriEvent.DRAG_ENTER, (event2) => {
3421
+ const unlistenDragEnter = await this.listen(TauriEvent.DRAG_ENTER, (event) => {
3422
3422
  handler({
3423
- ...event2,
3423
+ ...event,
3424
3424
  payload: {
3425
3425
  type: "enter",
3426
- paths: event2.payload.paths,
3427
- position: new PhysicalPosition(event2.payload.position)
3426
+ paths: event.payload.paths,
3427
+ position: new PhysicalPosition(event.payload.position)
3428
3428
  }
3429
3429
  });
3430
3430
  });
3431
- const unlistenDragOver = await this.listen(TauriEvent.DRAG_OVER, (event2) => {
3431
+ const unlistenDragOver = await this.listen(TauriEvent.DRAG_OVER, (event) => {
3432
3432
  handler({
3433
- ...event2,
3433
+ ...event,
3434
3434
  payload: {
3435
3435
  type: "over",
3436
- position: new PhysicalPosition(event2.payload.position)
3436
+ position: new PhysicalPosition(event.payload.position)
3437
3437
  }
3438
3438
  });
3439
3439
  });
3440
- const unlistenDragDrop = await this.listen(TauriEvent.DRAG_DROP, (event2) => {
3440
+ const unlistenDragDrop = await this.listen(TauriEvent.DRAG_DROP, (event) => {
3441
3441
  handler({
3442
- ...event2,
3442
+ ...event,
3443
3443
  payload: {
3444
3444
  type: "drop",
3445
- paths: event2.payload.paths,
3446
- position: new PhysicalPosition(event2.payload.position)
3445
+ paths: event.payload.paths,
3446
+ position: new PhysicalPosition(event.payload.position)
3447
3447
  }
3448
3448
  });
3449
3449
  });
3450
- const unlistenDragLeave = await this.listen(TauriEvent.DRAG_LEAVE, (event2) => {
3451
- handler({ ...event2, payload: { type: "leave" } });
3450
+ const unlistenDragLeave = await this.listen(TauriEvent.DRAG_LEAVE, (event) => {
3451
+ handler({ ...event, payload: { type: "leave" } });
3452
3452
  });
3453
3453
  return () => {
3454
3454
  unlistenDragEnter();
@@ -3584,14 +3584,14 @@ var Tevroc = (() => {
3584
3584
  * @returns A promise resolving to a function to unlisten to the event.
3585
3585
  * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
3586
3586
  */
3587
- async listen(event2, handler) {
3588
- if (this._handleTauriEvent(event2, handler)) {
3587
+ async listen(event, handler) {
3588
+ if (this._handleTauriEvent(event, handler)) {
3589
3589
  return () => {
3590
- const listeners2 = this.listeners[event2];
3590
+ const listeners2 = this.listeners[event];
3591
3591
  listeners2.splice(listeners2.indexOf(handler), 1);
3592
3592
  };
3593
3593
  }
3594
- return listen(event2, handler, {
3594
+ return listen(event, handler, {
3595
3595
  target: { kind: "WebviewWindow", label: this.label }
3596
3596
  });
3597
3597
  }
@@ -3614,14 +3614,14 @@ var Tevroc = (() => {
3614
3614
  * @returns A promise resolving to a function to unlisten to the event.
3615
3615
  * Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
3616
3616
  */
3617
- async once(event2, handler) {
3618
- if (this._handleTauriEvent(event2, handler)) {
3617
+ async once(event, handler) {
3618
+ if (this._handleTauriEvent(event, handler)) {
3619
3619
  return () => {
3620
- const listeners2 = this.listeners[event2];
3620
+ const listeners2 = this.listeners[event];
3621
3621
  listeners2.splice(listeners2.indexOf(handler), 1);
3622
3622
  };
3623
3623
  }
3624
- return once(event2, handler, {
3624
+ return once(event, handler, {
3625
3625
  target: { kind: "WebviewWindow", label: this.label }
3626
3626
  });
3627
3627
  }
@@ -3799,14 +3799,14 @@ var Tevroc = (() => {
3799
3799
  googleInitialized = true;
3800
3800
  if (isCapacitor) {
3801
3801
  const { App: App2 } = await getCapacitorPlugins();
3802
- App2.addListener("appUrlOpen", (event2) => {
3803
- handleCallback(event2.url);
3802
+ App2.addListener("appUrlOpen", (event) => {
3803
+ handleCallback(event.url);
3804
3804
  });
3805
3805
  }
3806
3806
  if (isTauri) {
3807
3807
  const { listen: listen2 } = await Promise.resolve().then(() => (init_event(), event_exports));
3808
- await listen2("deep-link://open-url", async (event2) => {
3809
- let url = event2.payload;
3808
+ await listen2("deep-link://open-url", async (event) => {
3809
+ let url = event.payload;
3810
3810
  if (typeof url === "object") {
3811
3811
  url = url?.url || url?.payload || null;
3812
3812
  }
@@ -3866,11 +3866,11 @@ var Tevroc = (() => {
3866
3866
  debugError("Popup blocked");
3867
3867
  }
3868
3868
  authWindowRef = popup;
3869
- authMessageListener = async (event2) => {
3869
+ authMessageListener = async (event) => {
3870
3870
  const serviceOrigin = new URL(serviceUrl).origin;
3871
- if (event2.origin !== serviceOrigin) return;
3872
- if (event2.data?.type === "google-auth") {
3873
- const token = event2.data?.token || null;
3871
+ if (event.origin !== serviceOrigin) return;
3872
+ if (event.data?.type === "google-auth") {
3873
+ const token = event.data?.token || null;
3874
3874
  const url = token ? `${window.location.href}${window.location.href.includes("?") ? "&" : "?"}token=${token}` : window.location.href;
3875
3875
  await handleCallback(url);
3876
3876
  }
@@ -3959,17 +3959,17 @@ var Tevroc = (() => {
3959
3959
  paymentInitialized = true;
3960
3960
  if (isCapacitor) {
3961
3961
  const { App: App2 } = await getCapacitorPlugins2();
3962
- App2.addListener("appUrlOpen", (event2) => {
3962
+ App2.addListener("appUrlOpen", (event) => {
3963
3963
  handlePaymentCallback(
3964
- event2.url,
3964
+ event.url,
3965
3965
  externalCallback
3966
3966
  );
3967
3967
  });
3968
3968
  }
3969
3969
  if (isTauri) {
3970
3970
  const { listen: listen2 } = await Promise.resolve().then(() => (init_event(), event_exports));
3971
- await listen2("deep-link://open-url", async (event2) => {
3972
- let url = event2.payload;
3971
+ await listen2("deep-link://open-url", async (event) => {
3972
+ let url = event.payload;
3973
3973
  if (typeof url === "object") {
3974
3974
  url = url?.url || url?.payload || null;
3975
3975
  }
@@ -4038,12 +4038,12 @@ var Tevroc = (() => {
4038
4038
  }
4039
4039
  let listenerAttached = true;
4040
4040
  let timerRunning = true;
4041
- const listener = (event2) => {
4041
+ const listener = (event) => {
4042
4042
  try {
4043
4043
  const serviceOrigin = new URL(serviceUrl).origin;
4044
- if (event2.origin !== serviceOrigin) return;
4045
- if (event2.data?.type === "payment-result") {
4046
- const status = event2.data?.status || null;
4044
+ if (event.origin !== serviceOrigin) return;
4045
+ if (event.data?.type === "payment-result") {
4046
+ const status = event.data?.status || null;
4047
4047
  listenerAttached = false;
4048
4048
  timerRunning = false;
4049
4049
  window.removeEventListener("message", listener);
@@ -14930,8 +14930,8 @@ var Tevroc = (() => {
14930
14930
  run(id);
14931
14931
  };
14932
14932
  };
14933
- var eventListener = function(event2) {
14934
- run(event2.data);
14933
+ var eventListener = function(event) {
14934
+ run(event.data);
14935
14935
  };
14936
14936
  var globalPostMessageDefer = function(id) {
14937
14937
  globalThis2.postMessage(String2(id), $location.protocol + "//" + $location.host);
@@ -15330,15 +15330,15 @@ var Tevroc = (() => {
15330
15330
  });
15331
15331
  };
15332
15332
  var dispatchEvent = function(name, promise, reason) {
15333
- var event2, handler;
15333
+ var event, handler;
15334
15334
  if (DISPATCH_EVENT) {
15335
- event2 = document2.createEvent("Event");
15336
- event2.promise = promise;
15337
- event2.reason = reason;
15338
- event2.initEvent(name, false, true);
15339
- globalThis2.dispatchEvent(event2);
15340
- } else event2 = { promise, reason };
15341
- if (!NATIVE_PROMISE_REJECTION_EVENT && (handler = globalThis2["on" + name])) handler(event2);
15335
+ event = document2.createEvent("Event");
15336
+ event.promise = promise;
15337
+ event.reason = reason;
15338
+ event.initEvent(name, false, true);
15339
+ globalThis2.dispatchEvent(event);
15340
+ } else event = { promise, reason };
15341
+ if (!NATIVE_PROMISE_REJECTION_EVENT && (handler = globalThis2["on" + name])) handler(event);
15342
15342
  else if (name === UNHANDLED_REJECTION) hostReportErrors("Unhandled promise rejection", reason);
15343
15343
  };
15344
15344
  var onUnhandled = function(state) {
@@ -19395,11 +19395,11 @@ var Tevroc = (() => {
19395
19395
  }
19396
19396
  return point;
19397
19397
  }
19398
- onClick(event2) {
19398
+ onClick(event) {
19399
19399
  var {
19400
19400
  x: x3,
19401
19401
  y: y3
19402
- } = this.mapXY(event2.clientX, event2.clientY);
19402
+ } = this.mapXY(event.clientX, event.clientY);
19403
19403
  this.events.push({
19404
19404
  type: "onclick",
19405
19405
  x: x3,
@@ -19411,11 +19411,11 @@ var Tevroc = (() => {
19411
19411
  }
19412
19412
  });
19413
19413
  }
19414
- onMouseMove(event2) {
19414
+ onMouseMove(event) {
19415
19415
  var {
19416
19416
  x: x3,
19417
19417
  y: y3
19418
- } = this.mapXY(event2.clientX, event2.clientY);
19418
+ } = this.mapXY(event.clientX, event.clientY);
19419
19419
  this.events.push({
19420
19420
  type: "onmousemove",
19421
19421
  x: x3,
@@ -24032,10 +24032,10 @@ var Tevroc = (() => {
24032
24032
  };
24033
24033
  });
24034
24034
  }
24035
- static doUpgrade(event2) {
24036
- const eventTarget = event2.target;
24035
+ static doUpgrade(event) {
24036
+ const eventTarget = event.target;
24037
24037
  const db = eventTarget.result;
24038
- switch (event2.oldVersion) {
24038
+ switch (event.oldVersion) {
24039
24039
  case 0:
24040
24040
  case 1:
24041
24041
  default: {
@@ -26208,20 +26208,20 @@ var Tevroc = (() => {
26208
26208
  await customElements.whenDefined("jeep-sqlite");
26209
26209
  this.jeepSqliteElement = document.querySelector("jeep-sqlite");
26210
26210
  this.ensureJeepSqliteIsAvailable();
26211
- this.jeepSqliteElement.addEventListener("jeepSqliteImportProgress", (event2) => {
26212
- this.notifyListeners("sqliteImportProgressEvent", event2.detail);
26211
+ this.jeepSqliteElement.addEventListener("jeepSqliteImportProgress", (event) => {
26212
+ this.notifyListeners("sqliteImportProgressEvent", event.detail);
26213
26213
  });
26214
- this.jeepSqliteElement.addEventListener("jeepSqliteExportProgress", (event2) => {
26215
- this.notifyListeners("sqliteExportProgressEvent", event2.detail);
26214
+ this.jeepSqliteElement.addEventListener("jeepSqliteExportProgress", (event) => {
26215
+ this.notifyListeners("sqliteExportProgressEvent", event.detail);
26216
26216
  });
26217
- this.jeepSqliteElement.addEventListener("jeepSqliteHTTPRequestEnded", (event2) => {
26218
- this.notifyListeners("sqliteHTTPRequestEndedEvent", event2.detail);
26217
+ this.jeepSqliteElement.addEventListener("jeepSqliteHTTPRequestEnded", (event) => {
26218
+ this.notifyListeners("sqliteHTTPRequestEndedEvent", event.detail);
26219
26219
  });
26220
- this.jeepSqliteElement.addEventListener("jeepSqlitePickDatabaseEnded", (event2) => {
26221
- this.notifyListeners("sqlitePickDatabaseEndedEvent", event2.detail);
26220
+ this.jeepSqliteElement.addEventListener("jeepSqlitePickDatabaseEnded", (event) => {
26221
+ this.notifyListeners("sqlitePickDatabaseEndedEvent", event.detail);
26222
26222
  });
26223
- this.jeepSqliteElement.addEventListener("jeepSqliteSaveDatabaseToDisk", (event2) => {
26224
- this.notifyListeners("sqliteSaveDatabaseToDiskEvent", event2.detail);
26223
+ this.jeepSqliteElement.addEventListener("jeepSqliteSaveDatabaseToDisk", (event) => {
26224
+ this.notifyListeners("sqliteSaveDatabaseToDiskEvent", event.detail);
26225
26225
  });
26226
26226
  if (!this.isWebStoreOpen) {
26227
26227
  this.isWebStoreOpen = await this.jeepSqliteElement.isStoreOpen();
@@ -40785,17 +40785,35 @@ var Tevroc = (() => {
40785
40785
  let stopped = true;
40786
40786
  const seen = /* @__PURE__ */ new Map();
40787
40787
  const listeners2 = /* @__PURE__ */ new Set();
40788
- const notify = (event2) => listeners2.forEach((listener) => listener(event2));
40788
+ const notify = (event) => listeners2.forEach((listener) => listener(event));
40789
40789
  const getSessionId = (session) => session.sessionId || session.session_id || session.id;
40790
40790
  const getMessages = async (sessionId, appId) => {
40791
- const result = await client.entities.ChatMessage.query({ filter: { appId, sessionId }, limit: 100 });
40792
- return toList(result);
40791
+ const [bySessionId, byLegacySessionId] = await Promise.all([
40792
+ client.entities.ChatMessage.query({ filter: { appId, sessionId }, limit: 100 }),
40793
+ client.entities.ChatMessage.query({ filter: { appId, session_id: sessionId }, limit: 100 })
40794
+ ]);
40795
+ const seenMessages = /* @__PURE__ */ new Set();
40796
+ return [...toList(bySessionId), ...toList(byLegacySessionId)].filter((message2) => {
40797
+ const key = message2?.id || `${message2?.createdAt || ""}:${message2?.content || ""}`;
40798
+ if (seenMessages.has(key)) return false;
40799
+ seenMessages.add(key);
40800
+ return true;
40801
+ });
40793
40802
  };
40794
40803
  const publish = (sessionId, payload) => {
40795
40804
  const connection = client.realtime.room(sessionId, {}, { maxReconnects: 2 });
40796
40805
  connection.publish({ type: "chat_message", sessionId, session_id: sessionId, message: payload, payload });
40797
40806
  setTimeout(() => connection.close(), 1e3);
40798
40807
  };
40808
+ const publishStatus = (sessionId, status, session) => publish(sessionId, {
40809
+ id: `status_${status}_${Date.now()}`,
40810
+ type: "chat_status",
40811
+ status,
40812
+ sessionId,
40813
+ session_id: sessionId,
40814
+ visitor_name: session?.visitor_name || "",
40815
+ createdAt: Date.now()
40816
+ });
40799
40817
  const accept = async (session) => {
40800
40818
  const sessionId = getSessionId(session);
40801
40819
  await client.entities.ChatSession.update(session.id, {
@@ -40803,11 +40821,13 @@ var Tevroc = (() => {
40803
40821
  agent_email: client.agentIdentity || "agent",
40804
40822
  updatedAt: Date.now()
40805
40823
  });
40824
+ publishStatus(sessionId, "agent_active", session);
40806
40825
  notify({ type: "accepted", sessionId, session });
40807
40826
  };
40808
40827
  const reject = async (session) => {
40809
40828
  const sessionId = getSessionId(session);
40810
40829
  await client.entities.ChatSession.update(session.id, { status: "agent_rejected", updatedAt: Date.now() });
40830
+ publishStatus(sessionId, "agent_rejected", session);
40811
40831
  notify({ type: "rejected", sessionId, session });
40812
40832
  };
40813
40833
  const reply = async (session, content) => {
@@ -40830,8 +40850,11 @@ var Tevroc = (() => {
40830
40850
  };
40831
40851
  const dispatchAction = async ({ action, sessionId, reply: text2 }) => {
40832
40852
  const appId = client.appId;
40833
- const sessions = toList(await client.entities.ChatSession.query({ filter: { appId, sessionId }, limit: 1 }));
40834
- const session = sessions[0];
40853
+ const [bySessionId, byLegacySessionId] = await Promise.all([
40854
+ client.entities.ChatSession.query({ filter: { appId, sessionId }, limit: 1 }),
40855
+ client.entities.ChatSession.query({ filter: { appId, session_id: sessionId }, limit: 1 })
40856
+ ]);
40857
+ const session = toList(bySessionId)[0] || toList(byLegacySessionId)[0];
40835
40858
  if (!session) return;
40836
40859
  if (action === "open") return notify({ type: "open", sessionId, session });
40837
40860
  if (action === "accept") return accept(session);
@@ -40842,15 +40865,19 @@ var Tevroc = (() => {
40842
40865
  id: `agent-request-${request.sessionId}`,
40843
40866
  title: request.title,
40844
40867
  body: request.body,
40845
- data: { sessionId: request.sessionId },
40868
+ data: { sessionId: request.sessionId, kind: request.kind || "agent_request" },
40846
40869
  channel: "agent_requests",
40870
+ style: request.style,
40847
40871
  actions: [
40848
- { id: "accept", title: "Accept" },
40849
- { id: "reject", title: "Reject" },
40872
+ ...request.kind === "agent_message" ? [] : [
40873
+ { id: "accept", title: "Accept" },
40874
+ { id: "reject", title: "Reject" }
40875
+ ],
40876
+ { id: "open", title: "Open" },
40850
40877
  { id: "reply", title: "Reply", input: true }
40851
40878
  ]
40852
40879
  });
40853
- const check = async ({ appId = client.appId } = {}) => {
40880
+ const check = async ({ appId = client.appId, notificationStyle } = {}) => {
40854
40881
  const sessions = toList(await client.entities.ChatSession.query({ filter: { appId, status: "escalated" }, limit: 100 }));
40855
40882
  for (const session of sessions) {
40856
40883
  const sessionId = getSessionId(session);
@@ -40861,17 +40888,44 @@ var Tevroc = (() => {
40861
40888
  seen.set(sessionId, fingerprint);
40862
40889
  const request = {
40863
40890
  sessionId,
40891
+ kind: "agent_request",
40864
40892
  title: `Support request from ${session.visitor_name || "a visitor"}`,
40865
40893
  body: latest?.content || "A visitor is requesting a human agent.",
40866
40894
  latestMessage: latest,
40867
- session
40895
+ session,
40896
+ style: notificationStyle
40868
40897
  };
40869
40898
  await showNative(request);
40870
40899
  notify({ type: "request", ...request });
40871
40900
  }
40901
+ if (client.agentIdentity) {
40902
+ const active = toList(await client.entities.ChatSession.query({ filter: { appId, status: "agent_active", agent_email: client.agentIdentity }, limit: 100 }));
40903
+ for (const session of active) {
40904
+ const sessionId = getSessionId(session);
40905
+ if (!sessionId) continue;
40906
+ const messages2 = await getMessages(sessionId, appId);
40907
+ const latestVisitor = latestByTime(messages2.filter((message2) => message2?.role === "visitor" || message2?.role === "user"));
40908
+ if (!latestVisitor) continue;
40909
+ const fingerprint = `message:${latestVisitor.id || latestVisitor.createdAt || latestVisitor.content}`;
40910
+ if (seen.get(`message:${sessionId}`) === fingerprint) continue;
40911
+ seen.set(`message:${sessionId}`, fingerprint);
40912
+ const request = {
40913
+ sessionId,
40914
+ kind: "agent_message",
40915
+ title: `New message from ${session.visitor_name || "visitor"}`,
40916
+ body: latestVisitor.content || "The visitor sent an attachment.",
40917
+ latestMessage: latestVisitor,
40918
+ session,
40919
+ style: notificationStyle
40920
+ };
40921
+ await showNative(request);
40922
+ notify({ type: "message", ...request });
40923
+ }
40924
+ }
40872
40925
  };
40873
40926
  const start = async ({ pollMs = 8e3, agentIdentity, ...options } = {}) => {
40874
40927
  if (agentIdentity) client.agentIdentity = agentIdentity;
40928
+ if (options.appId) client.appId = options.appId;
40875
40929
  stopped = false;
40876
40930
  await check(options);
40877
40931
  clearInterval(timer);
@@ -40887,7 +40941,9 @@ var Tevroc = (() => {
40887
40941
  return () => listeners2.delete(listener);
40888
40942
  };
40889
40943
  client.notifications.onAction(({ action, data, reply: text2 }) => {
40890
- if (data?.sessionId) dispatchAction({ action, sessionId: data.sessionId, reply: text2 }).catch((error) => notify({ type: "error", error }));
40944
+ if (data?.sessionId && String(data.kind || "").startsWith("agent_")) {
40945
+ dispatchAction({ action, sessionId: data.sessionId, reply: text2 }).catch((error) => notify({ type: "error", error }));
40946
+ }
40891
40947
  });
40892
40948
  return { start, stop, check, onEvent, accept, reject, reply, dispatchAction };
40893
40949
  }
@@ -40898,28 +40954,30 @@ var Tevroc = (() => {
40898
40954
  const listeners2 = /* @__PURE__ */ new Set();
40899
40955
  const scheduled = /* @__PURE__ */ new Map();
40900
40956
  let nativeListenerInstalled = false;
40901
- const emit2 = (event2) => listeners2.forEach((listener) => listener(event2));
40957
+ const emit2 = (event) => listeners2.forEach((listener) => listener(event));
40902
40958
  const appPlugin = () => globalThis?.Capacitor?.Plugins?.AppNotifications;
40903
40959
  const installNativeListener = () => {
40904
40960
  if (nativeListenerInstalled) return;
40905
40961
  const plugin = appPlugin();
40906
40962
  if (!plugin?.addListener) return;
40907
40963
  nativeListenerInstalled = true;
40908
- let data = event.data || {};
40909
- if (typeof data === "string") {
40910
- try {
40911
- data = JSON.parse(data);
40912
- } catch {
40913
- data = {};
40964
+ plugin.addListener("notificationAction", (event) => {
40965
+ let data = event?.data || {};
40966
+ if (typeof data === "string") {
40967
+ try {
40968
+ data = JSON.parse(data);
40969
+ } catch {
40970
+ data = {};
40971
+ }
40914
40972
  }
40915
- }
40916
- plugin.addListener("notificationAction", (event2) => emit2({
40917
- id: event2.id,
40918
- action: event2.action || "open",
40919
- reply: event2.reply || "",
40920
- data,
40921
- platform: "capacitor"
40922
- }));
40973
+ emit2({
40974
+ id: event?.id,
40975
+ action: event?.action || "open",
40976
+ reply: event?.reply || "",
40977
+ data,
40978
+ platform: "capacitor"
40979
+ });
40980
+ });
40923
40981
  plugin.consumePendingAction?.().catch?.(() => {
40924
40982
  });
40925
40983
  };
@@ -40958,7 +41016,8 @@ var Tevroc = (() => {
40958
41016
  data: options.data || {},
40959
41017
  actions: options.actions || [],
40960
41018
  silent: Boolean(options.silent),
40961
- channel: options.channel || "general"
41019
+ channel: options.channel || "general",
41020
+ style: options.style || {}
40962
41021
  };
40963
41022
  const plugin = appPlugin();
40964
41023
  if (plugin?.show) {
@@ -41014,6 +41073,49 @@ var Tevroc = (() => {
41014
41073
  return { permission, requestPermission, show, schedule, cancel, cancelAll, onAction };
41015
41074
  }
41016
41075
 
41076
+ // src/services/chatNotifications.js
41077
+ function createChatNotificationService(client) {
41078
+ const listeners2 = /* @__PURE__ */ new Set();
41079
+ const emit2 = (event) => listeners2.forEach((listener) => listener(event));
41080
+ const showMessage = async ({ sessionId, title = "New chat message", body = "", data = {}, style } = {}) => {
41081
+ if (!sessionId) return null;
41082
+ return client.notifications.show({
41083
+ id: `chat-message-${sessionId}-${Date.now()}`,
41084
+ title,
41085
+ body,
41086
+ data: { ...data, sessionId, kind: "chat_message" },
41087
+ channel: "chat_messages",
41088
+ style,
41089
+ actions: [
41090
+ { id: "open", title: "Open chat" },
41091
+ { id: "reply", title: "Reply", input: true }
41092
+ ]
41093
+ });
41094
+ };
41095
+ const showStatus = async ({ sessionId, title = "Chat update", body = "", data = {}, style } = {}) => {
41096
+ if (!sessionId) return null;
41097
+ return client.notifications.show({
41098
+ id: `chat-status-${sessionId}-${Date.now()}`,
41099
+ title,
41100
+ body,
41101
+ data: { ...data, sessionId, kind: "chat_status" },
41102
+ channel: "chat_messages",
41103
+ style,
41104
+ actions: [{ id: "open", title: "Open chat" }]
41105
+ });
41106
+ };
41107
+ const onEvent = (listener) => {
41108
+ listeners2.add(listener);
41109
+ return () => listeners2.delete(listener);
41110
+ };
41111
+ client.notifications.onAction(({ action, data, reply }) => {
41112
+ if (data?.sessionId && ["chat_message", "chat_status"].includes(data.kind)) {
41113
+ emit2({ type: action === "reply" ? "reply" : action, action, sessionId: data.sessionId, reply: reply || "", data });
41114
+ }
41115
+ });
41116
+ return { showMessage, showStatus, onEvent };
41117
+ }
41118
+
41017
41119
  // src/index.js
41018
41120
  init_usePlatform();
41019
41121
 
@@ -41938,10 +42040,10 @@ var Tevroc = (() => {
41938
42040
  autoInterval = null;
41939
42041
  }
41940
42042
  }
41941
- function emit2(event2, payload) {
42043
+ function emit2(event, payload) {
41942
42044
  try {
41943
- if (!listeners2.has(event2)) return;
41944
- for (const cb of listeners2.get(event2)) {
42045
+ if (!listeners2.has(event)) return;
42046
+ for (const cb of listeners2.get(event)) {
41945
42047
  try {
41946
42048
  cb(payload);
41947
42049
  } catch (e2) {
@@ -41961,14 +42063,14 @@ var Tevroc = (() => {
41961
42063
  stopAutoSync,
41962
42064
  getQueue,
41963
42065
  // events
41964
- on: (event2, cb) => {
41965
- if (!listeners2.has(event2)) listeners2.set(event2, /* @__PURE__ */ new Set());
41966
- listeners2.get(event2).add(cb);
41967
- return () => listeners2.get(event2).delete(cb);
42066
+ on: (event, cb) => {
42067
+ if (!listeners2.has(event)) listeners2.set(event, /* @__PURE__ */ new Set());
42068
+ listeners2.get(event).add(cb);
42069
+ return () => listeners2.get(event).delete(cb);
41968
42070
  },
41969
- off: (event2, cb) => {
41970
- if (!listeners2.has(event2)) return;
41971
- listeners2.get(event2).delete(cb);
42071
+ off: (event, cb) => {
42072
+ if (!listeners2.has(event)) return;
42073
+ listeners2.get(event).delete(cb);
41972
42074
  },
41973
42075
  getPendingUploads: async () => {
41974
42076
  const snapshot = await store.get("pending_uploads");
@@ -42135,6 +42237,7 @@ var Tevroc = (() => {
42135
42237
  this.commerce = createCommerceApi(this);
42136
42238
  this.realtime = createRealtimeApi(this);
42137
42239
  this.notifications = createNotificationService();
42240
+ this.chatNotifications = createChatNotificationService(this);
42138
42241
  this.agentNotifications = createAgentNotificationService(this);
42139
42242
  this.shiplogic = createShiplogicApi(this);
42140
42243
  this.platform = createPlatformApi(this);
@@ -42281,27 +42384,27 @@ var Tevroc = (() => {
42281
42384
  if (closedByUser) return;
42282
42385
  debugError2(client, "[tevrocsdk] opening realtime socket", { room, roomName, url, appId: client.appId });
42283
42386
  socket = new WebSocket(url);
42284
- socket.addEventListener("open", (event2) => {
42387
+ socket.addEventListener("open", (event) => {
42285
42388
  reconnectCount = 0;
42286
42389
  debugError2(client, "[tevrocsdk] realtime socket open", { room, roomName, readyState: socket.readyState, url });
42287
- handlers.open?.(event2);
42390
+ handlers.open?.(event);
42288
42391
  while (pendingMessages.length && sendNow(pendingMessages[0])) {
42289
42392
  pendingMessages.shift();
42290
42393
  }
42291
42394
  });
42292
- socket.addEventListener("message", (event2) => {
42293
- let data = event2.data;
42395
+ socket.addEventListener("message", (event) => {
42396
+ let data = event.data;
42294
42397
  try {
42295
- data = JSON.parse(event2.data);
42398
+ data = JSON.parse(event.data);
42296
42399
  } catch {
42297
42400
  }
42298
42401
  debugError2(client, "[tevrocsdk] realtime socket message", { room, roomName, data });
42299
- handlers.message?.(data, event2);
42402
+ handlers.message?.(data, event);
42300
42403
  });
42301
- socket.addEventListener("close", (event2) => {
42302
- debugLog2(client, "[tevrocsdk] realtime socket close", { room, roomName, code: event2.code, reason: event2.reason, wasClean: event2.wasClean, url });
42303
- handlers.close?.(event2);
42304
- const wasNeverOpen = event2?.code === 1006 || socket?.readyState !== WebSocket.OPEN;
42404
+ socket.addEventListener("close", (event) => {
42405
+ debugLog2(client, "[tevrocsdk] realtime socket close", { room, roomName, code: event.code, reason: event.reason, wasClean: event.wasClean, url });
42406
+ handlers.close?.(event);
42407
+ const wasNeverOpen = event?.code === 1006 || socket?.readyState !== WebSocket.OPEN;
42305
42408
  if (wasNeverOpen && !attemptedRawFallback && rawUrl && rawUrl !== url) {
42306
42409
  attemptedRawFallback = true;
42307
42410
  debugWarn2(client, "[tevrocsdk] realtime fallback to raw URL after failed encoded handshake", { encodedUrl: url, rawUrl });
@@ -42316,9 +42419,9 @@ var Tevroc = (() => {
42316
42419
  openSocket();
42317
42420
  }, reconnectMs);
42318
42421
  });
42319
- socket.addEventListener("error", (event2) => {
42320
- debugLog2(client, "[tevrocsdk] realtime socket error", { room, roomName, event: event2 });
42321
- handlers.error?.(event2);
42422
+ socket.addEventListener("error", (event) => {
42423
+ debugLog2(client, "[tevrocsdk] realtime socket error", { room, roomName, event });
42424
+ handlers.error?.(event);
42322
42425
  });
42323
42426
  };
42324
42427
  openSocket();