@salesforce/emp-api 12.6.3 → 12.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -61,6 +61,16 @@ removeListener();
61
61
  - **`onError(callback)`** — Registers a listener for engine-level errors.
62
62
  Per-channel and later transport failures surface here, not through the
63
63
  `subscribe()` promise. Returns a function that removes this listener.
64
+ - **`isEmpEnabled()`** — Resolves `true` if this browsing context has
65
+ `Worker` support, `false` if it doesn't. Resolves `false`, never rejects,
66
+ if the streaming config can't be fetched for any reason.
67
+ - **`setDebugFlag(flag)`** — Passes `flag` through to the underlying engine
68
+ to enable/disable console diagnostics. **Inherited quirk:** if
69
+ `localStorage['emp.debugFlag']` was already `"true"` when the page
70
+ loaded, this becomes a no-op for the rest of that page session — even
71
+ `setDebugFlag(false)` won't turn it off until the page is reloaded with
72
+ that key cleared or changed. This call still best-effort writes `flag` to
73
+ that same `localStorage` key, so a future page load picks it up.
64
74
 
65
75
  Messages delivered to `onMessage` are one of two shapes — a Platform Event
66
76
  message, or a Change Data Capture message whose payload carries a
package/dist/api.d.ts CHANGED
@@ -4,66 +4,88 @@ import { EmpSubscriptionHandle } from './vendor/emp.js';
4
4
  /**
5
5
  * Subscribes to a Platform Event or CDC channel.
6
6
  *
7
- * The returned Promise waits only on the one-time config fetch + engine
8
- * init, never on a `/meta/subscribe` server ack — it resolves right after
9
- * `Emp.init()` and the engine's synchronous `subscribe()` call for this
10
- * channel. It rejects only if config/init cannot be obtained; per-channel
11
- * and later transport failures surface exclusively through {@link onError},
12
- * never through this Promise, and never after it has already resolved.
7
+ * The returned Promise waits only on the one-time config fetch + engine init,
8
+ * never on a `/meta/subscribe` ack: it resolves right after `Emp.init()` and
9
+ * the engine's synchronous `subscribe()`. It rejects only if config/init can't
10
+ * be obtained; per-channel and later transport failures surface through
11
+ * {@link onError} only, never through this Promise and never after it resolves.
13
12
  *
14
- * `channel` and `replayId` are passed straight through with no validation,
15
- * clamping, or rewriting. Two `subscribe()` calls on the same channel are
16
- * two independent handles.
13
+ * `channel`/`replayId` pass through unvalidated; two calls on the same channel
14
+ * are independent handles. A failed ack (`successful !== true`) is routed to
15
+ * `onError` via this call's own `subscribeCallback` (not just the engine
16
+ * broadcast), so it survives an immediate empty-subscriptions teardown (see
17
+ * `dispatchError`).
17
18
  *
18
- * @param channel - A Platform Event or CDC channel name, e.g. `/event/Foo__e`.
19
- * @param replayId - `-1` for new events from the tip, `-2` to replay the
20
- * retention window, or a numeric replay id.
19
+ * @param channel - A Platform Event or CDC channel, e.g. `/event/Foo__e`.
20
+ * @param replayId - `-1` (tip), `-2` (retention window), or a numeric replay id.
21
21
  * @param onMessage - Invoked with each delivered message.
22
- * @param getConfig - Injectable config seam, defaults to the real
23
- * GraphQL-backed {@link getStreamingConfig}. Tests substitute a fake. Not
24
- * part of the public interface — the barrel's exported `subscribe` omits
25
- * this parameter.
26
- *
27
- * A failed subscribe ack (`successful !== true`) is also routed to
28
- * `onError`'s listeners via this call's own `subscribeCallback`, not just
29
- * the engine's broadcast — the ack is delivered before the engine's
30
- * empty-subscriptions disconnect check runs, so it survives even when the
31
- * connection is torn down immediately after (see `dispatchError`).
22
+ * @param getConfig - Injectable config seam (defaults to {@link getStreamingConfig});
23
+ * tests substitute a fake. Not part of the public `subscribe`.
32
24
  */
33
25
  export declare function subscribe(channel: string, replayId: number, onMessage: (message: StreamingMessage) => void, getConfig?: GetStreamingConfig): Promise<Subscription>;
34
26
  /**
35
- * Unsubscribes a handle returned by {@link subscribe}.
36
- * Synchronous, returns nothing, and is a silent no-op on a handle that has
37
- * already been unsubscribed — v1 has no completion callback, since the
38
- * vendored engine's unsubscribe callback is not a reliable per-handle ack.
27
+ * Unsubscribes a handle returned by {@link subscribe}. Synchronous, returns
28
+ * nothing, and a silent no-op on an already-unsubscribed handle — v1 has no
29
+ * completion callback (the engine's unsubscribe callback is not a reliable
30
+ * per-handle ack).
39
31
  *
40
32
  * @param subscription - The handle returned by {@link subscribe}.
41
33
  */
42
34
  export declare function unsubscribe(subscription: Subscription | EmpSubscriptionHandle): void;
43
35
  /**
44
- * Registers an error listener. Errors are passed
45
- * through unfiltered; classifying transient reconnect blips vs. terminal
46
- * failure is a caller concern, not this package's.
36
+ * Registers an error listener. Errors pass through unfiltered — classifying
37
+ * transient blips vs. terminal failure is a caller concern.
47
38
  *
48
- * The vendored engine itself has no per-listener removal — this package
49
- * tracks listeners on its own side and the returned function splices this
50
- * registration out of that list, rather than deleting anything from the
51
- * engine. Each call wraps `callback` in a fresh closure before storing it,
52
- * so registering the exact same function reference more than once still
53
- * gives each call its own removable registration — removing one doesn't
54
- * touch another registration that happens to wrap the same callback.
39
+ * Each call wraps `callback` in a fresh closure, so the same function reference
40
+ * can be registered (and removed) more than once independently; the returned
41
+ * function splices out this one registration (the engine has no per-listener
42
+ * removal).
55
43
  *
56
- * Note the engine's inherited `clearState()` behavior: it sends an
57
- * unsubscribe for every active local subscription but does not delete this
58
- * package's bookkeeping the way public `unsubscribe()` does, so a message
59
- * can still fire after `clearState()` — that is existing engine behavior,
60
- * not something this package fixes.
44
+ * Inherited caveat: `clearState()` unsubscribes every active sub but does not
45
+ * clear this package's bookkeeping the way `unsubscribe()` does, so a message
46
+ * can still fire afterward — existing engine behavior, not fixed here.
61
47
  *
62
48
  * @param callback - Invoked with the engine's error/reply message.
63
- * @returns A function that removes this listener. Calling it more than once
64
- * is a no-op.
49
+ * @returns A function that removes this listener; calling it again is a no-op.
65
50
  */
66
51
  export declare function onError(callback: (message: EmpErrorMessage) => void): () => void;
52
+ /**
53
+ * Resolves whether this context can run the streaming engine — the inherited
54
+ * LEX capability check, not "SharedWorker join achieved".
55
+ *
56
+ * Two cheap checks resolve `false` **before** any config fetch, since the
57
+ * answer can't depend on config: the native-mobile container (`window.__nimbus`)
58
+ * and no `Worker` in scope (e.g. Node/SSR) — the engine's SharedWorker →
59
+ * leader-election → standalone cascade all need `Worker`, so that one check
60
+ * covers it.
61
+ *
62
+ * Otherwise it awaits the same coalesced `ensureInit` as `subscribe()`. Not a
63
+ * side-effect-free probe: `ensureInit` runs `Emp.init`, so on success the mode
64
+ * picker constructs the SharedWorker (or starts leader election) just as a real
65
+ * `subscribe()` would. Any config failure resolves `false` (not reject), and —
66
+ * like `subscribe()` — a terminal refusal keeps resolving `false` without
67
+ * refetching.
68
+ *
69
+ * @param getConfig - Injectable config seam (defaults to {@link getStreamingConfig});
70
+ * tests substitute a fake. Not part of the public `isEmpEnabled`.
71
+ */
72
+ export declare function isEmpEnabled(getConfig?: GetStreamingConfig): Promise<boolean>;
73
+ /**
74
+ * Passes `flag` through to the vendored engine's `Emp.setDebugFlag`.
75
+ *
76
+ * **Inherited LEX latch:** the engine reads `localStorage['emp.debugFlag']`
77
+ * once at module load into a `const`. If it was `"true"` then, `setDebugFlag`
78
+ * is a permanent no-op for that page — passing `false` won't turn diagnostics
79
+ * off until the key is cleared and the page reloads. Engine behavior, not
80
+ * fixable without editing the vendored file.
81
+ *
82
+ * To persist intent forward, this also best-effort writes `flag` to
83
+ * `localStorage[DEBUG_FLAG_KEY]` (swallowing any failure), so a future page
84
+ * load re-latches from the most recent call.
85
+ *
86
+ * @param flag - true or false.
87
+ */
88
+ export declare function setDebugFlag(flag: boolean): void;
67
89
  /**
68
90
  * Test-only escape hatch to reset the module-level init guard between test
69
91
  * cases. Not part of the public barrel.
package/dist/api.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAsB,KAAK,kBAAkB,EAAE,MAAM,UAAU,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC/E,OAAO,EAAO,KAAK,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAyKlE;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,SAAS,CAC9B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,IAAI,EAC9C,SAAS,GAAE,kBAAuC,GAChD,OAAO,CAAC,YAAY,CAAC,CAsBvB;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,YAAY,EAAE,YAAY,GAAG,qBAAqB,GAAG,IAAI,CAEpF;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,OAAO,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,IAAI,GAAG,MAAM,IAAI,CAUhF;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,IAAI,IAAI,CAK9C"}
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAsB,KAAK,kBAAkB,EAAE,MAAM,UAAU,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC/E,OAAO,EAAO,KAAK,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAgJlE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,SAAS,CAC9B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,IAAI,EAC9C,SAAS,GAAE,kBAAuC,GAChD,OAAO,CAAC,YAAY,CAAC,CAsBvB;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,YAAY,EAAE,YAAY,GAAG,qBAAqB,GAAG,IAAI,CAEpF;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,OAAO,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,IAAI,GAAG,MAAM,IAAI,CAUhF;AAYD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,YAAY,CACjC,SAAS,GAAE,kBAAuC,GAChD,OAAO,CAAC,OAAO,CAAC,CAclB;AASD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAOhD;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,IAAI,IAAI,CAK9C"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { StreamingMessage, Subscription } from './types';
2
- export { unsubscribe, onError } from './api';
2
+ export { unsubscribe, onError, setDebugFlag } from './api';
3
3
  export { isChangeDataCaptureMessage } from './types';
4
4
  export type { BayeuxFailure, ChangeDataCaptureMessage, ChangeEventHeader, EmpErrorMessage, PlatformEventMessage, StreamingConfig, StreamingMessage, Subscription, } from './types';
5
5
  /**
@@ -9,4 +9,11 @@ export type { BayeuxFailure, ChangeDataCaptureMessage, ChangeEventHeader, EmpErr
9
9
  * public interface.
10
10
  */
11
11
  export declare function subscribe(channel: string, replayId: number, onMessage: (message: StreamingMessage) => void): Promise<Subscription>;
12
+ /**
13
+ * Resolves whether this browsing context can run the streaming engine at
14
+ * all. See {@link isEmpEnabledInternal} for full behavior. The config seam
15
+ * is an internal implementation detail used by tests — not part of the
16
+ * public interface.
17
+ */
18
+ export declare function isEmpEnabled(): Promise<boolean>;
12
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAiBH,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE9D,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AACrD,YAAY,EACX,aAAa,EACb,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,YAAY,GACZ,MAAM,SAAS,CAAC;AAEjB;;;;;GAKG;AACH,wBAAsB,SAAS,CAC9B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,IAAI,GAC5C,OAAO,CAAC,YAAY,CAAC,CAEvB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAeH,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE9D,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AACrD,YAAY,EACX,aAAa,EACb,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,YAAY,GACZ,MAAM,SAAS,CAAC;AAEjB;;;;;GAKG;AACH,wBAAsB,SAAS,CAC9B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,IAAI,GAC5C,OAAO,CAAC,YAAY,CAAC,CAEvB;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,OAAO,CAAC,CAErD"}
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { gql as je, createDataSDK as Ge } from "@salesforce/platform-sdk";
2
- const Ke = je`
1
+ import { gql as Ke, createDataSDK as Be } from "@salesforce/platform-sdk";
2
+ const Ve = Ke`
3
3
  query GetStreamingConfig {
4
4
  uiapi {
5
5
  platform {
@@ -11,12 +11,12 @@ const Ke = je`
11
11
  }
12
12
  }
13
13
  `;
14
- async function Be() {
15
- const r = await Ge();
16
- if (!r.graphql)
14
+ async function ue() {
15
+ const n = await Be();
16
+ if (!n.graphql)
17
17
  throw new Error("@salesforce/emp-api: GraphQL is not supported on this surface");
18
- const a = await r.graphql.query({
19
- query: Ke
18
+ const a = await n.graphql.query({
19
+ query: Ve
20
20
  }), l = a.data?.uiapi?.platform?.streamingConfig, d = l?.cometdUrl, b = l?.cometdWorkerJs;
21
21
  if (a.errors?.length || !d || !b)
22
22
  throw new Error(
@@ -24,124 +24,124 @@ async function Be() {
24
24
  );
25
25
  return { cometdUrl: d, cometdWorkerJs: b };
26
26
  }
27
- function Ve(r, a) {
28
- const l = "emp.leaderElection", d = "emp.heartbeat", b = ["FOLLOWER", "CANDIDATE", "LEADER"], E = Date.now() + "_" + w(1, 1e4), y = 4e3, T = 6e3, _ = 3e3, S = 4e3;
29
- let u = b[0], p = !1, s = 0, g = !1, f = null, C, L, O = !1;
27
+ function Ye(n, a) {
28
+ const l = "emp.leaderElection", d = "emp.heartbeat", b = ["FOLLOWER", "CANDIDATE", "LEADER"], E = Date.now() + "_" + C(1, 1e4), y = 4e3, T = 6e3, _ = 3e3, S = 4e3;
29
+ let u = b[0], p = !1, s = 0, g = !1, f = null, w, L, O = !1;
30
30
  const D = {};
31
31
  D.heartBeat = () => {
32
- const n = {};
33
- return n.eventType = "heartbeat", n.leader = {
32
+ const o = {};
33
+ return o.eventType = "heartbeat", o.leader = {
34
34
  id: E,
35
35
  candidateTime: f
36
- }, n;
36
+ }, o;
37
37
  }, D.election = () => {
38
- const n = {};
39
- return n.eventType = "election", n.candidateId = E, n.candidateTime = f, n;
40
- }, D.vote = (n) => {
38
+ const o = {};
39
+ return o.eventType = "election", o.candidateId = E, o.candidateTime = f, o;
40
+ }, D.vote = (o) => {
41
41
  const i = {};
42
- return i.eventType = "vote", i.candidateId = n, i;
42
+ return i.eventType = "vote", i.candidateId = o, i;
43
43
  };
44
- function h(...n) {
45
- O && window.console.log(...n);
44
+ function h(...o) {
45
+ O && window.console.log(...o);
46
46
  }
47
- function c(n) {
48
- return typeof n == "function";
47
+ function c(o) {
48
+ return typeof o == "function";
49
49
  }
50
- function w(n, i) {
51
- return n = Math.ceil(n), i = Math.floor(i), Math.floor(Math.random() * (i - n + 1)) + n;
50
+ function C(o, i) {
51
+ return o = Math.ceil(o), i = Math.floor(i), Math.floor(Math.random() * (i - o + 1)) + o;
52
52
  }
53
- function k(n) {
54
- J(d, n);
53
+ function k(o) {
54
+ G(d, o);
55
55
  }
56
- function H(n) {
57
- J(l, n);
56
+ function J(o) {
57
+ G(l, o);
58
58
  }
59
- function J(n, i) {
59
+ function G(o, i) {
60
60
  i.time = Date.now();
61
- const V = JSON.stringify(i);
62
- window.localStorage.setItem(n, V);
61
+ const Y = JSON.stringify(i);
62
+ window.localStorage.setItem(o, Y);
63
63
  }
64
- function P(n) {
65
- c(a) && a(n);
64
+ function P(o) {
65
+ c(a) && a(o);
66
66
  }
67
- function j(n) {
68
- u === b[2] && f > n.leader.candidateTime && (u = b[0], clearInterval(C), C = null), L !== n.leader.id && (L = n.leader.id, P({ leaderId: L })), g = !1, s = 0, p = !0;
67
+ function j(o) {
68
+ u === b[2] && f > o.leader.candidateTime && (u = b[0], clearInterval(w), w = null), L !== o.leader.id && (L = o.leader.id, P({ leaderId: L })), g = !1, s = 0, p = !0;
69
69
  }
70
- function G(n) {
71
- n.candidateId === E && (s += 1, h("[EmpLe] Vote handler: received votes [" + s + "]"));
70
+ function K(o) {
71
+ o.candidateId === E && (s += 1, h("[EmpLe] Vote handler: received votes [" + s + "]"));
72
72
  }
73
- function N(n) {
74
- return n === E;
73
+ function N(o) {
74
+ return o === E;
75
75
  }
76
- function W(n) {
76
+ function W(o) {
77
77
  h("[EmpLe] Election handler");
78
- const i = n.candidateId;
78
+ const i = o.candidateId;
79
79
  if (N(i)) {
80
80
  h(
81
81
  "[EmpLe] Event candidateId is same as Node Id. Ignore our own heartbeat message"
82
82
  );
83
83
  return;
84
84
  }
85
- !K() && n.candidateTime < f && (u = b[0], h(
85
+ !B() && o.candidateTime < f && (u = b[0], h(
86
86
  "[EmpLe] Election handler: Detected two candidates or leaders, becoming follower."
87
- )), R() && K() && (h("[EmpLe] Election handler: voted for [" + i + "]."), H(D.vote(i)), g = !0), p = !0;
87
+ )), A() && B() && (h("[EmpLe] Election handler: voted for [" + i + "]."), J(D.vote(i)), g = !0), p = !0;
88
88
  }
89
- function R() {
89
+ function A() {
90
90
  return !g;
91
91
  }
92
- function K() {
92
+ function B() {
93
93
  return u === b[0];
94
94
  }
95
- function A() {
95
+ function R() {
96
96
  window.setTimeout(() => {
97
- p ? (p = !1, A()) : F();
98
- }, w(y, T));
97
+ p ? (p = !1, R()) : F();
98
+ }, C(y, T));
99
99
  }
100
100
  function v() {
101
101
  window.setTimeout(() => {
102
102
  h(
103
103
  "[EmpLe] Election Timedout: heartbeat received=" + p
104
- ), p ? (p = !1, A()) : s > 0 && u !== b[0] && (u = b[2], g = !1, h(
104
+ ), p ? (p = !1, R()) : s > 0 && u !== b[0] && (u = b[2], g = !1, h(
105
105
  "[EmpLe] Yay I am the leader :" + E + " with [" + s + "] votes."
106
106
  ), X(), P({ leaderId: E }));
107
- }, w(S, S));
107
+ }, C(S, S));
108
108
  }
109
109
  function F() {
110
- u = b[1], s = 0, p ? A() : (s += 1, g = !0, f = Date.now(), H(D.election()), v());
110
+ u = b[1], s = 0, p ? R() : (s += 1, g = !0, f = Date.now(), J(D.election()), v());
111
111
  }
112
112
  function X() {
113
- C = window.setInterval(() => {
113
+ w = window.setInterval(() => {
114
114
  k(D.heartBeat());
115
- }, w(_, _));
115
+ }, C(_, _));
116
116
  }
117
117
  function U() {
118
- clearInterval(C), C = null;
118
+ clearInterval(w), w = null;
119
119
  }
120
- function B(n) {
120
+ function V(o) {
121
121
  let i;
122
- n.newValue && (n.key === l || n.key === d) && (i = JSON.parse(n.newValue)), i && i.eventType && (h("[EmpLe]", i), i.eventType === "heartbeat" && j(i), i.eventType === "vote" && G(i), i.eventType === "election" && W(i));
122
+ o.newValue && (o.key === l || o.key === d) && (i = JSON.parse(o.newValue)), i && i.eventType && (h("[EmpLe]", i), i.eventType === "heartbeat" && j(i), i.eventType === "vote" && K(i), i.eventType === "election" && W(i));
123
123
  }
124
- function z() {
125
- c(r) && r({ nodeId: E }), window.addEventListener("storage", B), A();
124
+ function $() {
125
+ c(n) && n({ nodeId: E }), window.addEventListener("storage", V), R();
126
126
  }
127
- function $(n) {
128
- O = n;
127
+ function z(o) {
128
+ O = o;
129
129
  }
130
130
  function x() {
131
131
  try {
132
132
  h("[EmpLe] Stopping heartbeats..."), U(), h("[EmpLe] Successfully stopped heartbeats");
133
- } catch (n) {
134
- h("[EmpLe] Failed to stop heartbeats. Reason = " + n);
133
+ } catch (o) {
134
+ h("[EmpLe] Failed to stop heartbeats. Reason = " + o);
135
135
  }
136
136
  }
137
137
  return {
138
- start: z,
138
+ start: $,
139
139
  stop: x,
140
- setDebugFlag: $
140
+ setDebugFlag: z
141
141
  };
142
142
  }
143
- const Q = (() => {
144
- const r = "org.cometd.reload.fromLocalStorage", a = "emp.cometd", l = "emp.debugFlag", d = J(), b = D(), E = {
143
+ const H = (() => {
144
+ const n = "org.cometd.reload.fromLocalStorage", a = "emp.cometd", l = "emp.debugFlag", d = G(), b = D(), E = {
145
145
  log: () => {
146
146
  }
147
147
  }, y = {
@@ -151,7 +151,7 @@ const Q = (() => {
151
151
  };
152
152
  let T, _, S = null;
153
153
  const u = {}, p = {};
154
- let s = null, g = null, f = null, C = null, L = {}, O = b;
154
+ let s = null, g = null, f = null, w = null, L = {}, O = b;
155
155
  function D() {
156
156
  return d ? localStorage.getItem(l) === "true" : !1;
157
157
  }
@@ -161,20 +161,20 @@ const Q = (() => {
161
161
  function c() {
162
162
  return h() ? window.console : E;
163
163
  }
164
- function w(e) {
164
+ function C(e) {
165
165
  return typeof e == "function";
166
166
  }
167
167
  function k(e, t) {
168
- Object.entries(e).forEach(([o, m]) => {
169
- t.length === 2 ? t(o, m) : t(m);
168
+ Object.entries(e).forEach(([r, m]) => {
169
+ t.length === 2 ? t(r, m) : t(m);
170
170
  });
171
171
  }
172
- function H() {
172
+ function J() {
173
173
  return !!navigator.userAgent.match(/ipad|iphone|ipod/i);
174
174
  }
175
- function J() {
175
+ function G() {
176
176
  try {
177
- return G("key", { value: "emp.test" }), localStorage.removeItem("key"), !0;
177
+ return K("key", { value: "emp.test" }), localStorage.removeItem("key"), !0;
178
178
  } catch {
179
179
  return !1;
180
180
  }
@@ -186,10 +186,10 @@ const Q = (() => {
186
186
  let e = "";
187
187
  return f && (e = f), e + "_" + Date.now() + "_" + P(1, 1e4);
188
188
  }
189
- function G(e, t) {
189
+ function K(e, t) {
190
190
  t.time = Date.now();
191
- const o = JSON.stringify(t);
192
- window.localStorage.setItem(e, o);
191
+ const r = JSON.stringify(t);
192
+ window.localStorage.setItem(e, r);
193
193
  }
194
194
  function N(e) {
195
195
  if (!d) {
@@ -199,27 +199,27 @@ const Q = (() => {
199
199
  );
200
200
  return;
201
201
  }
202
- G(a, e);
202
+ K(a, e);
203
203
  }
204
204
  function W(e) {
205
205
  c().log("[Emp] toCometdWorker: ", e);
206
206
  let t = s;
207
207
  s ? (S === y.SHARED_WORKER && (t = s.port), t.postMessage(e)) : N(e);
208
208
  }
209
- function R(e) {
209
+ function A(e) {
210
210
  return !!u[e.id];
211
211
  }
212
- function K(e) {
212
+ function B(e) {
213
213
  return !!p[e.id];
214
214
  }
215
- function A(e) {
215
+ function R(e) {
216
216
  return !!L[e.id];
217
217
  }
218
218
  function v() {
219
- return C === f;
219
+ return w === f;
220
220
  }
221
221
  function F() {
222
- return !!C || s;
222
+ return !!w || s;
223
223
  }
224
224
  function X(e) {
225
225
  return e.data.nodeId === f;
@@ -228,11 +228,11 @@ const Q = (() => {
228
228
  const t = {};
229
229
  return t.id = e.id, t.channel = e.channel, t.replayId = e.replayId, t;
230
230
  }
231
- function B(e) {
231
+ function V(e) {
232
232
  const t = {};
233
233
  return t.id = e.id, t;
234
234
  }
235
- function z() {
235
+ function $() {
236
236
  if (_) {
237
237
  const e = {
238
238
  eventType: "functionCall",
@@ -245,19 +245,19 @@ const Q = (() => {
245
245
  c().log("[Emp] Init config, remote call with ", e), W(e);
246
246
  }
247
247
  }
248
- function $() {
248
+ function z() {
249
249
  return {
250
250
  subscriptions: u,
251
251
  unsubscribes: p
252
252
  };
253
253
  }
254
254
  function x(e) {
255
- _ = e, T = _.paths.cometdWorkerJs, S = Ne(), c().log(
255
+ _ = e, T = _.paths.cometdWorkerJs, S = Ae(), c().log(
256
256
  "[Emp] Init config, the mode of operation is ",
257
257
  S
258
- ), S === y.LEADER_ELECTION && He(), !F() && Object.keys(u).length > 0 && ee();
258
+ ), S === y.LEADER_ELECTION && Ge(), !F() && Object.keys(u).length > 0 && ee();
259
259
  }
260
- function n(e) {
260
+ function o(e) {
261
261
  b || (O = e, i());
262
262
  }
263
263
  function i() {
@@ -270,63 +270,63 @@ const Q = (() => {
270
270
  }
271
271
  }), g && g.setDebugFlag(O);
272
272
  }
273
- function V(e) {
273
+ function Y(e) {
274
274
  const t = {
275
275
  eventType: "functionCall",
276
276
  nodeId: f,
277
277
  functionName: "addOnErrorListener",
278
278
  functionParams: {
279
- listener: B(e)
279
+ listener: V(e)
280
280
  }
281
281
  };
282
282
  W(t);
283
283
  }
284
284
  function oe() {
285
- k(L, V);
285
+ k(L, Y);
286
286
  }
287
- function fe(e) {
287
+ function pe(e) {
288
288
  const t = {
289
289
  eventType: "functionCall",
290
290
  nodeId: f,
291
291
  functionName: "removeOnErrorListener",
292
292
  functionParams: {
293
- listener: B(e)
293
+ listener: V(e)
294
294
  }
295
295
  };
296
296
  W(t);
297
297
  }
298
- function be() {
299
- k(L, fe), L = {};
298
+ function me() {
299
+ k(L, pe), L = {};
300
300
  }
301
- function pe(e) {
301
+ function Ee(e) {
302
302
  const t = {};
303
- t.id = j(), t.callback = e, L[t.id] = t, F() && V(t);
303
+ t.id = j(), t.callback = e, L[t.id] = t, F() && Y(t);
304
304
  }
305
305
  function re() {
306
- be(), Ie();
306
+ me(), Se();
307
307
  }
308
- function me(e) {
309
- k(u, (t, o) => {
310
- o.channel === e && delete u[t];
308
+ function ge(e) {
309
+ k(u, (t, r) => {
310
+ r.channel === e && delete u[t];
311
311
  });
312
312
  }
313
- function Ee(e) {
314
- k(p, (t, o) => {
315
- o.channel === e && delete p[t];
313
+ function _e(e) {
314
+ k(p, (t, r) => {
315
+ r.channel === e && delete p[t];
316
316
  });
317
317
  }
318
- function ge(e) {
319
- const t = e.message, o = JSON.parse(t);
320
- o && (o.channel === "/meta/subscribe" || o.channel === "/meta/unsubscribe") && o.subscription && (me(o.subscription), Ee(o.subscription)), k(L, (m) => {
318
+ function he(e) {
319
+ const t = e.message, r = JSON.parse(t);
320
+ r && (r.channel === "/meta/subscribe" || r.channel === "/meta/unsubscribe") && r.subscription && (ge(r.subscription), _e(r.subscription)), k(L, (m) => {
321
321
  const I = m.callback;
322
- w(I) && I(o);
322
+ C(I) && I(r);
323
323
  });
324
324
  }
325
325
  function ie() {
326
326
  if (_) {
327
327
  const e = JSON.parse(JSON.stringify(_));
328
328
  return d && (e.cometdState = window.localStorage.getItem(
329
- r
329
+ n
330
330
  )), e;
331
331
  }
332
332
  return {};
@@ -346,16 +346,16 @@ const Q = (() => {
346
346
  function se() {
347
347
  k(u, ae);
348
348
  }
349
- function _e(e, t, o, m) {
349
+ function Ie(e, t, r, m) {
350
350
  const I = {}, q = j();
351
- I.id = q, I.channel = e, I.replayId = t, I.callback = o, w(m) && (I.subscribeCallback = m), u[q] = I;
352
- const Pe = U(I);
353
- return F() ? ae(I) : ee(), Pe;
351
+ I.id = q, I.channel = e, I.replayId = t, I.callback = r, C(m) && (I.subscribeCallback = m), u[q] = I;
352
+ const je = U(I);
353
+ return F() ? ae(I) : ee(), je;
354
354
  }
355
- function he(e, t) {
355
+ function ye(e, t) {
356
356
  if (e) {
357
- const o = u[e.id];
358
- o && (delete u[e.id], p[o.id] = o, o.unsubscribeCallback = t, ce(o));
357
+ const r = u[e.id];
358
+ r && (delete u[e.id], p[r.id] = r, r.unsubscribeCallback = t, ce(r));
359
359
  }
360
360
  }
361
361
  function ce(e) {
@@ -369,19 +369,19 @@ const Q = (() => {
369
369
  }
370
370
  }, c().log("[Emp] unsubscribe with ", t), W(t));
371
371
  }
372
- function Ie() {
372
+ function Se() {
373
373
  k(u, ce);
374
374
  }
375
- function ye(e) {
376
- let t, o;
377
- e && e.subscription && R(e.subscription) && (t = e.subscription.id, o = u[t], o.cometdSubscription = e.subscription.cometdSubscription);
375
+ function we(e) {
376
+ let t, r;
377
+ e && e.subscription && A(e.subscription) && (t = e.subscription.id, r = u[t], r.cometdSubscription = e.subscription.cometdSubscription);
378
378
  }
379
- function Se(e) {
380
- let t, o, m;
381
- e && e.message && (t = e.subscription.id, o = p[t], o && (m = o.unsubscribeCallback, t && (e.message.successful && delete p[t], c().log(
379
+ function Le(e) {
380
+ let t, r, m;
381
+ e && e.message && (t = e.subscription.id, r = p[t], r && (m = r.unsubscribeCallback, t && (e.message.successful && delete p[t], c().log(
382
382
  "[Emp] unsubscribe callback called for subscription",
383
- o
384
- ), w(m) && m(e.message))));
383
+ r
384
+ ), C(m) && m(e.message))));
385
385
  const I = Object.keys(p).length, q = Object.keys(u).length;
386
386
  c().log(
387
387
  "[Emp] No. of unsubscribes = " + I + ", unsubscribes object:",
@@ -392,61 +392,61 @@ const Q = (() => {
392
392
  );
393
393
  }
394
394
  function Ce(e) {
395
- let t, o, m;
396
- e && e.subscription && (t = e.subscription.id, o = u[t], m = e.message, o && o.callback && (Le(o, m), o.callback(m)));
395
+ let t, r, m;
396
+ e && e.subscription && (t = e.subscription.id, r = u[t], m = e.message, r && r.callback && (ke(r, m), r.callback(m)));
397
397
  }
398
- function Le(e, t) {
398
+ function ke(e, t) {
399
399
  t && t.data && t.data.event && t.data.event.replayId && (e.replayId = t.data.event.replayId);
400
400
  }
401
- function we(e) {
402
- let t, o, m;
403
- e && e.subscription && (t = e.subscription.id, o = u[t], m = e.message, o && o.subscribeCallback && o.subscribeCallback(m));
401
+ function Te(e) {
402
+ let t, r, m;
403
+ e && e.subscription && (t = e.subscription.id, r = u[t], m = e.message, r && r.subscribeCallback && r.subscribeCallback(m));
404
404
  }
405
- function ke() {
405
+ function Oe() {
406
406
  c().log("[Emp] Clearing state before unload..."), re();
407
407
  }
408
- function Te(e) {
408
+ function De(e) {
409
409
  if (!d)
410
410
  return;
411
411
  let t = null;
412
- e && e.params && (t = e.params.state, window.localStorage.setItem(r, t), c().log("[Emp] Cometd state in main is " + t));
412
+ e && e.params && (t = e.params.state, window.localStorage.setItem(n, t), c().log("[Emp] Cometd state in main is " + t));
413
413
  }
414
- function Oe() {
415
- d && window.localStorage.removeItem(r);
414
+ function Ne() {
415
+ d && window.localStorage.removeItem(n);
416
416
  }
417
- function De() {
418
- c().log("[Emp] Terminating cometd worker..."), s && (S === y.LEADER_ELECTION && Je(), S === y.SHARED_WORKER ? s.port.close() : s.terminate(), c().log("[Emp] Set cometdWorker to null"), s = null);
417
+ function We() {
418
+ c().log("[Emp] Terminating cometd worker..."), s && (S === y.LEADER_ELECTION && Pe(), S === y.SHARED_WORKER ? s.port.close() : s.terminate(), c().log("[Emp] Set cometdWorker to null"), s = null);
419
419
  }
420
420
  function Z(e) {
421
421
  if (c().log("[Emp] fromCometdWorker: ", e), e && e.data) {
422
422
  if (e.data.eventType === "functionCall")
423
423
  switch (e.data.functionName) {
424
424
  case "subscribeCallback": {
425
- R(e.data.subscription) ? we(e.data) : N(e.data);
425
+ A(e.data.subscription) ? Te(e.data) : N(e.data);
426
426
  return;
427
427
  }
428
428
  case "unsubscribeCallback": {
429
- K(e.data.subscription) ? Se(e.data) : N(e.data);
429
+ B(e.data.subscription) ? Le(e.data) : N(e.data);
430
430
  return;
431
431
  }
432
432
  case "messageCallback": {
433
- R(e.data.subscription) ? Ce(e.data) : N(e.data);
433
+ A(e.data.subscription) ? Ce(e.data) : N(e.data);
434
434
  return;
435
435
  }
436
436
  case "onErrorCallback": {
437
- A(e.data.listener) ? ge(e.data) : N(e.data);
437
+ R(e.data.listener) ? he(e.data) : N(e.data);
438
438
  return;
439
439
  }
440
440
  case "saveCometdState": {
441
- Te(e.data);
441
+ De(e.data);
442
442
  return;
443
443
  }
444
444
  case "removeCometdState": {
445
- Oe();
445
+ Ne();
446
446
  return;
447
447
  }
448
448
  case "terminateWorker": {
449
- De();
449
+ We();
450
450
  return;
451
451
  }
452
452
  case "setDebugFlag":
@@ -456,16 +456,16 @@ const Q = (() => {
456
456
  "[Emp] fromCometdWorker: No handler found for [" + e.data.functionName + "]."
457
457
  );
458
458
  }
459
- e.data.eventType === "functionReturn" && e.data.functionName === "subscribe" && (R(e.data.subscription) ? ye(e.data) : N(e.data));
459
+ e.data.eventType === "functionReturn" && e.data.functionName === "subscribe" && (A(e.data.subscription) ? we(e.data) : N(e.data));
460
460
  }
461
461
  }
462
- function Ne() {
463
- return !H() && Re() ? y.SHARED_WORKER : We() ? y.LEADER_ELECTION : y.STANDALONE;
462
+ function Ae() {
463
+ return !J() && ve() ? y.SHARED_WORKER : Re() ? y.LEADER_ELECTION : y.STANDALONE;
464
464
  }
465
- function We() {
465
+ function Re() {
466
466
  return d && !!window.Worker;
467
467
  }
468
- function Re() {
468
+ function ve() {
469
469
  let e = T && "SharedWorker" in window;
470
470
  if (e)
471
471
  try {
@@ -479,77 +479,77 @@ const Q = (() => {
479
479
  }
480
480
  return e;
481
481
  }
482
- function Ae() {
482
+ function Me() {
483
483
  return !s && S === y.SHARED_WORKER;
484
484
  }
485
- function ve() {
485
+ function Fe() {
486
486
  return !s && (v() || S === y.STANDALONE);
487
487
  }
488
488
  function ee() {
489
489
  if (T) {
490
490
  let e = !1;
491
- Ae() ? (c().log("[Emp] Create new SharedWorker"), s = new SharedWorker(T), s.port.addEventListener(
491
+ Me() ? (c().log("[Emp] Create new SharedWorker"), s = new SharedWorker(T), s.port.addEventListener(
492
492
  "message",
493
493
  Z
494
- ), s.port.start(), e = !0) : ve() && (c().log("[Emp] Create new WebWorker"), s = new Worker(T), s.addEventListener("message", Z), e = !0), e && (c().log("[Emp] New Worker Created"), i(), z(), oe(), se());
494
+ ), s.port.start(), e = !0) : Fe() && (c().log("[Emp] Create new WebWorker"), s = new Worker(T), s.addEventListener("message", Z), e = !0), e && (c().log("[Emp] New Worker Created"), i(), $(), oe(), se());
495
495
  }
496
496
  }
497
- function Me(e) {
498
- f = e.nodeId, w(_.onNodeIdInit) && _.onNodeIdInit(f);
497
+ function Ue(e) {
498
+ f = e.nodeId, C(_.onNodeIdInit) && _.onNodeIdInit(f);
499
499
  }
500
- function Fe(e) {
501
- C !== e.leaderId && (C = e.leaderId, _.onLeaderChange && _.onLeaderChange(C === f), v() ? ee() : (se(), oe()));
500
+ function He(e) {
501
+ w !== e.leaderId && (w = e.leaderId, _.onLeaderChange && _.onLeaderChange(w === f), v() ? ee() : (se(), oe()));
502
502
  }
503
- function Ue(e) {
503
+ function Je(e) {
504
504
  const t = {};
505
- let o;
506
- e.newValue && e.key === a && (o = JSON.parse(e.newValue), t.data = o), o && o.eventType && (v() ? s ? s.postMessage(o) : c().log("[Emp] Cometd Worker is undefined!") : X(t) && Z(t));
505
+ let r;
506
+ e.newValue && e.key === a && (r = JSON.parse(e.newValue), t.data = r), r && r.eventType && (v() ? s ? s.postMessage(r) : c().log("[Emp] Cometd Worker is undefined!") : X(t) && Z(t));
507
507
  }
508
- function He() {
509
- g || (window.addEventListener("storage", Ue), g = new Ve(Me, Fe), g.setDebugFlag(O), g.start());
508
+ function Ge() {
509
+ g || (window.addEventListener("storage", Je), g = new Ye(Ue, He), g.setDebugFlag(O), g.start());
510
510
  }
511
- function Je() {
511
+ function Pe() {
512
512
  g && v() && (c().log("[Emp] Stop sending heartbeats..."), g.stop(), c().log("[Emp] Leader stopped sending heartbeats"));
513
513
  }
514
- return window.addEventListener("unload", ke), {
514
+ return window.addEventListener("unload", Oe), {
515
515
  init: x,
516
- subscribe: _e,
517
- unsubscribe: he,
518
- onError: pe,
516
+ subscribe: Ie,
517
+ unsubscribe: ye,
518
+ onError: Ee,
519
519
  clearState: re,
520
- setDebugFlag: n,
521
- getState: $
520
+ setDebugFlag: o,
521
+ getState: z
522
522
  };
523
523
  })();
524
- function ue(r) {
525
- return typeof r == "object" && r !== null;
524
+ function de(n) {
525
+ return typeof n == "object" && n !== null;
526
526
  }
527
- function qe(r) {
528
- if (typeof r != "object" || r === null)
527
+ function qe(n) {
528
+ if (typeof n != "object" || n === null)
529
529
  return !1;
530
- const a = r.data;
530
+ const a = n.data;
531
531
  if (typeof a != "object" || a === null)
532
532
  return !1;
533
533
  const l = a.payload, d = a.event;
534
- return typeof r.channel == "string" && typeof l == "object" && l !== null && typeof d == "object" && d !== null;
534
+ return typeof n.channel == "string" && typeof l == "object" && l !== null && typeof d == "object" && d !== null;
535
535
  }
536
536
  let te = null;
537
- function Ye(r) {
538
- return te || (te = r().then((a) => {
539
- Q.init({
537
+ function fe(n) {
538
+ return te || (te = n().then((a) => {
539
+ H.init({
540
540
  cometdUrl: a.cometdUrl,
541
541
  paths: { cometdWorkerJs: a.cometdWorkerJs }
542
542
  });
543
543
  })), te;
544
544
  }
545
- const Y = [];
545
+ const Q = [];
546
546
  let le = !1;
547
547
  const Qe = 2e3, Xe = 200, M = /* @__PURE__ */ new Map();
548
- function ze(r) {
549
- return ue(r) ? r.id == null ? null : String(r.id) : null;
548
+ function $e(n) {
549
+ return de(n) ? n.id == null ? null : String(n.id) : null;
550
550
  }
551
- function ne(r) {
552
- const a = ze(r);
551
+ function ne(n) {
552
+ const a = $e(n);
553
553
  if (a !== null) {
554
554
  const l = Date.now(), d = M.get(a);
555
555
  if (d !== void 0 && l - d < Qe)
@@ -562,36 +562,36 @@ function ne(r) {
562
562
  }
563
563
  M.set(a, l);
564
564
  }
565
- for (const l of [...Y])
565
+ for (const l of [...Q])
566
566
  try {
567
- l(r);
567
+ l(n);
568
568
  } catch {
569
569
  }
570
570
  }
571
- function de() {
572
- le || (le = !0, Q.onError(ne));
571
+ function be() {
572
+ le || (le = !0, H.onError(ne));
573
573
  }
574
- function $e(r) {
575
- return { id: r.id, channel: r.channel, replayId: r.replayId };
574
+ function ze(n) {
575
+ return { id: n.id, channel: n.channel, replayId: n.replayId };
576
576
  }
577
- function xe(r) {
577
+ function xe(n) {
578
578
  return {
579
- id: r.id,
580
- channel: r.channel,
581
- replayId: r.replayId,
582
- unsubscribe: () => et(r)
579
+ id: n.id,
580
+ channel: n.channel,
581
+ replayId: n.replayId,
582
+ unsubscribe: () => et(n)
583
583
  };
584
584
  }
585
- async function Ze(r, a, l, d = Be) {
586
- await Ye(d), de();
587
- const b = Q.subscribe(
588
- r,
585
+ async function Ze(n, a, l, d = ue) {
586
+ await fe(d), be();
587
+ const b = H.subscribe(
588
+ n,
589
589
  a,
590
590
  (E) => {
591
591
  qe(E) && l(E);
592
592
  },
593
593
  (E) => {
594
- if (!ue(E)) {
594
+ if (!de(E)) {
595
595
  ne({ successful: !1, error: "Invalid ack payload" });
596
596
  return;
597
597
  }
@@ -600,26 +600,52 @@ async function Ze(r, a, l, d = Be) {
600
600
  );
601
601
  return xe(b);
602
602
  }
603
- function et(r) {
604
- Q.unsubscribe($e(r));
603
+ function et(n) {
604
+ H.unsubscribe(ze(n));
605
605
  }
606
- function nt(r) {
607
- de();
608
- const a = (l) => r(l);
609
- return Y.push(a), () => {
610
- const l = Y.indexOf(a);
611
- l !== -1 && Y.splice(l, 1);
606
+ function it(n) {
607
+ be();
608
+ const a = (l) => n(l);
609
+ return Q.push(a), () => {
610
+ const l = Q.indexOf(a);
611
+ l !== -1 && Q.splice(l, 1);
612
612
  };
613
613
  }
614
- function ot(r) {
615
- return typeof r.data?.payload == "object" && r.data.payload !== null && "ChangeEventHeader" in r.data.payload;
614
+ function tt() {
615
+ return typeof window < "u" && window.__nimbus != null;
616
+ }
617
+ async function nt(n = ue) {
618
+ if (tt() || typeof Worker > "u")
619
+ return !1;
620
+ try {
621
+ await fe(n);
622
+ } catch {
623
+ return !1;
624
+ }
625
+ return !0;
626
+ }
627
+ const ot = "emp.debugFlag";
628
+ function at(n) {
629
+ H.setDebugFlag(n);
630
+ try {
631
+ localStorage.setItem(ot, String(n));
632
+ } catch {
633
+ }
634
+ }
635
+ function st(n) {
636
+ return typeof n.data?.payload == "object" && n.data.payload !== null && "ChangeEventHeader" in n.data.payload;
637
+ }
638
+ async function ct(n, a, l) {
639
+ return Ze(n, a, l);
616
640
  }
617
- async function rt(r, a, l) {
618
- return Ze(r, a, l);
641
+ async function lt() {
642
+ return nt();
619
643
  }
620
644
  export {
621
- ot as isChangeDataCaptureMessage,
622
- nt as onError,
623
- rt as subscribe,
645
+ st as isChangeDataCaptureMessage,
646
+ lt as isEmpEnabled,
647
+ it as onError,
648
+ at as setDebugFlag,
649
+ ct as subscribe,
624
650
  et as unsubscribe
625
651
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/emp-api",
3
- "version": "12.6.3",
3
+ "version": "12.7.0",
4
4
  "description": "empApi-shaped wrapper for UI Bundles over the platform CometD/Bayeux streaming engine, so a UI Bundle can react to Platform Events and Change Data Capture (CDC) events without polling.",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "type": "module",
@@ -28,13 +28,13 @@
28
28
  "test:coverage": "vitest run --coverage"
29
29
  },
30
30
  "peerDependencies": {
31
- "@salesforce/platform-sdk": "^12.6.3"
31
+ "@salesforce/platform-sdk": "^12.7.0"
32
32
  },
33
33
  "devDependencies": {
34
- "@salesforce/platform-sdk": "^12.6.3",
34
+ "@salesforce/platform-sdk": "^12.7.0",
35
35
  "vite": "^7.3.5",
36
36
  "vite-plugin-dts": "^4.5.4",
37
- "vitest": "^4.0.6"
37
+ "vitest": "^4.1.11"
38
38
  },
39
39
  "publishConfig": {
40
40
  "access": "public"