@memberjunction/realtime-widget 6.2.2 → 6.2.4

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  UserViewEngine
3
- } from "./chunk-FSUYQQ6X.js";
3
+ } from "./chunk-4FX3KCZD.js";
4
4
  import "./chunk-DIDGGUK7.js";
5
5
  export {
6
6
  UserViewEngine
@@ -37301,10 +37301,14 @@ var BaseEngine = class _BaseEngine extends BaseSingleton {
37301
37301
  const configsToLoad = this.CheckPermissionsOrSkipAll(this._metadataConfigs, contextUser);
37302
37302
  const entityConfigsToLoad = configsToLoad.filter((c) => c.Type === "entity");
37303
37303
  const datasetConfigsToLoad = configsToLoad.filter((c) => c.Type === "dataset");
37304
- await Promise.all([
37305
- ...datasetConfigsToLoad.map((c) => this.LoadSingleDatasetConfig(c, contextUser, bypassCache)),
37306
- this.LoadMultipleEntityConfigs(entityConfigsToLoad, contextUser, bypassCache)
37307
- ]);
37304
+ try {
37305
+ await Promise.all([
37306
+ ...datasetConfigsToLoad.map((c) => this.LoadSingleDatasetConfig(c, contextUser, bypassCache)),
37307
+ this.LoadMultipleEntityConfigs(entityConfigsToLoad, contextUser, bypassCache)
37308
+ ]);
37309
+ } finally {
37310
+ this.reconcileExpirationTimers();
37311
+ }
37308
37312
  this.RegisterCacheChangeCallbacks(entityConfigs);
37309
37313
  }
37310
37314
  static {
@@ -38665,9 +38669,58 @@ var BaseEngine = class _BaseEngine extends BaseSingleton {
38665
38669
  if (this._expirationTimers.has(propertyName)) {
38666
38670
  clearTimeout(this._expirationTimers.get(propertyName));
38667
38671
  }
38668
- const timer = setTimeout(() => this.RefreshItem(propertyName), expiration);
38672
+ const timer = setTimeout(() => this.runExpirationRefresh(propertyName, expiration, timer), expiration);
38673
+ if (typeof timer === "object" && timer !== null && "unref" in timer && typeof timer.unref === "function") {
38674
+ timer.unref();
38675
+ }
38669
38676
  this._expirationTimers.set(propertyName, timer);
38670
38677
  }
38678
+ /**
38679
+ * Makes the running timers match the loaded configs: a config with an Expiration and no timer
38680
+ * gets one, and a timer whose config no longer has an Expiration is stopped.
38681
+ *
38682
+ * A successful load arms its own timer from {@link HandleSingleViewResult}, but a failed one does
38683
+ * not — without this a failed first load would leave that property with no refresh until restart.
38684
+ * And a reload that drops the Expiration (an interval set to 0) must stop the timer, which
38685
+ * {@link runExpirationRefresh} would otherwise keep re-arming at the old interval.
38686
+ */
38687
+ reconcileExpirationTimers() {
38688
+ for (const c of this._metadataConfigs) {
38689
+ if (c.Expiration && !this._expirationTimers.has(c.PropertyName)) {
38690
+ this.setExpirationTimer(c.PropertyName, c.Expiration);
38691
+ } else if (!c.Expiration && this._expirationTimers.has(c.PropertyName)) {
38692
+ clearTimeout(this._expirationTimers.get(c.PropertyName));
38693
+ this._expirationTimers.delete(c.PropertyName);
38694
+ }
38695
+ }
38696
+ }
38697
+ /**
38698
+ * Runs one timed refresh and keeps the timer alive. A successful load re-arms the timer from
38699
+ * {@link HandleSingleViewResult}; a failed one (an unsuccessful result, or a thrown connection
38700
+ * error) does not, so without this the refresh would stop for good after a single failed read
38701
+ * and the property would keep its last rows indefinitely.
38702
+ * The re-arm uses the config as it is now, so a reload that dropped the Expiration while this
38703
+ * tick was running stops the timer instead of keeping it at the old interval.
38704
+ * @param timer - The handle that fired; if the map no longer holds it, a successful load, a
38705
+ * {@link reconcileExpirationTimers} or a {@link RemoveDynamicConfig} already
38706
+ * decided what happens next.
38707
+ */
38708
+ async runExpirationRefresh(propertyName, expiration, timer) {
38709
+ try {
38710
+ await this.RefreshItem(propertyName);
38711
+ } catch (e) {
38712
+ LogError(`${this.constructor.name}: timed refresh of ${propertyName} failed \u2014 ${e.message}. Retrying in ${expiration} ms.`);
38713
+ }
38714
+ if (this._expirationTimers.get(propertyName) !== timer) {
38715
+ return;
38716
+ }
38717
+ const config = this._metadataConfigs.find((c) => c.PropertyName === propertyName) || this._dynamicConfigs.get(propertyName);
38718
+ if (config?.Expiration) {
38719
+ this.setExpirationTimer(propertyName, config.Expiration);
38720
+ } else {
38721
+ this._expirationTimers.delete(propertyName);
38722
+ }
38723
+ }
38671
38724
  /**
38672
38725
  * Adds a dynamic metadata configuration at runtime.
38673
38726
  * @param config - The metadata configuration to add
@@ -38708,7 +38761,7 @@ var BaseEngine = class _BaseEngine extends BaseSingleton {
38708
38761
  config,
38709
38762
  this._contextUser,
38710
38763
  /*bypassCache*/
38711
- false,
38764
+ !!config.Expiration,
38712
38765
  /*suppressEmit*/
38713
38766
  true
38714
38767
  );
@@ -61,7 +61,7 @@ import {
61
61
  ValidateUserViewProperties,
62
62
  WellKnownUserSource,
63
63
  getGraphQLTypeNameBase
64
- } from "./chunk-FSUYQQ6X.js";
64
+ } from "./chunk-4FX3KCZD.js";
65
65
  import {
66
66
  BehaviorSubject,
67
67
  CleanAndParseJSON,
@@ -143211,7 +143211,7 @@ var ViewInfo = class {
143211
143211
  * @async
143212
143212
  */
143213
143213
  static async GetViewEntity(viewId, contextUser) {
143214
- const { UserViewEngine } = await import("./UserViewEngine-GC7MTS7M.js");
143214
+ const { UserViewEngine } = await import("./UserViewEngine-UL2SXGFT.js");
143215
143215
  await UserViewEngine.Instance.Config(false, contextUser);
143216
143216
  const view = UserViewEngine.Instance.GetViewById(viewId);
143217
143217
  if (view) {
@@ -143230,7 +143230,7 @@ var ViewInfo = class {
143230
143230
  * @async
143231
143231
  */
143232
143232
  static async GetViewEntityByName(viewName, contextUser) {
143233
- const { UserViewEngine } = await import("./UserViewEngine-GC7MTS7M.js");
143233
+ const { UserViewEngine } = await import("./UserViewEngine-UL2SXGFT.js");
143234
143234
  await UserViewEngine.Instance.Config(false, contextUser);
143235
143235
  const view = UserViewEngine.Instance.GetViewByName(viewName);
143236
143236
  if (view) {
@@ -163309,7 +163309,7 @@ var Fe = class {
163309
163309
  return LogError(`Error checking for a duplicate entry: ${t}`), { Status: "Failed", ErrorMessage: t || "Unknown error occurred", Candidates: [] };
163310
163310
  }
163311
163311
  };
163312
- var H = "6.2.2";
163312
+ var H = "6.2.4";
163313
163313
  var F = "default";
163314
163314
  var _e = class {
163315
163315
  static {
@@ -11,7 +11,7 @@ import {
11
11
  S,
12
12
  TemplateEngineBase,
13
13
  coerceFailedExecuteAgentResult
14
- } from "./chunk-FUTOBCKH.js";
14
+ } from "./chunk-CCHOUKBG.js";
15
15
  import {
16
16
  BaseEngine,
17
17
  BaseEntity,
@@ -22,7 +22,7 @@ import {
22
22
  PermissionConstrainedError,
23
23
  RegisterForStartup,
24
24
  RunView
25
- } from "./chunk-FSUYQQ6X.js";
25
+ } from "./chunk-4FX3KCZD.js";
26
26
  import {
27
27
  ParseModelConfiguration,
28
28
  ParseVendorConfiguration,
@@ -28,9 +28,9 @@ import {
28
28
  SessionCardStatusChip,
29
29
  SessionCardTitle,
30
30
  SessionsObserver
31
- } from "./chunk-K7W2OS56.js";
32
- import "./chunk-FUTOBCKH.js";
33
- import "./chunk-FSUYQQ6X.js";
31
+ } from "./chunk-HOTWHK6Z.js";
32
+ import "./chunk-CCHOUKBG.js";
33
+ import "./chunk-4FX3KCZD.js";
34
34
  import "./chunk-JOGHPRST.js";
35
35
  import "./chunk-DIDGGUK7.js";
36
36
  export {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  S
3
- } from "./chunk-FUTOBCKH.js";
4
- import "./chunk-FSUYQQ6X.js";
3
+ } from "./chunk-CCHOUKBG.js";
4
+ import "./chunk-4FX3KCZD.js";
5
5
  import "./chunk-JOGHPRST.js";
6
6
  import "./chunk-DIDGGUK7.js";
7
7
 
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  S
3
- } from "./chunk-FUTOBCKH.js";
4
- import "./chunk-FSUYQQ6X.js";
3
+ } from "./chunk-CCHOUKBG.js";
4
+ import "./chunk-4FX3KCZD.js";
5
5
  import {
6
6
  ParseRealtimeClientTransport
7
7
  } from "./chunk-JOGHPRST.js";
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  ConversationsRuntime
3
- } from "./chunk-K7W2OS56.js";
3
+ } from "./chunk-HOTWHK6Z.js";
4
4
  import {
5
5
  Bt,
6
6
  ConversationEngine,
7
7
  Ot,
8
8
  agentFailureMessage
9
- } from "./chunk-FUTOBCKH.js";
9
+ } from "./chunk-CCHOUKBG.js";
10
10
  import {
11
11
  RunView
12
- } from "./chunk-FSUYQQ6X.js";
12
+ } from "./chunk-4FX3KCZD.js";
13
13
  import "./chunk-JOGHPRST.js";
14
14
  import "./chunk-DIDGGUK7.js";
15
15
 
@@ -960,14 +960,14 @@ function defaultSessionClient(apiUrl, widgetKey) {
960
960
  return new WidgetSessionClient(apiUrl, widgetKey);
961
961
  }
962
962
  async function defaultTransport(apiUrl) {
963
- const { RuntimeWidgetTransport } = await import("./chunks/runtime-widget-transport-PVQLLTW3.js");
963
+ const { RuntimeWidgetTransport } = await import("./chunks/runtime-widget-transport-FBTIKZRU.js");
964
964
  return new RuntimeWidgetTransport(apiUrl);
965
965
  }
966
966
  async function defaultVoiceController(session) {
967
967
  const [{ RealtimeVoiceController }, { createGuestVoiceMint }, { createGuestToolRelay }] = await Promise.all([
968
968
  import("./chunks/realtime-voice-controller-76SVXCXJ.js"),
969
- import("./chunks/guest-voice-mint-LCZSOULT.js"),
970
- import("./chunks/guest-tool-relay-QBLI73YQ.js")
969
+ import("./chunks/guest-voice-mint-AHN4J57R.js"),
970
+ import("./chunks/guest-tool-relay-QFRDH3RT.js")
971
971
  ]);
972
972
  return new RealtimeVoiceController(
973
973
  createGuestVoiceMint(session),
@@ -998,7 +998,7 @@ function resolveMountTarget(target) {
998
998
  return document.body;
999
999
  }
1000
1000
  function registerNotificationAdapter(element) {
1001
- void import("./chunks/dist-RKESSSYW.js").then(({ ConversationsRuntime }) => {
1001
+ void import("./chunks/dist-VKJDJCDN.js").then(({ ConversationsRuntime }) => {
1002
1002
  ConversationsRuntime.Instance.UseNotificationAdapter({
1003
1003
  Notify: (level, message) => {
1004
1004
  if (level === "error" || level === "warning") {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@memberjunction/realtime-widget",
3
3
  "type": "module",
4
- "version": "6.2.2",
4
+ "version": "6.2.4",
5
5
  "description": "MemberJunction: Droppable, embeddable public customer-support widget (text + voice). A shadow-DOM web component that reuses ConversationsRuntime + the realtime client stack against MJAPI with a guest session JWT. No MJ login required.",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -11,14 +11,14 @@
11
11
  "author": "MemberJunction.com",
12
12
  "license": "BUSL-1.1",
13
13
  "dependencies": {
14
- "@memberjunction/global": "6.2.2",
15
- "@memberjunction/core": "6.2.2",
16
- "@memberjunction/core-entities": "6.2.2",
17
- "@memberjunction/ai": "6.2.2",
18
- "@memberjunction/ai-core-plus": "6.2.2",
19
- "@memberjunction/ai-realtime-client": "6.2.2",
20
- "@memberjunction/conversations-runtime": "6.2.2",
21
- "@memberjunction/graphql-dataprovider": "6.2.2"
14
+ "@memberjunction/global": "6.2.4",
15
+ "@memberjunction/core": "6.2.4",
16
+ "@memberjunction/core-entities": "6.2.4",
17
+ "@memberjunction/ai": "6.2.4",
18
+ "@memberjunction/ai-core-plus": "6.2.4",
19
+ "@memberjunction/ai-realtime-client": "6.2.4",
20
+ "@memberjunction/conversations-runtime": "6.2.4",
21
+ "@memberjunction/graphql-dataprovider": "6.2.4"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/node": "24.10.11",